mirror of https://github.com/flysand7/ciabatta.git
Implement thrd_yield on linux
This commit is contained in:
parent
5c6b55e4e5
commit
bbdcbb3e7c
|
@ -18,4 +18,5 @@ enum {
|
||||||
|
|
||||||
int thrd_create(thrd_t *thr, thrd_start_t func, void *arg);
|
int thrd_create(thrd_t *thr, thrd_start_t func, void *arg);
|
||||||
int thrd_join(thrd_t thr, int *out_exit_code);
|
int thrd_join(thrd_t thr, int *out_exit_code);
|
||||||
int thrd_detach(thrd_t thr);
|
int thrd_detach(thrd_t thr);
|
||||||
|
void thrd_yield();
|
|
@ -58,6 +58,7 @@ static _RT_Status _rt_thread_create(_RT_Thread *thread, int (*thread_fn)(void *c
|
||||||
static _RT_Status _rt_thread_join(_RT_Thread *thread, int *out_exit_code);
|
static _RT_Status _rt_thread_join(_RT_Thread *thread, int *out_exit_code);
|
||||||
static _RT_Status _rt_thread_detach(_RT_Thread *thread);
|
static _RT_Status _rt_thread_detach(_RT_Thread *thread);
|
||||||
static _RT_Status _rt_thread_terminate(_RT_Thread *thread);
|
static _RT_Status _rt_thread_terminate(_RT_Thread *thread);
|
||||||
|
static _RT_Status _rt_thread_yield();
|
||||||
static _RT_Status _rt_thread_sleep(u64 time);
|
static _RT_Status _rt_thread_sleep(u64 time);
|
||||||
static _RT_Status _rt_thread_get_timer_freq(u64 *freq);
|
static _RT_Status _rt_thread_get_timer_freq(u64 *freq);
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,15 @@ static _RT_Status _rt_thread_detach(_RT_Thread *thread) {
|
||||||
return _RT_STATUS_OK;
|
return _RT_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static _RT_Status _rt_thread_yield() {
|
||||||
|
i64 status = syscall(SYS_sched_yield);
|
||||||
|
if(status != 0) {
|
||||||
|
// shouldn't happen on linux
|
||||||
|
return _RT_ERROR_GENERIC;
|
||||||
|
}
|
||||||
|
return _RT_STATUS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static _RT_Status _rt_thread_terminate(_RT_Thread *thread) {
|
static _RT_Status _rt_thread_terminate(_RT_Thread *thread) {
|
||||||
return _RT_ERROR_NOT_IMPLEMENTED;
|
return _RT_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ void cia_mutex_lock(Cia_Mutex *mutex) {
|
||||||
, memory_order_acquire
|
, memory_order_acquire
|
||||||
, memory_order_relaxed
|
, memory_order_relaxed
|
||||||
);
|
);
|
||||||
|
|
||||||
// We got the mutex, lets bail
|
// We got the mutex, lets bail
|
||||||
if(p_tag == _CIA_MUTEX_FREE) {
|
if(p_tag == _CIA_MUTEX_FREE) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -22,3 +22,7 @@ int thrd_join(thrd_t thr, int *out_exit_code) {
|
||||||
}
|
}
|
||||||
return thrd_error;
|
return thrd_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void thrd_yield(void) {
|
||||||
|
_rt_thread_yield();
|
||||||
|
}
|
Loading…
Reference in New Issue