Reputation: 360
In Linux, futexs have the following signature
long futex(uint32_t *uaddr, int futex_op, uint32_t val, const struct timespec *timeout)
, so I can say syscall(SYS_futex, &m_address, FUTEX_WAIT_PRIVATE, 1, nullptr);
which will pause the current thread if the value at m_address is 1.
What I want to know is how do I do this in windows.
The signature for BOOL WaitOnAddress(volatile VOID *Address, PVOID CompareAddress, SIZE_T AddressSize, DWORD dwMilliseconds)
. There's no option for a value. Do I have to make a variable with constant value and pass it to CompareAddress or am I missing something?
Upvotes: 0
Views: 170
Reputation: 247
WaitOnAddress is not used as a single call wait instruction, it is generally called in a loop e.g. Raymond Chen - A helper template function to wait for WaitOnAddress in a loop. Nor will it wake without extra help, whatever code changes the bytes at Address must also call WakeByAddressSingle or WakeByAddressAll to allow any active WaitOnAddress calls to return.
Upvotes: 2