diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2009-01-08 11:08:22 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2009-01-08 11:08:22 +0000 |
commit | 33a7f3a6cff78ff625621e6a3d4a5728328de0e3 (patch) | |
tree | f7edec5c96d18c4666a1108a3b523ff217cba7dd /uisimulator | |
parent | cb7e88d3b677dee6948608c944eded256acf37fd (diff) | |
download | rockbox-33a7f3a6cff78ff625621e6a3d4a5728328de0e3.tar.gz rockbox-33a7f3a6cff78ff625621e6a3d4a5728328de0e3.zip |
Allow sims to shut down normally from panic code.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19718 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator')
-rw-r--r-- | uisimulator/common/stubs.c | 4 | ||||
-rw-r--r-- | uisimulator/sdl/thread-sdl.c | 17 | ||||
-rw-r--r-- | uisimulator/sdl/thread-sdl.h | 1 |
3 files changed, 18 insertions, 4 deletions
diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c index 12b6f293a4..58e18392bc 100644 --- a/uisimulator/common/stubs.c +++ b/uisimulator/common/stubs.c @@ -342,12 +342,12 @@ void touchpad_set_sensitivity(int level) void system_exception_wait(void) { - while(1); + thread_sdl_exception_wait(); } void system_reboot(void) { - while(1); + thread_sdl_exception_wait(); } /* assure an unused place to direct virtual pointers to */ diff --git a/uisimulator/sdl/thread-sdl.c b/uisimulator/sdl/thread-sdl.c index ab1086dd7d..1522f318a6 100644 --- a/uisimulator/sdl/thread-sdl.c +++ b/uisimulator/sdl/thread-sdl.c @@ -64,15 +64,18 @@ extern long start_tick; void thread_sdl_shutdown(void) { int i; - /* Take control */ - SDL_LockMutex(m); /* Tell all threads jump back to their start routines, unlock and exit gracefully - we'll check each one in turn for it's status. Threads _could_ terminate via remove_thread or multiple threads could exit on each unlock but that is safe. */ + + /* Do this before trying to acquire lock */ threads_exit = true; + /* Take control */ + SDL_LockMutex(m); + for (i = 0; i < MAXTHREADS; i++) { struct thread_entry *thread = &threads[i]; @@ -200,6 +203,16 @@ bool thread_sdl_init(void *param) return true; } +void thread_sdl_exception_wait(void) +{ + while (1) + { + SDL_Delay(HZ/10); + if (threads_exit) + thread_exit(); + } +} + /* A way to yield and leave the threading system for extended periods */ void thread_sdl_thread_lock(void *me) { diff --git a/uisimulator/sdl/thread-sdl.h b/uisimulator/sdl/thread-sdl.h index b88ba50f8c..f221aa5a72 100644 --- a/uisimulator/sdl/thread-sdl.h +++ b/uisimulator/sdl/thread-sdl.h @@ -27,6 +27,7 @@ extern SDL_Thread *gui_thread; /* The "main" thread */ void thread_sdl_thread_lock(void *me); void * thread_sdl_thread_unlock(void); +void thread_sdl_exception_wait(void); bool thread_sdl_init(void *param); /* Init the sim threading API - thread created calls app_main */ void thread_sdl_shutdown(void); /* Shut down all kernel threads gracefully */ void thread_sdl_lock(void); /* Sync with SDL threads */ |