subject

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?

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 01:00
Ap practice - performance task response the ap create performance task asks you to write about an abstraction that you developed and wrote into your code. most of the time that means identifying a function or procedure you wrote to "manage complexity" in your program. here is the actual prompt from the create performance task: 2d. capture and paste a program code segment that contains an abstraction you developed individually on your own (marked with a rectangle). this abstraction must integrate mathematical and logical concepts. explain how your abstraction manage the complexity of your program. (must not exceed 200 words) below is a segment of code from an "under the sea" program with a rectangle drawn around a portion of the code identifying an abstraction. imagine that you wrote this and are composing an ap response about how this abstraction manages complexity. (note: ignore the requirement that the abstraction integrate "mathematical and logical concepts" for this practice response. just write about managing complexity). explain how the abstraction marked with the rectangle in the code above manage complexity of this program. write your response here submit
Answers: 2
question
Computers and Technology, 23.06.2019 11:00
What is the name of the sound effect that danny hears
Answers: 1
question
Computers and Technology, 23.06.2019 15:00
In the blank libreoffice writer document, to start the process of entering a date field into a letter, click on the insert menu. edit menu. file menu. fields menu.
Answers: 3
question
Computers and Technology, 23.06.2019 17:00
Companies that implement and apply an information system effectively can create
Answers: 1
You know the right answer?
Do {
while (true) {
flag[i] = want in; j = turn;
while (j != i) {
if (fla...
Questions
question
Chemistry, 04.02.2020 10:49
Questions on the website: 13722360