Introduction To Bakery Algorithm
Introduction To Bakery Algorithm
______________________________________________
• Critical Section
• Hardware Requirements for Bakery Algorithm
• Software Requirements for Bakery Algorithm
• Introduction to Bakery Algorithm
• Bakery Algorithm Notations
• Bakery Algorithm Data Structures
Critical Section
Do
{
Entry section
Critical section
Exit section
Remainder section
}
While(true)
Critical Section Solution Critriea
__________________________________________
In the above diagram we can see that there are two processes p1
and p2. the process p2 will go to the critical section because it has
loweset ticket number
Bakery Algorithm
_________________________________________
In the above diagram we can see that there are two processes p1 and
p2 the processs p1&p2 have same ticket number. Then process ID
will be checked. P1 process has lowest ID and will go to critical
section First.
Bakery Algorithm
_____________________________________
Data structures
• Boolean choosing[n];
• Int number[n]
• These data structures are initialized to false and 0, respectively
Bakery Algorithm
_________________________________________
Structure of
do {
choosing[i] =true;
number[i] = max(number[0],number[1],……, number[n-1])
+ 1;
choosing[i] = false;
Bakery Algorithm
_________________________________________
• Solution: