Hi,

FYI, if you haven't seen this yet:
https://github.com/abseil/abseil-cpp/blob/master/absl/synchronization/mutex.h
https://github.com/abseil/abseil-cpp/blob/master/absl/synchronization/mutex.cc

Some minor improvements are possible, but overall it's a piece of art.
Originally developed by Mike Burrows
(https://en.wikipedia.org/wiki/Michael_Burrows). If you like learning
synchronization primitives, this one will be a good time investment.
The main design goal I guess is handling all possible usage scenarios
gracefully (i.e. not just readers, or writers, or light contention, or
heavy contention, or few waiters, or thousands of waiters, etc) which
is expected of a primitive used in literally millions of place across
thousands of systems. It also has some interesting features like
contention profiling and deadlock detection. FWIW it also fits into a
single intptr (i.e. 4 bytes on 32-bit systems).

There is also a bit simplified version of the same algo in nsync library:
https://github.com/google/nsync/blob/master/README
https://github.com/google/nsync/blob/master/internal/mu.c
It's C and does not have contention profiling and deadlock detection,
so may be easier for leaning of the mutex algorithm itself.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"Scalable Synchronization Algorithms" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to lock-free+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/lock-free/CAEeQi3tstU5aQU%3Dq7oXXwrxRzQzsDzKJE66_hKSB4sUbZJsNzA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to