Huang's Termination detection algorithm - GeeksforGeeks

30 Apr, 2019
Huang’s algorithm is an algorithm for detecting termination in a distributed system. The algorithm was proposed by Shing-Tsaan Huang in 1989 in the Journal of Computers.
In a distributed system, a process is either in an active state or in an idle state at any given point of time. Termination occurs when all of the processes becomes idle and there are no any in transit(on its way to be delivered) computational message.
Assumptions of the algorithm:
One of the co-operating processes which monitors the computation is called the controlling agent.
The initial weight of controlling agent is 1
All other processes are initially idle and have weight 0.
The computation starts when the controlling agent send a computation message to one of the processes.
The process become active on receiving a computation message.
Computation message can be sent only by controlling agent or an active process.
Control message is sent to controlling agent by an active process when they are becoming idle.
The algorithm assigns a weight W (such that 0 < W < 1 ) to every active process and every in transit message.
Notations used in the algorithm:
B(DW): Computation message with weight DW
C(DW): Control message with weight DW
Algorithm:
Rule to send B(DW) –Suppose Process P with weight W is sending B(DW) to process QSplit the weight of the process P into W1 and W2.Such thatW = W1 + W2  and W1 > 0, W2 > 0Set weight of the process P as W1 ( i.e W = W1 )Send B(W2) to process Q, here DW = W2.Note: Only the Controlling agent or any active process can send Computation message.
Suppose Process P with weight W is sending B(DW) to process Q
Split the weight of the process P into W1 and W2.Such thatW = W1 + W2  and W1 > 0, W2 > 0
W = W1 + W2  and W1 > 0, W2 > 0
Set weight of the process P as W1 ( i.e W = W1 )
Send B(W2) to process Q, here DW = W2.
Note: Only the Controlling agent or any active process can send Computation message.
On receiving B(DW) by process Q –Add the weight DW to the weight of process Q i.e for process Q, W = W + DWIf process Q was idle, it will become active on receiving B(DW).
Add the weight DW to the weight of process Q i.e for process Q, W = W + DW
If process Q was idle, it will become active on receiving B(DW).
Rule to send C(DW) –Any active process having weight W can become idle by sending C(W) to controlling agentSend a control message C(W) to the controlling agent. Here DW = W.Set weight of the process as 0 i.e W = 0. (After this process will become idle.)
Any active process having weight W can become idle by sending C(W) to controlling agent
Send a control message C(W) to the controlling agent. Here DW = W.
Set weight of the process as 0 i.e W = 0. (After this process will become idle.)
On receiving C(DW) by controlling agent –Add the weight received through control message to the weight of controlling agent i.e W = W + DWAfter adding, if the weight of controlling agent becomes 1 then it can be conclude that the computation has terminated.
Add the weight received through control message to the weight of controlling agent i.e W = W + DW
After adding, if the weight of controlling agent becomes 1 then it can be conclude that the computation has terminated.
Advantages of Huang’s Algorithm:
The algorithm detects every true termination in finite time.
Limitations of Huang’s Algorithm:
The algorithm is unable to detect computation termination if a message is lost in transit.
It also does not work when a process fails while in an active state.
Distributed System
Operating Systems
Operating Systems
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
States of a Process in Operating Systems
Introduction of Process Management
Process Table and Process Control Block (PCB)
Memory Management in Operating System
Process Schedulers in Operating System
Difference between Internal and External fragmentation
Introduction of System Call
Dining Philosopher Problem Using Semaphores
Logical and Physical Address in Operating System
Program for Least Recently Used (LRU) Page Replacement algorithm