Question

In: Computer Science

software approach to mutual exclusion

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.

 

Solutions

Expert Solution

This is a program that provides mutual exclusion for access to a critical resource among N processes, which can only use the resource one at a time. The unique feature of this algorithm is that a process need wait no more then N - 1 turns for access. The values of control[i] for process i are interpreted as follows: 0 = outside the critical section and not seeking entry; 1 = wants to access critical section; 2 = has claimed precedence for entering the critical section. The value of k reflects whose turn it is to enter the critical section. 

 

 

Entry algorithm: Process i expresses the intention to enter the critical section by setting control[i] = 1. If no other process between k and i (in circular order) has expressed a similar intention then process i claims its precedence for entering the critical section by setting control[i] = 2. If i is the only process to have made a claim, it enters the critical section by setting k = 1; if there is contention, i restarts the entry algorithm. 

 

 

Exit algorithm: Process i examines the array control in circular fashion beginning with entry i + 1. If process i finds a process with a nonzero control entry, then k is set to the identifier of that process. 

 

 

The original paper makes the following observations: First observe that no two processes can be simultaneously processing between their statements L3 and L6. Secondly, observe that the system cannot be blocked; for if none of the processes contending for access to its critical section has yet passed its statement L3, then after a point, the value of k will be constant, and the first contending process in the cyclic ordering (k, k + 1, ..., N, 1, ..., k – 1) will meet no resistance. Finally, observe that no single process can be blocked. Before any process having executed its critical section can exit the area protected from simultaneous processing, it must designate as its unique successor the first contending process in the cyclic ordering, assuring the choice of any individual contending process within N – 1 turns. 


it must designate as its unique successor the first contending process in the cyclic ordering, assuring the choice of any individual contending process within N – 1 turns. 

Related Solutions

There are three ways to provide mutual exclusion in a system. Explain how mutual exclusion can...
There are three ways to provide mutual exclusion in a system. Explain how mutual exclusion can be guaranteed using hardware approach and software approach.
mutual exclusion is Lamport’s bakery
A software approach to mutual exclusion is Lamport’s bakery algorithm [LAMP74], so called because it is based on the practice in bakeries and other shops in which every customer receives a numbered ticket on arrival, allowing each to be served in turn. The algorithm is as follows:boolean choosing[n];int number[n];while (true) {choosing[i] = true;number[i] = 1 + getmax(number[], n);choosing[i] = false;for (int j = 0; j < n; j++){while (choosing[j]) { };while ((number[j] != 0) && (number[j],j) < (number[i],i)) { };}/*...
Consider the four distributed mutual exclusion algorithms Permission Based ---#1: Centralized Mutual Exclusion ---#2: Decentralized Mutex...
Consider the four distributed mutual exclusion algorithms Permission Based ---#1: Centralized Mutual Exclusion ---#2: Decentralized Mutex Algorithm ---#3: Distributed Mutual Exclusion #4: A Token Ring Algorithm Discuss their relative fault tolerance – basically the effect of processor crashes on the performance of the algorithm. You don’t have to come up with a 1-2-3-4 ordering.
Write a program to simulate the Distributed Mutual Exclusion in ‘C’.
Write a program to simulate the Distributed Mutual Exclusion in ‘C’.
What are the disadvantages of disabling interrupts as a strategy for achieving mutual exclusion?
What are the disadvantages of disabling interrupts as a strategy for achieving mutual exclusion?
Please prove the correctness of the following extended compare_and_wait program in terms of mutual exclusion, progress,...
Please prove the correctness of the following extended compare_and_wait program in terms of mutual exclusion, progress, and bounded waiting. please show it in the in terms of mutual exclusion, progress, and bounded waiting.aspects thankyou while (true) { waiting[i] = true; key = 1; while (waiting[i] && key == 1) key = compare_and_swap(&lock,0,1); waiting[i] = false;    // critical section j = (i + 1) % n; while ((j != i) && !waiting[j]) j = (j + 1) % n; if...
Modify the included program to implement the strict alternation solution to achieve mutual exclusion. It does...
Modify the included program to implement the strict alternation solution to achieve mutual exclusion. It does not matter whether Thread 0 goes first or Thread 1, but it is important that the thread strictly alternate. PROGRAM: #include <iostream> #include <pthread.h> #include <stdlib.h> int count; int turn = 0; // Shared variable used to implement strict alternation void* myFunction(void* arg) {    int actual_arg = *((int*) arg);       for(unsigned int i = 0; i < 10; ++i) {    //...
Question Four Explain Peterson’s solution for critical-section problem and show that mutual exclusion is preserved with...
Question Four Explain Peterson’s solution for critical-section problem and show that mutual exclusion is preserved with Peterson’s solution. (Assume there are only two processes P0 and P1)
A. Discussion Thread: "Free Software" Consider the "Free Software" approach advocated by Richard Stallman and others...
A. Discussion Thread: "Free Software" Consider the "Free Software" approach advocated by Richard Stallman and others (see Section 4.6 of Gift of Fire). Do you think this approach should be adopted? How do you think the Free Software approach would affect the quantity and quality of software that would be produced? Would the current funding methods for free software be sufficient? Are there other modifications of the current system of software licensing that should be considered? Which arguments for free...
When a special machine instruction is used to provide mutual exclusion in the fashion of Figure 5.2, there is no control over how
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT