Fall 2000: CS 771/871 Operating Systems

[ Home | Class Roster | Syllabus | Status | Glossary | Search | Course Notes]


 

Lecture 6 - Distributed Mutual Exclusion

Clock Based Consistent Cache

 


Mutual Exclusion

Only one process can access a shared resource at a time (e.g. printer, file, data record).

Can be implemented as critical region.
Question: what is difference between critical section and resource lock?

Desirable Characteristics of Mutual Exclusion algorithm:


Measuring performance

Also high/low load and best/average/worst case performance


Centralized Mutual Exclusion Algorithm

Centralized algorithm:

Centralized is not always inappropriate.
A single shared resource is inherently centralized - co-locate coordinator.

System Throughput is 1/(2T+E) where T is average message delay and E is the average CS time


Distributed Mutual Exclusion Algorithm (Ricart and Agrawala)

How many messages?
What about failures? before, during and after
What about load (CPU and network)?
Is distributed better?

Correctness of Ricart-Agrawala Algorithm

Proof by contradiction: Assume that two sites Si and Sj are executing the critical section (CS) concurrently and that Si's request has a smaller timestamp than Sj (timestamps are totally ordered). Si must have receieved Sj's request after it made its own request. But Sj can only be in the CS if Si returned a reply to it before Si finishes the CS. But this is not possible since Sj has lower priority than Si's request.

 


Distributed Mutual Exclusion Algorithm (Token Ring)

Is this fair?
what is max wait?
What if token is lost?
What is machine crashes?


Comparison of Mutual Exclusion Algorithms

 

algorithm Messages/critical region Delay to enter Problems
Centralized 3 2 coordinator crash
Distributed 2(n-1) 2(n-1) process crash
Token Ring 1 to unbounded 0 to n-1 lost token or process crash

 Can also measure throughput, utilization, etc.


Generalized Non-Token-Based Algorithm

Sanders realized that what each process knows about the global state can be used to generalize Non-token based algorithms.

The knowledge of the global state for each site Si is kept in an information structure containing:

If Si is in Ij then Sj is in STi

Theorem 6.4: If for all i, Si is in Ii, then to guarantee mutual exclusion

G1: Forall i, Ii is a subset of Ri

G2: forall i,j :: The UNION of Ii and Ij is not empty OR Si is in Rj AND Sj is in Ri)

Algorithm:

Requesting the critical section:

  1. Site wishing to enter CS sends timestamped REQUEST messages to all sites in its request set.

  2. On receipt of a REQUEST message, a site Si does

    • Places request in its queue (ordered by timestamp)

    • If CSSTAT indicates CS is free, send GRANT request to site at top of the queue, removing it.
      If the recipient of a GRANT message is in STi, then CSSTAT is set to indicate that the site is in the CS

Executing the critical section

  1. after receiving a GRANT message for all sites in its request set.

Releasing the critical section

  1. Send RELEASE message to all sites in the inform set.
    Upon receiving a RELEASE message do

    • CSSTAT is set to free

    • If the queue is non-empty, thens a GRANT request to the site on the top
      If the recipient of a GRANT message is in STi, then CSSTAT is set to indicate that the site is in the CS

    • Repeat previous until CSSTAT indicated that a site is in its CS or queue is empty

Ricart-Agrawala algorithm says it does not object to another site entering the CS but does not have the authority by itself in granting permission.

Maekawa's algorithm says all sites in my status set agree that you can enter your CS.

Generalized combines these two. If first predicate of G2 is false for all Si and Si, then it is Ricart-Agrawala. if second predicate is false it is Maekawa.

 

 

 
 

 


Copyright chris wild 1996.
For problems or questions regarding this web contact [Dr. Wild].
Last updated: August 29, 1996.