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 n – 1 turns, where n 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.