418 Subj : Re: lockless low-overhead 'pipes' (w/semaphores) To : comp.programming.threads From : Alexander Terekhov Date : Fri Apr 22 2005 07:34 pm Joe Seigh wrote: [...] > > This transformation is not legal. It changes the order of locking > > operations. In general, it is somewhat hard for compilers (but not > > hardware) to "overlap" critical regions because lock() can block, > > but legitimate transformation shall not block preceding unlock. > > > Does something somewhere actually say that last bit. Actually > they can't overlap because it might cause deadlock, i.e. violate They can overlap as long as it doesn't cause deadlocks and doesn't violate acquire-release ordering. In theory, compiler can also overlap -- using trylock(). (assume throw()-nothing) lock X access A unlock X lock Y access B unlock Y can be tranformed to lock X b = trylock Y if b { access B } access A unlock X if !b { lock, access B } unlock Y regards, alexander. . 0