1

I'm implementing pessimistic locking for a distributed key-value store. I have a rock-solid atomic compare-exchange (and increment and decrement) operation for implementing the locks. There's also data structures for sets, sorted sets, lists, and arrays that already offer atomic operations (and I can manipulate these structures in any way, atomically, using server-side scripts).

Using the above as building blocks, I need to make a reentrant mutex that supports an operation like .Net's WaitHandle.WaitAll, ie. being able to lock multiple resources in one call, while minimizing the possibility of live lock and starvation. How do I do that? Is there a generally accepted algorithm?

As a side question, I've looked at things like Peterson's algorithm and its kin, but it seems these mutual exclusion algorithms are solving a different problem than what I'm facing (I already have atomic operations). I'm working towards something that I believe is considered a more advanced synchronization primitive (based on the title of http://en.wikipedia.org/wiki/Mutual_exclusion#Advanced_mutual_exclusion) and I'm wondering if there's a separate class of algorithms that answer these less-down-to-the-core problems.

Brent
  • 4,153
  • 4
  • 30
  • 63

0 Answers0