While implementing my blocking system using futexes, I wondered if I couldn't do something smarter.
Now, I directly use futexes to actually have a binary semaphore over a value in mmap. It's kind of cumbersome, but it works right now.
But, it is not as battle tested as a Mutex could be, since the latter IS using futexes underneath as well, but certainly more correctly than I do (corner cases.. the list is long).
My only issue is this:
let mutex = Mutex::new(0);
I would like something like
let mutex = Mutex::new(&from_value_in_mmap);
and mutex would directly apply the logic on the shared memory atomic u32, which is synchronizing the threads/processes.
Note: I just need to support Linux x86_64.
Is there a way to achieve this without needing to implement a full blow locking mechanism myself ?
Again, mine is working but I'm trying to converge the efforts.