6 #include "linuxrwlocks.h"
13 static void a(void *obj)
16 atomic_store_explicit(&x, 17, memory_order_relaxed);
17 write_unlock(&mylock);
19 if (!read_can_lock(&mylock))
21 if (read_trylock(&mylock)) {
22 atomic_load_explicit(&x, memory_order_relaxed);
27 static void b(void *obj)
30 if (write_trylock(&mylock)) {
31 atomic_store_explicit(&x, 16, memory_order_relaxed);
32 write_unlock(&mylock);
36 atomic_load_explicit(&x, memory_order_relaxed);
40 int user_main(int argc, char **argv)
44 atomic_init(&mylock.lock, RW_LOCK_BIAS);
48 thrd_create(&t1, (thrd_start_t)&a, NULL);
49 thrd_create(&t2, (thrd_start_t)&b, NULL);