Skip to content
Related Articles
Open in App
Not now

Related Articles

Huang’s Termination detection algorithm

Improve Article
Save Article
Like Article
  • Last Updated : 30 Apr, 2019
Improve Article
Save Article
Like Article

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.
      Such that

      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.
My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!