32 lines
657 B
C
32 lines
657 B
C
#include "thread.h"
|
|
#include "debug.h"
|
|
#include "pthread.h"
|
|
#include <sched.h>
|
|
|
|
|
|
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);
|
|
}
|
|
|