Eisenberg-McGuire Algorithm Shared structures enum pstate {idle, want_in, in_cs}
ID: 3583384 • Letter: E
Question
Eisenberg-McGuire Algorithm Shared structures enum pstate {idle, want_in, in_cs} pstate flag[n] int turn;/*where turn can be initialized to any value between 0 and n-1*/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) && (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)? 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' flagll from the one holding "turn" to ourselves, stopping at each one that is not idle until it is idle, then proceeding 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. The answer is no but why?Explanation / Answer
After first while
/* announce that we need the resource */
From that clearly it allows only process.otherwise deadlock occurred.
Answer is no
CONCEPT:
The turn variable and status flags are used as in Dekker's algorithm for the 2-process case.
three possible values for flag:
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.