-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
complete the implementation of std.mutex on all platforms #1455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Lock must be the same struct on all architectures so they can be shared between heterogeneous processes. Use-case: https://keithp.com/blogs/Shared_Memory_Fences/ Because musl and glibc do not do this correctly we can't be compatible with them. (although they could become compatible with us in the future) |
WebKit guys have their ParkingLot implementation. |
in regards to "Concurrent Hashtable of Synchronized Queues" of the ParkingLot blog post: I am wondering how much spin-lock contention a concurrent red-black tree has, because that would eliminate out-of-memory and dynamic memory allocation in ParkingLot as the the rb-node could be stored on the stack. https://xuezhaokun.github.io/150-algorithm/ Also, it would allow WTF::Lock-type locks to be shared between processes. (through multiple instances of WTF::ParkingLot) Wouldn't perform as well on NUMA systems however... |
see ziglang#1455 Eventually I would like to see something like WTF::Lock/WTF::ParkingLot, but that is a bunch of work.
When a user wants a lock that is the same struct on all architectures or whatever, they should explicitly request it by using a type that makes this guarantee. The default std lib mutex should not make this guarantee. |
I believe this is done now, thanks to @kprotty's work. If not, please open separate issues for each OS that is not supported. |
As threads can be suspended at any time (even kernel threads!), we need not just spinlocks, but blocking locks implemented with futexes and their equivalent. This is necessary to fix #1363
https://www.kernel.org/doc/Documentation/robust-futexes.txt
http://man7.org/linux/man-pages/man2/futex.2.html
http://man7.org/linux/man-pages/man7/futex.7.html
https://www.akkadia.org/drepper/futex.pdf
The text was updated successfully, but these errors were encountered: