# Question: Consider the following program which provides a software approach to

Consider the following program which provides a software approach to mutual exclusion:

Integer array control [1: N]; integer k

Where 1 ≤ k ≤ N, and each element of “control” is either 0, 1, Or 2. All elements of “control” are initially zero; the initial valueof k is immaterial.

The program of the ith process (1 ≤ i ≤ N) is

begin integer j;

L0: control [i] := l;

LI: for j:=k step l until N, l step l until k do

begin

if j = i then goto L2;

if control [j] ≠ 0 then goto L1

end;

L2: control [i] := 2;

for j := 1 step 1 until N do

if j ≠ i and control [j] = 2 then goto L0;

L3: if control [k] ≠ 0 and k ≠ i then goto L0;

L4: k := i;

critical section;

L5: for j := k step 1 until N, 1 step 1 until k do

if j ≠ k and control [j] ≠ 0 then

begin

k := j;

goto L6

end;

L6: control [i] := 0;

L7: remainder of cycle;

goto L0;

end

This is referred to as the Eisenberg-McGuire algorithm. Explain its operation and its key features.

Integer array control [1: N]; integer k

Where 1 ≤ k ≤ N, and each element of “control” is either 0, 1, Or 2. All elements of “control” are initially zero; the initial valueof k is immaterial.

The program of the ith process (1 ≤ i ≤ N) is

begin integer j;

L0: control [i] := l;

LI: for j:=k step l until N, l step l until k do

begin

if j = i then goto L2;

if control [j] ≠ 0 then goto L1

end;

L2: control [i] := 2;

for j := 1 step 1 until N do

if j ≠ i and control [j] = 2 then goto L0;

L3: if control [k] ≠ 0 and k ≠ i then goto L0;

L4: k := i;

critical section;

L5: for j := k step 1 until N, 1 step 1 until k do

if j ≠ k and control [j] ≠ 0 then

begin

k := j;

goto L6

end;

L6: control [i] := 0;

L7: remainder of cycle;

goto L0;

end

This is referred to as the Eisenberg-McGuire algorithm. Explain its operation and its key features.

## Answer to relevant Questions

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 ...The following pseudocode is a correct implementation of the producer/consumer problem with a bounded buffer: Labels p1, p2, p3 and c1, c2, c3 refer to the lines of code shown above (p2 and c2 each cover three lines of code). ...Consider the following ways of handling deadlock: (1) Banker’s algorithm, (2) Detect deadlock and kill thread, releasing all resources, (3) Reserve all resources in advance, (4) Restart thread and release all resources ...For Figure, provide a narrative description of each of the six depicted paths, similar to the description of the paths of Figure 6.2 provided in Section 6.1. Evaluate the banker’s algorithm for its usefulness in an OS.Post your question