Question: Bakery algorithm as defined in the textbook as below. 1 class Bakery implements Lock { 2 boolean[] flag; 3 Label[] label; 4 public Bakery (int

Bakery algorithm as defined in the textbook as below.

1 class Bakery implements Lock { 2 boolean[] flag; 3 Label[] label; 4 public Bakery (int n) { 5 flag = new boolean[n]; 6 label = new Label[n]; 7 for (int i = 0; i < n; i++) { 8 flag[i] = false; label[i] = 0; 9 } 10 } 11 public void lock() { 12 int i = ThreadID.get(); 13 flag[i] = true; 14 label[i] = max(label[0], ...,label[n-1]) + 1; 15 while ((k != i)(flag[k] && (label[k],k) << (label[i],i))) {}; 16 } 17 public void unlock() { 18 flag[ThreadID.get()] = false; 19 } 20 }

Suppose we redefine in the Bakery algorithm as defined in the textbook chapter 2 as below.

(label [i],i) << (label[j],j) If and only if label [i] < label [j]

What would be the impact on the algorithm? Which of the lemmas 2.6.1, 2.6.2, and 2.6.3(they are defined in the textbook) will still be correct? (Or more precisely, which of them wnill continue to be lemmas?) If any of them continues to be a lemma, clearly justify your answer. For ones that are not lemmas anymore, explain with a counterexample.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!