mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-04 18:28:30 +00:00
Support process shared condition variables
This commit is contained in:
parent
3de6632be6
commit
0a9a6f86bb
14 changed files with 168 additions and 19 deletions
|
@ -22,6 +22,8 @@
|
|||
#include "libc/runtime/syslib.internal.h"
|
||||
#include "libc/thread/thread.h"
|
||||
|
||||
void sys_sched_yield(void);
|
||||
|
||||
/**
|
||||
* Yields current thread's remaining timeslice to operating system.
|
||||
*
|
||||
|
@ -30,13 +32,16 @@
|
|||
int pthread_yield_np(void) {
|
||||
if (IsXnuSilicon()) {
|
||||
__syslib->__pthread_yield_np();
|
||||
} else if (IsOpenbsd()) {
|
||||
pthread_pause_np(); // sched_yield() is punishingly slow on OpenBSD
|
||||
} else if (IsOpenbsd() || IsNetbsd()) {
|
||||
// sched_yield() is punishingly slow on OpenBSD
|
||||
// it's ruinously slow it'll destroy everything
|
||||
pthread_pause_np();
|
||||
} else {
|
||||
sched_yield();
|
||||
sys_sched_yield();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
__weak_reference(pthread_yield_np, thrd_yield);
|
||||
__weak_reference(pthread_yield_np, sched_yield);
|
||||
__weak_reference(pthread_yield_np, pthread_yield);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue