Write some lock contention tests

This commit is contained in:
Justine Tunney 2022-06-16 09:06:09 -07:00
parent 42c38bc3e3
commit c06ffd458c
19 changed files with 205 additions and 76 deletions

View file

@ -0,0 +1,20 @@
#ifndef COSMOPOLITAN_LIBC_INTRIN_WAIT0_H_
#define COSMOPOLITAN_LIBC_INTRIN_WAIT0_H_
#include "libc/bits/atomic.h"
#include "libc/calls/calls.h"
#include "libc/dce.h"
#include "libc/linux/futex.h"
#define _wait0(ptid) \
do { \
int x; \
if (!(x = atomic_load_explicit(ptid, memory_order_relaxed))) { \
break; \
} else if (IsLinux()) { \
LinuxFutexWait(ptid, x, 0); \
} else { \
sched_yield(); \
} \
} while (1)
#endif /* COSMOPOLITAN_LIBC_INTRIN_WAIT0_H_ */