You are on page 1of 63

p  p

  
  
 
   

M. Maekawa
University of Tokyo
The Problem of Mutual Exclusion

M Exclusive access to a shared resource is sometimes


essential for consistency.
M The problem of mutual exclusion involves granting
exclusive access to shared resources whenever it is
desired by a requestor.
Previous Work

M Ricart and Agrawala


O(N) messages.
Each node communicates with every other node.
M Thomas
Majority voting, still O(N) messages
M Gifford and Skeen
Majority voting with a non-uniform distribution of
votes; Centralized
6ntroduction

M Maekawa¶s algorithm uses


c*Sqrt*(N) messages to obtain
Mutual Exclusion.
M c is a constant between 3 and 5
M Symmetric
M Fully parallel operation
Network assumptions

M Error-free
M F6FO channels
[Messages between two nodes are
delivered in the order sent]
jecentralization

M Two criteria for decentralized Mutual


Exclusion
Equal Responsibility: Each node in the network
bears an equal amount of responsibility to
control Mutual Exclusion.
Equal Work: Each node must perform an equal
amount of work to obtain Mutual Exclusion.
6ntuition behind Voting Sets

M Any pair of mutual exclusion requests must be arbitrated and


one of the requesting nodes may be given access.
M The system comprises entirely of identical nodes which must
share the responsibility of mutual exclusion [jecentralization]
M Thus, any pair of two requests must reach a certain common
node.
M This implies that the voting sets of any two nodes i and j,
given by Si and Sj, must have a non-empty intersection.
Voting Set Rules
Voting Set Rules

Every pair of Voting Sets should


have at least one shared node.

Each nodes Voting Set should contain


the node itself.
Voting Set Rule jetails

All Voting Sets should be of the


same size. This ensures that each
node does an equal amount of
work for obtaining mutual
exclusion.

Each node should appear


a constant number of
times in all the Voting
Sets. This ensures that
each node is equally
responsible for mutual
exclusion.
Optimal Voting Set Size
' The general idea is to represent the maximum number of
Voting Sets [The size of the set of Voting Sets], in terms of j, K
guided by the established set of rules. This evaluates to:
(j-1)K + 1
' This should be equal to the number of nodes, N, since we do
not want fewer or more voting sets.
' j is the degree of duplication of nodes and KN is the number of
members such that N = KN/j. Thus j=K.
 ·    a
  ÷
· ÷a
More Math
The problem of finding a set of Si¶s which satisfy all rules exactly
is equivalent to finding a finite projective plane of N points.
The finite projective plane result implies that the set of Si¶s will
comply with all the rules 6FF (K-1) is a power of a prime.
For other cases some of the rules can be relaxed.

6n general:

· ÷
Algorithm 6ntuition
M 6f node i can lock all members of its Voting Set Si, then no
other node can capture all its members since the intersection
of its Voting Set with that of i¶s will have at least one node.
M 6f a node fails to capture all its members, it waits till all of
them are freed to lock them.
M To prevent deadlocks, nodes get a priority based on the
timestamp of their request.
Messages
M REQUEST
The message sent by a node to request mutual exclusion
REQUEST messages are time-stamped and earlier ones get higher priority.
M 6NQURE
The 6NQU6RE message is sent to a node i that has requested a node j if j
receives another request that predates that of i.
The purpose of the 6NQU6RE message is to query node j if it can indeed lock
all its members. 6t is only sent once.
M REL6NQU6SH
A reply to 6NQU6RE if the originating node cannot get all it members.
M RELEASE
The message sent by a node after it has completed it critical section
M LOCKEj
The message sent from a member node to a requesting node if it is not
currently locked by another request.
M FA6LEj
The message sent from a member node to a requestor when it is currently
locked by a higher priority request.
Example (1)
Example (2)
Example (3)
Example (4)
Example (5)
Proof of Mutual Exclusion

M Paper contains a proof.


M Essentially as long as the network
assumptions hold and the algorithm
observes it specification, mutual
exclusion is guaranteed.
jeadlocks
jeadlocks are eliminated in
Maekawa¶s algorithm by
attacking the circular wait
condition

For any cycle, there must be


one node in the cycle whose
REQUEST timestamp is
preceded by both of its adjacent
nodes in the circular wait. The
removal of such a node breaks
the circular wait condition for
deadlocks to occur.
Starvation
M Starvation is a state of no progress.
M For a node i in Maekawas algorithm, starvation would occur if
i¶s REQUEST are continuously blocked by preceding REQUEST
messages at various members of Si.
M This is however impossible because there can be at most (K-1)
preceding outstanding requests for any request by a node and
therefore, in finite time, i¶s request will be accomodated.
Message Traffic ± Light jemand
M Contention is rare
M For an instance of mutual exclusion
(K-1) REQUEST messages
(K-1) LOCKEj messages
(K-1) RELEASE messages
Message Traffic ± Heavy jemand
M At most (K-1) messages for each of {REQUEST,
6NQU6RE, FA6LEj, RELEASEj, REL6NQU6SH}
M Thus, a maximum of 5*(K-1) messages.
Node Failure
M Algorithm assumes that failures can be detected by other
nodes and failed nodes are removed from the system.
M A simple approach to deal with failure is to allow another node
to take over the responsibilities of the failed node.
Comparison
Variations

