summaryrefslogtreecommitdiffstats
path: root/uisimulator/sdl/thread-sdl.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-09-09 08:28:42 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-09-09 08:28:42 +0000
commit3a45faa6a8b12cd7a798f488c2fc9bc60327f5cd (patch)
tree5dbe71d5582798ac32044e0f3723025059aee26b /uisimulator/sdl/thread-sdl.c
parentb0a1ed1852fb7574cdda515c0e481b760b693b40 (diff)
downloadrockbox-3a45faa6a8b12cd7a798f488c2fc9bc60327f5cd.tar.gz
rockbox-3a45faa6a8b12cd7a798f488c2fc9bc60327f5cd.tar.bz2
rockbox-3a45faa6a8b12cd7a798f488c2fc9bc60327f5cd.zip
More Simulator tweaking. Back to the counter but with 0 delay. Forget the semaphore; it makes for too much kernel thread yielding.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14649 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator/sdl/thread-sdl.c')
-rw-r--r--uisimulator/sdl/thread-sdl.c26
1 files changed, 8 insertions, 18 deletions
diff --git a/uisimulator/sdl/thread-sdl.c b/uisimulator/sdl/thread-sdl.c
index 8769b5d84f..d146cfb64b 100644
--- a/uisimulator/sdl/thread-sdl.c
+++ b/uisimulator/sdl/thread-sdl.c
@@ -45,7 +45,6 @@ static char __name[32];
struct thread_entry threads[MAXTHREADS]; /* Thread entries as in core */
static SDL_mutex *m;
-static SDL_sem *s;
static struct thread_entry *running;
extern long start_tick;
@@ -60,9 +59,7 @@ void kill_sim_threads(void)
if (thread->context.t != NULL)
{
SDL_LockMutex(m);
- if (thread->statearg == STATE_RUNNING)
- SDL_SemPost(s);
- else
+ if (thread->statearg != STATE_RUNNING)
SDL_CondSignal(thread->context.c);
SDL_Delay(10);
SDL_KillThread(thread->context.t);
@@ -70,7 +67,6 @@ void kill_sim_threads(void)
}
}
SDL_DestroyMutex(m);
- SDL_DestroySemaphore(s);
}
static int find_empty_thread_slot(void)
@@ -144,19 +140,20 @@ void thread_sdl_unlock(void)
void switch_thread(bool save_context, struct thread_entry **blocked_list)
{
+ static int counter = 0;
struct thread_entry *current = running;
SDL_UnlockMutex(m);
- SDL_SemWait(s);
-
- SDL_Delay(0);
+ if (counter++ >= 50)
+ {
+ SDL_Delay(0);
+ counter = 0;
+ }
SDL_LockMutex(m);
running = current;
- SDL_SemPost(s);
-
(void)save_context; (void)blocked_list;
}
@@ -299,7 +296,6 @@ void init_threads(void)
int slot;
m = SDL_CreateMutex();
- s = SDL_CreateSemaphore(0);
memset(threads, 0, sizeof(threads));
@@ -324,10 +320,6 @@ void init_threads(void)
if (SDL_LockMutex(m) == -1) {
THREAD_PANICF("Couldn't lock mutex\n");
}
-
- if (SDL_SemPost(s) == -1) {
- THREAD_PANICF("Couldn't post to semaphore\n");
- }
}
void remove_thread(struct thread_entry *thread)
@@ -347,9 +339,7 @@ void remove_thread(struct thread_entry *thread)
if (thread != current)
{
- if (thread->statearg == STATE_RUNNING)
- SDL_SemPost(s);
- else
+ if (thread->statearg != STATE_RUNNING)
SDL_CondSignal(c);
}