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, 23.06.2019 01:00
Petrică, tânăr licean în clasa a ix-a, a primit în dar de la părinţii săi un cont bancar pentru micile sale cheltuieli curente. el este pasionat de internet banking şi îşi verifică cu grijă toate tranzacţiile efectuate. pentru creşterea securităţii tranzacţiilor online, banca îi furnizează lui petrică un număr pe care el va trebui să îl modifice, obţinând un număr tan – număr de autentificare a tranzacţiei (transaction authentication number). regula de obţinere a numărului tan este următoarea: se formează cel mai mic număr par din toate cifrele numărului furnizat de bancă. cerinţă cunoscând numărul n furnizat de bancă, să se determine numărul tan obţinut de petrică. date de intrare fişierul tan.in conţine pe prima linie numărul natural n cu semnificaţia din enunţ. date de ieşire fişierul de ieşire tan.out va conţine o singură linie pe care va fi scris numărul tan cerut. restricţii • 0 < n < 18*1018 • n are cel puţin o cifră pară • numărul tan obţinut nu poate conţine zerouri nesemnificative
Answers: 2
question
Computers and Technology, 23.06.2019 06:00
Respond to the following in three to five sentences. select the workplace skill, habit, or attitude described in this chapter that you believe is most important for being a successful employee.
Answers: 1
question
Computers and Technology, 23.06.2019 15:00
Based on the current economic situation do you expect the employment demand for graduating engineers to increase or decrease? explain the basis for your answer. with a significant economic recovery, what do you think will happen to future enrollments in graduating engineering programs?
Answers: 1
question
Computers and Technology, 24.06.2019 09:50
Create a string list. 2. use console.readline() to collect values of firstname, lastname, street, city, state, zip, save them to list. 3. write a simple linq statement, call method uppercasewords() to change first letter to uppercase. 4. create a foreach statment to display the information. public static string uppercasewords(string value) { char[] array = value.tochararray(); if (array.length > = 1) { if (char.islower(array[0])) { array[0] = char.toupper(array[0]); } } for (int i = 1; i < array.length; i++) { if (array[i - 1] == ' ') { if (char.islower(array[i])) { array[i] = char.toupper(array[i]); } } } return new string(array);
Answers: 3
You know the right answer?
Do {
while (true) {
flag[i] = want in; j = turn;
while (j != i) {
if (fla...
Questions
question
Mathematics, 04.02.2021 06:40
question
Chemistry, 04.02.2021 06:40
question
Mathematics, 04.02.2021 06:40
Questions on the website: 13722362