M A simplified version of the algorithm can achieve mutual


exclusion in 2 Sqrt(N) messages if greater delays are tolerated.
M This entails sending REQUEST messages one-by-one to Voting
Set members only if all REQUESTs so far have been LOCKEj,
in cyclic order.
M An additional Sqrt(N) messages are required to release the
mutual exclusion.
Critique
+ Message complexity is O(Sqrt(N)) which is better that
Ricart and Agrawala for a decentralized protocol.
+ Symmetry: The responsibility on nodes to control mutual
exclusion and the work needed to attain mutual
exclusion are balanced.
-- joes not address the problems associated with node
churn specifically. jynamic adjustments made to Voting
Sets with large churn will lead to rapid degeneration
from the ideal Maekawa setup depending on policies for
removal and addition of nodes.
p      

 


   

  
p 
  p 
   p 
       
      

 

M i      ! "#  
 $ "   %  &% 
  
M p      "#' "  
 (  "    (  
M  )  " "   (    
"    "  # "     
 #  
M i       #    
  )  


! "# 

M p)    #      
% *    
  
M           
 " #     &
  % # #  "  %'
   
6


M  V   % 
    "  ""   $
M 6 )   "  #% 
   " & )  
    
M   " #   &
   %'    & "
 
  
 
M   ""    % "

    
M  " &      
 "  "#  
 #  $
 

M   % # &#  
   # " 
M  #    " #  "
 #  
M    "   
   #   +
  # " " 
 
!
$
  
  %&% '(
 
! p %

M         "

M    # "
M      $ "   
      '"  
      
)  



M p  &p,$p
'

Replica
2
1
Critical 3 1
Replica
Section
Client 2 .
.
.
1
Replica
2
)  


!  

M m # "  % 
   %'  #%   
 "    #   
  " " 
M ,#"#    (   %
    # &%  -&  ++  
.+/0

-.
M  #' (    12.
M   &  "& 
&% # %  3
)  


! 
 
)  


!


 
  *
 
M    %'  
#%     " &) 
% "   "   
m#  2   # "    %
    
m#  !"#   
6 p 



M p""##  "#
%  4
M m#  2 "#  )  
 &%    "   
 %&     
M m#   "#      
   
 
6 p 


! p 
6 p 


! +6, -%

M         * 
   "% #  "
 
M 56i iipi6ii
M 7  56i ) &  
      
# "     % "
 % 
M      %  
6 p 


! .    /
 &
M p&   "
 + "#     
M           
 %#  & "% 
  &%  
M   "   #    
"    
6 p 


! .    &
 &
M 6)   ""& 4 
##    % 

  
 " ("%    "   
   &      
 %  8m69
m  4    )  
  "  
%  % ""    
6 p 


! p 
M V       )  
'#     &
::    "
M V
  "%  ## &
         # #
     
M :     " 
 
%  * /
 0
M         " "
" " "  # "#"
M p      &  
)  #" m  
"  #   &% ;   ) 

M p0 %
&"2. 
"  %      #
 ")  "   "+
""    ) 
%  * &
 0
%  * 0
 0


 

M %"     %'  
#%    "  
  " "   p,$p
'
%  
M   "  
#%    "   
 ##   " 
  #  "#  
M m" 
   
# " 4
  
     p
 
M 56i   %  # 
   *    
 # #  
 
  
M $%  % <#= 
(    ">
M i   #   
 >
ã 6
M p  *    #
  56i  
M i( "      
"     "   "
 "     "



M m"  &    " 

   "  # "   


(     " $
M  *"     ")  
   " %  "   
M  %    
  "
   
M m " #      
 + # "  
¢
 
    

 
p 

 ?
" @ "

      


@ *  6     

  "#%"  4%# 


6


M j

       
)  &%%  
M 6  "%)   
p     (  " )   
 "  
j
 

 

M :   )  m  
   
 
M   # "   "  
#  

   (    ""   &  


)   
M A "   

p%  p
   11 ,

M %""#%  ")  
  " #  (  
" 
   
M m" 
" #  (  
 
"  ""# "
M m"   ")  

 B ÷
   
   2


  
' jynamic: Processors are joining and leaving the system
arbitrarily.
' The grid is substituted with a continuous unit square.
' This square can be decomposed into Voronoi cells where
each processor is associated with a cell.
' Adding a processor involves computing a new boundary.
(      
 

A quorum is the
union of the
vertices that
form right-left
and top-bottom
paths in the
jelaunay
graph.
Thank you

You might also like