Synchronization in Distributed Systems Workbench
Ricart and Agrawala's Algorithm


Ricart and Agrawala's Algorithm solves the synchronization problem in distributed systems. This algorithm insures that only one process will be allowed in a critical region at a time. It works by a using a system of messages and acknowledgements. The sending of a message is assumed to be reliable; that is, every message is acknowledged.

The algorithm works as follows:

When a process wants to enter a critical region, it builds a message containing the name of the critical region it wants to enter, its process number and the current time. It then sends the message to all the other processes including itself. When a process receives a request message from another process, the action it takes depends on its state with respect to the critical region named in the message. There are three possible states: After sending out requests asking permission to enter a critical region, a process sits back and waits until everyone else has given permission. As soon as all the permissions are in, it may enter the critical region. When it exits the critical region, it sends OK messages to all processes on its queue and deletes them all from the queue.

This workbench displays a distributed system with four nodes, each node having a request queue and an acknowledge queue. The request queue displays the queued requests along with the timestamps. The status of each node is displayed at the top of the node. Sending a request is animated by using colored balls and sending acknowledgements by using colored rectangles. In the interactive mode, 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