[ Home | Class Roster | Syllabus | Status | Glossary | Search | Course Notes]
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:
Also high/low load and best/average/worst case performance
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
How many messages?
What about failures? before, during and after
What about load (CPU and network)?
Is distributed better?
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.
Is this fair?
what is max wait?
What if token is lost?
What is machine crashes?
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.
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:
Ri: request set
Ii: inform set
STi: status set
CSSTATi: this site's knowledge of the status of the CS
Queue of Requests message ordered by timestamp
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:
Site wishing to enter CS sends timestamped REQUEST messages to all sites in its request set.
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 CSExecuting the critical section
after receiving a GRANT message for all sites in its request set.
Releasing the critical section
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 CSRepeat 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.