subject

Given the following code, where id indicates a process number or ID), launch() indicates concurrent start of the processes passed on its parameters, and N is an integer representing the number of processes that will be launched (i. e. processes that will run on that system).

boolean blocked[N];

for(int i = 0; i < N;i++)
blocked[i] = false.
int turn = 0;
int other;

P(int id)
while(true)
blocked[id] = true;

while(turn != id)
if(id == 0 || id == 2)
other = 1;
else other = 0;

while(blocked[other])
{ turn = other;}
turn = id;

/* <<<< CRITICAL SECTION IS EXECUTED HERE>>>>>> */
blocked[id] = false;

a. Will the above code work (achieves mutual execution, good progress and deadlock-free) if launch is called as: launch(P(0), P(1)). Explain your answer in full details and in terms of each of mutual exclusion, good progress and deadlock-free.
b. Will the above code work (achieves mutual execution, good progress and deadlock-free) if launch is called as: launch(P(0), P(1), P(2)). Explain your answer in full details and in terms of each of mutual exclusion, good progress and deadlock-free.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 09:50
Assume that you have an sorted array of records. assume that the length of the array (n) is known. give two different methods to search for a specific value in this array. you can use english or pseudo-code for your algorithm. what is the time complexity for each algorithm and why?
Answers: 1
question
Computers and Technology, 22.06.2019 11:00
The great length of north america causes the climate to be varied. true false
Answers: 2
question
Computers and Technology, 24.06.2019 13:20
In the insert table dialog box, you select the checkbox to create the first row as the header of the table.
Answers: 3
question
Computers and Technology, 24.06.2019 16:00
Which of the following characters is acceptable to use in a filename? ? / – %
Answers: 1
You know the right answer?
Given the following code, where id indicates a process number or ID), launch() indicates concurrent...
Questions
question
Mathematics, 29.10.2020 22:40
question
Mathematics, 29.10.2020 22:40
question
English, 29.10.2020 22:40
question
Business, 29.10.2020 22:40
Questions on the website: 13722361