forked from len0rd/rockbox
Implement cooperative threads on hosted platforms using C code.
This replaces SDL threads with real cooperative threads, which are less cpu intensive and allow priority scheduling. The backend for context switching is dependant on the host (sigaltstack/longjmp on Unix, Fibers on Windows). configure has options to force or disallow SDL threads. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29327 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
3926c30705
commit
6d85de3419
13 changed files with 580 additions and 27 deletions
|
|
@ -184,7 +184,9 @@ static int sdl_event_thread(void * param)
|
|||
|
||||
/* Order here is relevent to prevent deadlocks and use of destroyed
|
||||
sync primitives by kernel threads */
|
||||
sim_thread_shutdown();
|
||||
#ifdef HAVE_SDL_THREADS
|
||||
sim_thread_shutdown(); /* not needed for native threads */
|
||||
#endif
|
||||
sim_kernel_shutdown();
|
||||
|
||||
return 0;
|
||||
|
|
@ -199,9 +201,13 @@ void sim_do_exit(void)
|
|||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
uintptr_t *stackbegin;
|
||||
uintptr_t *stackend;
|
||||
void system_init(void)
|
||||
{
|
||||
SDL_sem *s;
|
||||
/* fake stack, OS manages size (and growth) */
|
||||
stackbegin = stackend = (uintptr_t*)&s;
|
||||
|
||||
#if (CONFIG_PLATFORM & PLATFORM_MAEMO)
|
||||
/* Make glib thread safe */
|
||||
|
|
@ -219,21 +225,24 @@ void system_init(void)
|
|||
/* wait for sdl_event_thread to run so that it can initialize the surfaces
|
||||
* and video subsystem needed for SDL events */
|
||||
SDL_SemWait(s);
|
||||
|
||||
/* cleanup */
|
||||
SDL_DestroySemaphore(s);
|
||||
}
|
||||
|
||||
void system_exception_wait(void)
|
||||
{
|
||||
sim_thread_exception_wait();
|
||||
}
|
||||
|
||||
void system_reboot(void)
|
||||
{
|
||||
#ifdef HAVE_SDL_THREADS
|
||||
sim_thread_exception_wait();
|
||||
#else
|
||||
sim_do_exit();
|
||||
#endif
|
||||
}
|
||||
|
||||
void system_exception_wait(void)
|
||||
{
|
||||
system_reboot();
|
||||
}
|
||||
|
||||
void sys_handle_argv(int argc, char *argv[])
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue