volatile (in comp.lang.c)

Stephen Crawley scc at cl.cam.ac.uk
Tue May 31 01:57:27 AEST 1988


In article <21821 at amdcad.AMD.COM> rpw3 at amdcad.UUCP (Rob Warnock) writes:
>There is a perfectly respectable mutual exclusion technique which can be
>used on multi-processor machines, which requires no special hardware, and
>requires only that writes of a small integer are atomic. (The "small integer"
>has to be able to hold a processor number.) In the two-processor case, this
>is called "Dekker's Algorithm".  (For large numbers of processors, it is
>called "expensive"!  ;-}  ;-}  )
>
>Rob Warnock
>Systems Architecture Consultant

A more recent solution to the mutual exclusion is NOT expensive for multiple
processors:

  "A Fast Mutual Exclusion Algortithm"
  Leslie Lamport, Nov 14 1985.
  Report #5, DEC Systems Research Centre

The review at the beginning of the report (by Butler Lampson) says it 
better than I can:

"   To build a useful computer system from a collection of processors that
communicate by sharing memory, but lack any atomic operation more complex
than a memory read or write, it is necessary to implement mutual exclusion
by using only these operations.  Solutions to this problem have been known
for twenty years, but they are linear in the number of processors.  Lamport
presents a new algorithm which takes constant time (five writes and two
reads) in the absence of contention, which is the normal case.  To achieve
this performance it sacrifices fairness [*], which is probably unimportant in
practical applications.
    The paper gives an informal argument that the algorithm's performance
in the absence of contention is optimal [!!], and a fairly formal proof
of safety and freedom from deadlock, using a slightly modified Owicki-Gries 
method.  The proofs are extremely clear, and use very little notation."

[All typo's in the above are mine!]

[* The body of the report notes that there is a variation of the algorithm
   that is starvation free, at the cost of one extra memory reference in
   the absence of contention.]

In case you want to rush out and buy a copy, the address for DEC SRC is
given as 

    Digital Systems Research Center
    130 Lytton Avenue
    Palo Alto, California 94301


-- Steve



More information about the Comp.lang.c mailing list