- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Raymond’s tree based algorithm
Raymond’s tree-based algorithm is used to protect the distributed systems from the occurrence of sections by the lock method. Distributed systems are networks with numerous numbers of nodes that involves the message flow from one node to another. When the process is locked or in the critical section, then only one thread or process can be allowed inside and other threads will be in the waiting state. As there are many nodes involved in the distributed systems, it can be reduced by spanning trees.
Raymond’s Tree Based Algorithm
The Algorithm follows the method that only the threads with tokens are allowed inside the critical section. Each node of the network can have a maximum of one parent node and which is responsible for generating the tokens
In the tree structure, each node can have only one parent or root node to which all the requests from other nodes are sent to. The parent node follows the First in First out (FIFO) mechanism to respond to the requests from the child nodes, whenever the token is received.
A token is used by this algorithm to guarantee mutual exclusion. In this approach, each site is organized into a directed tree with edges pointing in the direction of the site that is holding the token. If a site has the token, it may access the vital portion. This makes sure that only one site at a time can access the important area while everyone else must wait for the token to be released.
Raymond’s Tree Algorithm Mechanism
The node that enters the critical section is considered that it has a token. Let’s take Node A as the parent node and the child nodes are B, C, and D.
A node enters the critical section based on the request.
When the parent site queue is nil, then it moves the child node to the First In First Out queue and based on the request, the token is assigned
When the parent node is not empty or the queue is full, it pushes the requested child node into the queue.
When any child node with the token, receives another token it will move the token to the child node which in need of tokens.
Properties of Raymond’s Tree based Algorithm
Some of the primary properties of the algorithm are,
It ensures mutual exclusion property by using a token. If a site has the token, it may access the vital portion.
All of the sites are arranged as a directed tree, with the edges facing the site that is holding the token.
There is just one parent for each node, who receives requests and forwards them.
Every time a node encounters a token, it keeps a FIFO queue of requests in place.
Example of the Algorithm
The Algorithm is implemented in the distributed system using the following tree structure,
In the above example site A is the primary node that holds the token. The sites below node A is the sites B and C which are considered child nodes. These sites request that site A enter the critical section. Site C is again divided into two subdivisions as nodes D and E.
Like the above step, node C is the primary node with two sub-nodes as D and E. These nodes send the request to the parent node based on its requirement. As the request raised by nodes B and C is already present, the present request will be set in the queue.
Based on the token received from the primary to secondary nodes, the sites enter the critical section.
Time complexity of the Algorithm
The Critical section of the distributed system provides a time complexity of O(log n). It is compulsory that each node of the process should hold at least O(log n) bits.
Drawback of Raymond’s Algorithm
Starvation − Raymond’s algorithm gives rise to starvation. Starvation is a condition that can occur in a concurrent system when a process or thread is perpetually denied the resources it needs to execute. This can happen when a scheduling algorithm consistently prioritizes other processes or threads over the starving process, causing it to wait indefinitely for resources. Starvation can lead to reduced system performance and can even cause the system to become unresponsive.
Greedy Strategy − Raymond’s algorithm gives rise to starvation. Starvation is a condition that can occur in a concurrent system when a process or thread is perpetually denied the resources it needs to execute. This can happen when a scheduling algorithm consistently prioritizes other processes or threads over the starving process, causing it to wait indefinitely for resources. Starvation can lead to reduced system performance and can even cause the system to become unresponsive.
The Algorithm is used based on the requests sent by the child nodes to the parent node. The procedure is followed by requesting the parent node, executing the nodes according to the queues after the node is released from the critical section and the nodes can be chosen between empty or non-empty ones.
Kickstart Your Career
Get certified by completing the courseGet Started