Preallocate the waitq handle
commit8a18d5b12d97994512eb8cf90665e94bad8df103
authorJakub Jermar <jakub@jermar.eu>
Sat, 10 Nov 2018 16:22:29 +0000 (10 17:22 +0100)
committerJakub Jermar <jakub@jermar.eu>
Sun, 11 Nov 2018 15:47:39 +0000 (11 16:47 +0100)
treedce1104c7986ba28e82f6db3907f970bb6793cfe
parent0b5203bfbdafa8ef8abc2bd7521c6fd282f677e9
Preallocate the waitq handle

This fixes a race condition (a missing wakeup) when the wakeup was
faster than the thread going to sleep and no handle was allocated yet.
The handle get preallocated to avoid a possible allocation failure in
wakeup.

We also switched to using atomic_compare_exchange_weak_explicit() to fix
ARMv4 and ARMv5 builds.
uspace/lib/c/generic/private/futex.h
uspace/lib/c/generic/thread/futex.c