Bakery algorithm

Now consider a version of the without the variable choosing.

Then we have

int number[n];

while (true)

number[i] = 1 + getmax(number[], n);

for (int j = 0; j < n;=””>

while ((number[j] != 0) && (number[j],j) < (number[i],i))=”” =””>

/* critical section */;

number [i] = 0;

/* remainder */;

Does this version violate mutual exclusion? Explain why or why not.

2. Consider the first instance of the statement bolt = 0 in Figure 5.2b.

a. Achieve the same result using the exchange instruction.

b. Which method is preferable?

3.When a special machine instruction is used to provide mutual exclusion in the

fashion of Figure 5.2, there is no control over how long a process must wait

before being granted access to its critical section. Devise an algorithm that uses

the compare&swap instruction but that guarantees that any process waiting to

enter its critical section will do so within – 1 turns, where is the number of

processes that may require access to the critical section and a “turn” is an event

consisting of one process leaving the critical section and another process being

granted access.

WhatsApp
Hello! Need help with your assignments?

For faster services, inquiry about  new assignments submission or  follow ups on your assignments please text us/call us on +1 (251) 265-5102

🛡️ Worried About Plagiarism? Run a Free Turnitin Check Today!
Get peace of mind with a 100% AI-Free Report and expert editing assistance.

X