简体   繁体   中英

How compare to a constant with WaitOnAddress

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?

WaitOnAddress is not used as a single call wait instruction, it is generally called in a loop egRaymond 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM