Computers and Technology

Do {
while (true) {
flag[i] = want in; j = turn;
while (j != i) {
if (flag[j] != idle) {
j = turn;
else
j = (j + 1) % n;
}
flag[i] = in cs;
j = 0;
while ( (j < n) && (j == i || flag[j] != in cs))
j++;
if ( (j >= n) && (turn == i || flag[turn] == idle))
break;
}
/* critical section */
j = (turn + 1) % n;
while (flag[j] == idle)
j = (j + 1) % n;
turn = j;
flag[i] = idle;
/* remainder section */
} while (true) ;

Think about this general question:
Why does Eisenberg-McGuire as a software solution to the n-process critical sector problem require 2 levels of scanning, and 2 levels of activation (WANT_IN, IN_CS)?
Hint: this is a software solution and does not imply the use of an atomic test-and-set or compare_and_swap. Answer each part of the specific question 1 that applies (a and b, or a and c).
The first while loop in Eisenberg-McGuire checks all processes' flag[] from the one holding "turn" to ourselves, stopping at each one that is not idle until it is idle, then proceeding.

(a) Is it possible for two or more processes to go through this first loop and find all processes but itself idle? Explain either way, not just yes or no.
(b) If this is not possible, why docs each process finding all others idle need the second loop, to tentatively claim the CS, that is set its flag to IN_CS and then scan to see if any other process has also asserted IN_CS? Why wouldn't the process finding all but itself idle automatically have turn set to it by the process exiting the CS? Why not just enter the CS if all other processes are idle?
(c) If it is possible for 2 or more processes to find all but themselves idle, would they have to wait for "turn" or could they try to enter the CS at the same time? Explain your conclusion. Hint: must a process waiting for the CS have to get the "turn" or is there another condition in which it can enter?

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 10:30, Twitches
This first part of the film shows the early history of motion pictures. how accurate do you think the portrayal of the early motion picture industry is? why? is historical accuracy important in films and theatre productions? explain. in the scene where don is going to the party (starting at time code 14: 51), we see a street scene as he first rides with cosmo and then with kathy. what aspects did the filmmaker include to make the scene look and feel like don, cosmo, and kathy are riding in a car on a street? think about elements such as scenery, sound, props, lighting, and so on. a "talkie" picture is shown starting around time code 21: 15. how does the audience in the film react to the "talkie"? what influence do audiences have on film and theatre performances? how do film and theatre actors influence audiences? in the musical scene with cosmo (starting at time code 27: 00), how does the actor use props? what is the result? do you think the use of props effectively fulfilled the artistic vision for this musical number? why or why not?
Answers: 1
image
Computers and Technology, 22.06.2019 14:00, GGerardi7552
What are procedures that keep a data base current
Answers: 1
image
Computers and Technology, 22.06.2019 18:30, Akkenson17871
The "instance" relationship shows that something is an object of a
Answers: 1
image
Computers and Technology, 24.06.2019 08:20, brinks7994
Which type of entity describes a fundamental business aspect of a database? a. linking b. lookup c. domain d. weak
Answers: 3
Do you know the correct answer?
Do {
while (true) {
flag[i] = want in; j = turn;
while (j != i) {
if (fla...

Questions in other subjects: