diff --git a/src/thread/thread.c b/src/thread/thread.c new file mode 100644 index 0000000..ad673eb --- /dev/null +++ b/src/thread/thread.c @@ -0,0 +1,31 @@ +#include "thread.h" +#include "debug.h" +#include "pthread.h" +#include + + +int thread_yield(void) { + TRACE("yield\n"); + return sched_yield(); +} + + +thread_t thread_self(void) { +return (void *) pthread_self(); +} + +int thread_create(thread_t *newthread, void *(*func)(void *), void *funcarg) { + TRACE("Create a new thread that execute function %p", func); + return pthread_create((pthread_t *) newthread, NULL, func, funcarg); +} + +int thread_join(thread_t thread, void **retval) { + TRACE("Join thread %p", thread); + return pthread_join((pthread_t) thread, retval); +} + +void thread_exit(void *retval) { + TRACE("Exit thread"); + pthread_exit(retval); +} +