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
- Rule to send B(DW) –
- Suppose Process P with weight W is sending B(DW) to process Q
- Split the weight of the process P into W1 and W2.
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 + 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 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 + 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.
- Operating System | Deadlock detection algorithm
- Chandy-Misra-Haas's Distributed Deadlock Detection Algorithm
- Deadlock Detection And Recovery
- Deadlock detection in Distributed systems
- Hierarchical Deadlock Detection in Distributed System
- Program for Banker's Algorithm | Set 1 (Safety Algorithm)
- Techniques used in centralized approach of deadlock detection in distributed systems
- LRU Approximation (Second Chance Algorithm)
- Raymond's tree based algorithm
- Operating System | Banker's Algorithm
- Operating System | Dekker's algorithm
- Operating System | Bakery Algorithm
- Algorithm for implementing Distributed Shared Memory
- Program for Optimal Page Replacement Algorithm
- Program for SSTF disk scheduling algorithm
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.