Use futexes on OpenBSD and improve threading

This commit is contained in:
Justine Tunney 2022-07-17 19:59:49 -07:00
parent 5b11033d4d
commit 4f4889ddf7
17 changed files with 114 additions and 63 deletions

View file

@ -36,10 +36,14 @@ void _wait0(const int *ctid) {
for (;;) {
if (!(x = atomic_load_explicit(ctid, memory_order_acquire))) {
break;
} else if (IsLinux() /* || IsOpenbsd() */) {
} else if (IsLinux() || IsOpenbsd()) {
_futex_wait(ctid, x, &(struct timespec){2});
} else {
sched_yield();
}
}
if (IsOpenbsd()) {
// TODO(jart): whyyyy do we need it
sched_yield();
}
}