diff options
Diffstat (limited to 'uisimulator/sdl')
-rw-r--r-- | uisimulator/sdl/thread-sdl.c | 17 | ||||
-rw-r--r-- | uisimulator/sdl/thread-sdl.h | 2 | ||||
-rw-r--r-- | uisimulator/sdl/uisdl.c | 6 |
3 files changed, 19 insertions, 6 deletions
diff --git a/uisimulator/sdl/thread-sdl.c b/uisimulator/sdl/thread-sdl.c index a07ac29738..b8297072f2 100644 --- a/uisimulator/sdl/thread-sdl.c +++ b/uisimulator/sdl/thread-sdl.c | |||
@@ -157,6 +157,23 @@ bool thread_sdl_init(void *param) | |||
157 | return true; | 157 | return true; |
158 | } | 158 | } |
159 | 159 | ||
160 | /* A way to yield and leave the threading system for extended periods */ | ||
161 | void thread_sdl_thread_lock(void *me) | ||
162 | { | ||
163 | SDL_LockMutex(m); | ||
164 | running = (struct thread_entry *)me; | ||
165 | |||
166 | if (threads_exit) | ||
167 | remove_thread(NULL); | ||
168 | } | ||
169 | |||
170 | void * thread_sdl_thread_unlock(void) | ||
171 | { | ||
172 | struct thread_entry *current = running; | ||
173 | SDL_UnlockMutex(m); | ||
174 | return current; | ||
175 | } | ||
176 | |||
160 | static int find_empty_thread_slot(void) | 177 | static int find_empty_thread_slot(void) |
161 | { | 178 | { |
162 | int n; | 179 | int n; |
diff --git a/uisimulator/sdl/thread-sdl.h b/uisimulator/sdl/thread-sdl.h index 3739130f97..0f3b7b6d3a 100644 --- a/uisimulator/sdl/thread-sdl.h +++ b/uisimulator/sdl/thread-sdl.h | |||
@@ -23,6 +23,8 @@ | |||
23 | #include "SDL_thread.h" | 23 | #include "SDL_thread.h" |
24 | 24 | ||
25 | extern SDL_Thread *gui_thread; /* The "main" thread */ | 25 | extern SDL_Thread *gui_thread; /* The "main" thread */ |
26 | void thread_sdl_thread_lock(void *me); | ||
27 | void * thread_sdl_thread_unlock(void); | ||
26 | bool thread_sdl_init(void *param); /* Init the sim threading API - thread created calls app_main */ | 28 | bool thread_sdl_init(void *param); /* Init the sim threading API - thread created calls app_main */ |
27 | void thread_sdl_shutdown(void); /* Shut down all kernel threads gracefully */ | 29 | void thread_sdl_shutdown(void); /* Shut down all kernel threads gracefully */ |
28 | void thread_sdl_lock(void); /* Sync with SDL threads */ | 30 | void thread_sdl_lock(void); /* Sync with SDL threads */ |
diff --git a/uisimulator/sdl/uisdl.c b/uisimulator/sdl/uisdl.c index de6089b648..e0a449ed48 100644 --- a/uisimulator/sdl/uisdl.c +++ b/uisimulator/sdl/uisdl.c | |||
@@ -192,7 +192,6 @@ bool gui_shutdown(void) | |||
192 | sync primitives by kernel threads */ | 192 | sync primitives by kernel threads */ |
193 | thread_sdl_shutdown(); | 193 | thread_sdl_shutdown(); |
194 | SDL_RemoveTimer(tick_timer_id); | 194 | SDL_RemoveTimer(tick_timer_id); |
195 | sim_io_shutdown(); | ||
196 | sim_kernel_shutdown(); | 195 | sim_kernel_shutdown(); |
197 | return true; | 196 | return true; |
198 | } | 197 | } |
@@ -277,11 +276,6 @@ int main(int argc, char *argv[]) | |||
277 | return -1; | 276 | return -1; |
278 | } | 277 | } |
279 | 278 | ||
280 | if (!sim_io_init()) { | ||
281 | fprintf(stderr, "sim_io_init failed\n"); | ||
282 | return -1; | ||
283 | } | ||
284 | |||
285 | if (!gui_startup()) { | 279 | if (!gui_startup()) { |
286 | fprintf(stderr, "gui_startup failed\n"); | 280 | fprintf(stderr, "gui_startup failed\n"); |
287 | return -1; | 281 | return -1; |