|
|
Subscribe / Log in / New account

Windows NT synchronization primitives for Linux

Windows NT synchronization primitives for Linux

Posted Feb 22, 2024 9:52 UTC (Thu) by farnz (subscriber, #17727)
In reply to: Windows NT synchronization primitives for Linux by Wol
Parent article: Windows NT synchronization primitives for Linux

You can't do it on the first call, because to implement it properly, you need to prevent previous wait-for-any calls from using the kernel mechanism; time-travelling backwards like that is a technical challenge. And Windows handles it by having its kernel equivalent of /dev/ntsync handle wait-for-all as well as wait-for-any; it may have fast paths in there for wait-for-any, but it's all in-kernel.


to post comments

Windows NT synchronization primitives for Linux

Posted Feb 22, 2024 15:05 UTC (Thu) by Wol (subscriber, #4433) [Link] (3 responses)

And a wait-for-any call will go direct from the app bypassing wine?

Otherwise you could presumably ref-count wait-for-any, and if the count was non-zero you'd have to divert new calls and wait for existing calls to go to zero. Messy, assuming it's even possible ...

Cheers,
Wol

Windows NT synchronization primitives for Linux

Posted Feb 22, 2024 15:21 UTC (Thu) by farnz (subscriber, #17727) [Link] (2 responses)

You also need some mechanism to tell all the existing calls in the kernel that wineserver is taking over wait calls now, so they need to return to userspace and be retried (inside Wine) by the IPC mechanism instead of the kernel mechanism, otherwise you can't correctly implement the corner-cases of Win32 when you have both wait-for-any and wait-for-all referencing the same objects.

Windows NT synchronization primitives for Linux

Posted Feb 22, 2024 17:04 UTC (Thu) by Wol (subscriber, #4433) [Link] (1 responses)

That was the point of my ref-counting - wine takes over, but cannot proceed until the ref count drops to zero. Almost certainly not nice ...

Cheers,
Wol

Windows NT synchronization primitives for Linux

Posted Feb 22, 2024 21:36 UTC (Thu) by farnz (subscriber, #17727) [Link]

Wine needs to take over before the ref count drops to zero, else you've regressed. To match Windows kernel behaviour, you either need the Linux kernel to support wait-for-all somehow, or you need the Linux kernel to hand over the existing wait-for-any waits to Wine, so that Wine can correctly emulate the corner cases of wait-for-all.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds