Synchronization in Distributed Systems Workbench
Token Ring Algorithm



Token Ring algorithm achieves mutual exclusion in a distributed system by creating a bus network of processes. A logical ring is constructed with these processes and each process is assigned a position in the ring. Each process knows who is next in line after itself.

The algorithm works as follows:

When the ring is initialized, process 0 is given a token. The token circulates around the ring. When a process acquires the token from its neighbor, it checks to see if it is attempting to enter a critical region. If so, the process enters the region, does all the work it needs to, and leaves the region. After it has exited, it passes the token to the next process in the ring. It is not allowed to enter the critical region again using the same token. If a process is handed the token by its neighbor and is not interested in entering a critical region, it just passes the token along to the next process.

This workbench displays a distributed system with six nodes, each node having a status flag. If the flag is green it means the node is ready to accept the request. The yellow flag means a request to enter a critical region is generated and the node is waiting for token. If the flag is red, the node is in a critical region. In the interactive mode of this workbench, you can generate requests for nodes by pushing corresponding Node buttons at the bottom. You can also execute the workbench in the continuous mode by pushing the Animate button. The animation speed can be varied using Speed scroll bar.

Workbench