summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2009-01-08 11:08:22 +0000
committerMichael Sevakis <jethead71@rockbox.org>2009-01-08 11:08:22 +0000
commit33a7f3a6cff78ff625621e6a3d4a5728328de0e3 (patch)
treef7edec5c96d18c4666a1108a3b523ff217cba7dd
parentcb7e88d3b677dee6948608c944eded256acf37fd (diff)
downloadrockbox-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
-rw-r--r--uisimulator/common/stubs.c4
-rw-r--r--uisimulator/sdl/thread-sdl.c17
-rw-r--r--uisimulator/sdl/thread-sdl.h1
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)
342 342
343void system_exception_wait(void) 343void system_exception_wait(void)
344{ 344{
345 while(1); 345 thread_sdl_exception_wait();
346} 346}
347 347
348void system_reboot(void) 348void system_reboot(void)
349{ 349{
350 while(1); 350 thread_sdl_exception_wait();
351} 351}
352 352
353/* assure an unused place to direct virtual pointers to */ 353/* 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;
64void thread_sdl_shutdown(void) 64void thread_sdl_shutdown(void)
65{ 65{
66 int i; 66 int i;
67 /* Take control */
68 SDL_LockMutex(m);
69 67
70 /* Tell all threads jump back to their start routines, unlock and exit 68 /* Tell all threads jump back to their start routines, unlock and exit
71 gracefully - we'll check each one in turn for it's status. Threads 69 gracefully - we'll check each one in turn for it's status. Threads
72 _could_ terminate via remove_thread or multiple threads could exit 70 _could_ terminate via remove_thread or multiple threads could exit
73 on each unlock but that is safe. */ 71 on each unlock but that is safe. */
72
73 /* Do this before trying to acquire lock */
74 threads_exit = true; 74 threads_exit = true;
75 75
76 /* Take control */
77 SDL_LockMutex(m);
78
76 for (i = 0; i < MAXTHREADS; i++) 79 for (i = 0; i < MAXTHREADS; i++)
77 { 80 {
78 struct thread_entry *thread = &threads[i]; 81 struct thread_entry *thread = &threads[i];
@@ -200,6 +203,16 @@ bool thread_sdl_init(void *param)
200 return true; 203 return true;
201} 204}
202 205
206void thread_sdl_exception_wait(void)
207{
208 while (1)
209 {
210 SDL_Delay(HZ/10);
211 if (threads_exit)
212 thread_exit();
213 }
214}
215
203/* A way to yield and leave the threading system for extended periods */ 216/* A way to yield and leave the threading system for extended periods */
204void thread_sdl_thread_lock(void *me) 217void thread_sdl_thread_lock(void *me)
205{ 218{
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 @@
27extern SDL_Thread *gui_thread; /* The "main" thread */ 27extern SDL_Thread *gui_thread; /* The "main" thread */
28void thread_sdl_thread_lock(void *me); 28void thread_sdl_thread_lock(void *me);
29void * thread_sdl_thread_unlock(void); 29void * thread_sdl_thread_unlock(void);
30void thread_sdl_exception_wait(void);
30bool thread_sdl_init(void *param); /* Init the sim threading API - thread created calls app_main */ 31bool thread_sdl_init(void *param); /* Init the sim threading API - thread created calls app_main */
31void thread_sdl_shutdown(void); /* Shut down all kernel threads gracefully */ 32void thread_sdl_shutdown(void); /* Shut down all kernel threads gracefully */
32void thread_sdl_lock(void); /* Sync with SDL threads */ 33void thread_sdl_lock(void); /* Sync with SDL threads */