News for hackers. Stuff that matters.
Re:Use lock addresses to enforce uniform locking order. Avoi... by jeremyjh on Sunday June 14, 2015 @09:15AM (#9714767)
If you are always going to grab locks in the same order, doesn't that mean you only need one lock?
Re:Use lock addresses to enforce uniform locking order. Avoi... by JoeAltmaier on Sunday June 14, 2015 @09:16AM (#9714772)
Different places in the code may take a different set of locks. Its about granularity, letting different threads continue while different locks are held.
Re:Use lock addresses to enforce uniform locking order. Avoi... by michaelochurch on Sunday June 14, 2015 @01:44PM (#9715710)
It works as long as you know which locks you need in advance. You'll get much better concurrency than with the one-lock model when there's a low probability that two processes need any of the same locks (e.g. locking a whole table vs. locking individual records).

It fails you if you have a monadic rather than applicative requirement on the computation; that is, if intermediate computations can require you to take more locks that you couldn't have predicted needing in advance. In that case, you're going to need a transactional-memory system that can abort and retry computations, and that is powerful but hard to get right.