From 973b1a827413189098d206a1023916a375a0e94c Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 14 Jun 2002 12:44:51 +0000 Subject: current_tick simulation added git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1005 a1c6a512-1295-4272-9138-f99709370657 --- uisimulator/x11/thread.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/uisimulator/x11/thread.c b/uisimulator/x11/thread.c index ddaae313ae..437080acc9 100644 --- a/uisimulator/x11/thread.c +++ b/uisimulator/x11/thread.c @@ -23,6 +23,7 @@ #include "kernel.h" #include +long current_tick = 0; /* * We emulate the target threads by using pthreads. We have a mutex that only @@ -38,6 +39,7 @@ void init_threads(void) /* get mutex to only allow one thread running at a time */ pthread_mutex_lock(&mp); + current_tick = time(NULL); /* give it a boost from start! */ } /* int pthread_create(pthread_t *new_thread_ID, @@ -45,16 +47,17 @@ void init_threads(void) void * (*start_func)(void *), void *arg); */ -void (yield)(void) +void yield(void) { + current_tick+=3; pthread_mutex_unlock(&mp); /* return */ pthread_mutex_lock(&mp); /* get it again */ } void newfunc(void (*func)(void)) { - yield(); - func(); + yield(); + func(); } @@ -72,9 +75,9 @@ int create_thread(void* fp, void* sp, int stk_size) (void *(*)(void *)) newfunc, /* function to start */ fp /* start argument */); if(0 != error) - fprintf(stderr, "Couldn't run thread number %d, errno %d\n", i, error); + fprintf(stderr, "Couldn't run thread number %d, errno %d\n", i, error); else - fprintf(stderr, "Thread %ld is running\n", (long)tid); + fprintf(stderr, "Thread %ld is running\n", (long)tid); yield(); @@ -84,6 +87,7 @@ int create_thread(void* fp, void* sp, int stk_size) /* ticks is HZ per second */ void x11_sleep(int ticks) { + current_tick+=5; pthread_mutex_unlock(&mp); /* return */ /* portable subsecond "sleep" */ poll((void *)0, 0, ticks * 1000/HZ); -- cgit v1.2.3