Boost logo

Boost :

From: Eric D Crahen (crahen_at_[hidden])
Date: 2002-05-19 14:19:34


> My life depends on that lock. I'm going to make sure that I've got the
> only key.

A human might want that sense of security, but as long as the code is
balanced in that every one who adds 1 padlock removed 1 padlock when
they are done, what would be the utility of adding the overhead to make
sure you lock and unlock a specific padlock?

> No. You can have several people who want to turn the switch off at
> the same time, and the rest don't have to wait until the first one turns
> it back on. Once it's off everyone can work.

What happens when the work who wants to turn the switch on arrives?
That worker needs to be sure that there is no padlock present, and
the switch needs to be moved to the on state, that needs to be atomic.
Similarly, each worker who needs to associate thier padlock with the
switch needs to do that atmoicly. If you don't have atmoicity there,
then you have a race condition.

If you look at this from another perspective this is a scenarios for
1 read-write lock. The people going in to work who want the power off
use the read lock and the people turning the power on want the write
lock. Trying to decentralize the serialization of this only complicates
the problem.

- Eric
http://www.cse.buffalo.edu/~crahen


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk