Class AsyncLCR
source code
distalgs.Algorithm --+
|
distalgs.Asynchronous_Algorithm --+
|
AsyncLCR
The LeLann, Chang and Roberts algorithm for Leader Election in an
Asynchronous Ring Network
Each Process sends its identifier around the ring. When a Process
receives incoming identifier(s), it compares their largest to its own. If
that incoming identifier is greater than its own, it keeps passing that
identifier; if it is less than its own, it discards all the incoming
identifiers; if it is equal to its own, the Process declares itself the
leader. When a Process has declared itself Leader, it sends a Leader
Declaration message around the ring, and halts As it goes around the
ring, each other Process outputs 'non-leader', and halts.
Requires:
-
Every process knows state['n'], the size of the network
Effects:
-
Every process has state['status'] is 'leader' or 'non-leader'.
-
Exactly one process has state['status'] is 'leader'
|
msgs_i(self,
p,
verbose=False)
Determines what messages a Process, p, will send. |
source code
|
|
|
trans_i(self,
p,
verbose=False)
Determines what state transition a Process, p, will perform, having
received messages, msgs |
source code
|
|
|
cleanup_i(self,
p)
Determines what final state transition a Process, p, will perform,
after the algorithm terminates. |
source code
|
|
Inherited from distalgs.Asynchronous_Algorithm :
run ,
run_process
Inherited from distalgs.Algorithm :
__call__ ,
__init__ ,
cleanup ,
count_msg ,
delete ,
get ,
halt ,
halt_i ,
has ,
increment ,
output ,
print_algorithm_terminated ,
set
|
Determines what state transition a Process, p, will perform, having
received messages, msgs
- Overrides:
distalgs.Algorithm.trans_i
- (inherited documentation)
|
Determines what final state transition a Process, p, will perform,
after the algorithm terminates.
- Overrides:
distalgs.Algorithm.cleanup_i
- (inherited documentation)
|