From a4d19b7e899a9223433fcb91627af737a638e9d3 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Mon, 3 Dec 2007 14:01:12 +0000 Subject: Simplify the uisimulator I/O routine and let the rockbox thread calling the functions be the background thread. Should speed things up too and lose none of the advantanges of background I/O. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15870 a1c6a512-1295-4272-9138-f99709370657 --- uisimulator/sdl/thread-sdl.c | 17 +++++++++++++++++ uisimulator/sdl/thread-sdl.h | 2 ++ uisimulator/sdl/uisdl.c | 6 ------ 3 files changed, 19 insertions(+), 6 deletions(-) (limited to 'uisimulator/sdl') 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) return true; } +/* A way to yield and leave the threading system for extended periods */ +void thread_sdl_thread_lock(void *me) +{ + SDL_LockMutex(m); + running = (struct thread_entry *)me; + + if (threads_exit) + remove_thread(NULL); +} + +void * thread_sdl_thread_unlock(void) +{ + struct thread_entry *current = running; + SDL_UnlockMutex(m); + return current; +} + static int find_empty_thread_slot(void) { 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 @@ #include "SDL_thread.h" extern SDL_Thread *gui_thread; /* The "main" thread */ +void thread_sdl_thread_lock(void *me); +void * thread_sdl_thread_unlock(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 */ 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) sync primitives by kernel threads */ thread_sdl_shutdown(); SDL_RemoveTimer(tick_timer_id); - sim_io_shutdown(); sim_kernel_shutdown(); return true; } @@ -277,11 +276,6 @@ int main(int argc, char *argv[]) return -1; } - if (!sim_io_init()) { - fprintf(stderr, "sim_io_init failed\n"); - return -1; - } - if (!gui_startup()) { fprintf(stderr, "gui_startup failed\n"); return -1; -- cgit v1.2.3