60 likes | 86 Views
Learn about the Eisenburg-McGuire algorithm for mutual exclusion, its fairness property, implementation details, and potential issues.
E N D
Eisenburg-McGuire algorithm for mutual exclusion • Eisenburg-McGuire algorithm, CACM 1972 • Also appears in a popular OS textbook (Operating System Concepts, Silberschatz & Galvin) • The first mutual exclusion algorithm with good fairness property : n-1 bounded bypass
Eisenburg-McGuire ME Algorithm – Data Structure There are n processes with id i in {0,1,…,n-1} Shared variables: • turn :{0,.....,n-1}, initially arbitrary • flag(i): {idle, want-in, in-cs} for each process i; initially idle Private variable j : integer ; for each process i In general, the contending process with id larger than turn and is closer to turn has higher priority.
Eisenburg-McGuire ME Algorithm – Trying Region 1 repeat 2 flag(i) := want-in 3 j := turn 4 while not(j=i) do 5 if not(flag(j) = idle)) then j := turn 6 else j := j+1 mod n fi 7 od 8 flag(i) := in-cs 9 j := 0 10 while ( j < n) and ( j = i or not(flag( j) = in-cs) ) do j:= j+1 od 11 until ( j >= n) and (turn = i or flag(turn) = idle) 12 turn := i
Eisenburg-McGuire ME Algorithm – Exit Region 13 ***** CS ****** 14 j := i+1 mod n 15 while flag( j) = idle do j := j+1 mod n od 16 turn := j 17 flag(i) := idle • ***** Remainder Region ***** • until false
Question 1: • Is it possible for more than one process to reach line 8 at the same time? Why? Show the details. • Question 2: • Suppose the code of trying region is as follows. • 1 repeat • 8 flag(i) := in-cs • 9 j := 0 • 10 while ( j < n) and ( j = i or not(flag( j) = in-cs) ) do j:= j+1 od • 11 until ( j >= n) • 12 turn := i • What will go wrong with the algorithm? Why? Show the details.
Question 3: • Prove that the original algorithm satisfies progress requirement (that is, there is no deadlock).