On 10/21/22 14:29, LIU Hao wrote:
在 2022/10/21 20:13, Jacek Caban 写道:
This is not true for past 15 years, CRITICAL_SECTIONS use something
like RtlWaitOnAddress (an equivalent of futexes) since Vista, see
Wine implementation for details:
https://gitlab.winehq.org/wine/wine/-/blob/master/dlls/ntdll/sync.c#L190
Ah Jacek, nice to see you here.
I haven't dug into this too much, though. From my limited knowledge
(mostly from reading disassembly) now CRITICAL_SECTION uses
`NtWaitForAlertByThreadId` (and no longer keyed events or semaphores).
As with `WaitOnAddress()`, there seems to be some global data
structure, protected by a spin lock. It's just another undocumented
syscall. Keyed events are still functional.
NtWaitForAlertByThreadId() is an underlying syscall that's used by
WaitOnAddress(). Anyway, you don't need to worry about that if you just
use public CRITICAL_SECTION APIs.
Jacek