[Info-vax] K-mutex

Pierre pierre.bru at gmail.com
Thu Dec 15 17:48:40 EST 2011


On Dec 15, 3:07 pm, koeh... at eisner.nospam.encompasserve.org (Bob
Koehler) wrote:
> In article <7c16fc0a-4f6a-4f56-b170-448c721b0... at p16g2000yqd.googlegroups.com>, Pierre <pierre.... at gmail.com> writes:

> > the easiest way to emulate semaphores with the DLM is to use a lock
> > with a value block. this method is not fault-tolerant but neither are
> > semaphores (if a process crash before freeing the resource slot, this
> > slot may be totally  lost).
>
>    An implementation that doesn't wind down when a process crashes is
>    poor and incomplete.  Certainly VMS would release any locks held
>    by the process.  More sophisticated handling could be entered into
>    an image exit handler.

semaphores are NOT locks. semaphores are system-wide "counters" that
may be waited for (counter = counter -1) or signaled (counter =
counter + 1) by ANY process. this is the by-design behavior of
semaphores and a lot of semaphore-patterns heavily rely on that
behavior. MAYBE a by-image specific image rundown could do some
cleanup. but even in this context, this would be very difficult as the
image rundown would have to know exactly what the program was
executing when it crashed. and in anyway, the process rundown would
have a very hard time to do this, if possible.

one of the so many unix flavors (can't remember which one) introduced
a new kind of semaphore with a possible hint to tell the image/process
rundown what to do in case of image/process crash. but this is non-
standard and according to the programmers, not very efficient.

semaphores are a good tool to synchronize threads/processes but in a
world without image/process crashes.

http://en.wikipedia.org/wiki/Semaphore_%28programming%29

Pierre.



More information about the Info-vax mailing list