feat[pthread]: implement with thread with pthread lib

This commit is contained in:
Martin Eyben 2025-03-14 17:55:57 +01:00
parent 91d6d55a74
commit b26dc40079

31
src/thread/thread.c Normal file
View File

@ -0,0 +1,31 @@
#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);
}