current_tick simulation added

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1005 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Daniel Stenberg 2002-06-14 12:44:51 +00:00
parent 3f0bf03677
commit 973b1a8274

View file

@ -23,6 +23,7 @@
#include "kernel.h" #include "kernel.h"
#include <poll.h> #include <poll.h>
long current_tick = 0;
/* /*
* We emulate the target threads by using pthreads. We have a mutex that only * 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 */ /* get mutex to only allow one thread running at a time */
pthread_mutex_lock(&mp); pthread_mutex_lock(&mp);
current_tick = time(NULL); /* give it a boost from start! */
} }
/* /*
int pthread_create(pthread_t *new_thread_ID, int pthread_create(pthread_t *new_thread_ID,
@ -45,8 +47,9 @@ void init_threads(void)
void * (*start_func)(void *), void *arg); void * (*start_func)(void *), void *arg);
*/ */
void (yield)(void) void yield(void)
{ {
current_tick+=3;
pthread_mutex_unlock(&mp); /* return */ pthread_mutex_unlock(&mp); /* return */
pthread_mutex_lock(&mp); /* get it again */ pthread_mutex_lock(&mp); /* get it again */
} }
@ -84,6 +87,7 @@ int create_thread(void* fp, void* sp, int stk_size)
/* ticks is HZ per second */ /* ticks is HZ per second */
void x11_sleep(int ticks) void x11_sleep(int ticks)
{ {
current_tick+=5;
pthread_mutex_unlock(&mp); /* return */ pthread_mutex_unlock(&mp); /* return */
/* portable subsecond "sleep" */ /* portable subsecond "sleep" */
poll((void *)0, 0, ticks * 1000/HZ); poll((void *)0, 0, ticks * 1000/HZ);