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 15:10
Consider a direct-mapped cache with 216 words in main memory. the cache has 16 blocks of 8 words each. it is a word-addressable computer (rather than a byte-addressable computer which we normally discuss). (a) how many blocks of main memory are there? (b) what is the format of a memory address as seen by the cache, that is, what are the sizes of the tag, cache block, and block offset fields (if they apply)? (c) to which cache block will the memory reference db6316 map?
Answers: 1
question
Computers and Technology, 24.06.2019 02:10
Consider the usual algorithm to convert an infix expression to a postfix expression. suppose that you have read 10 input characters during a conversion and that the stack now contains these symbols: (5 points) | | | + | | ( | bottom |_*_| now, suppose that you read and process the 11th symbol of the input. draw the stack for the case where the 11th symbol is
Answers: 2
question
Computers and Technology, 24.06.2019 12:00
How can we take picture in this app
Answers: 1
question
Computers and Technology, 24.06.2019 23:50
Which career involves analyzing various factors that influence the customer decision-making process? analyze various factors that influence the customer decision-making processes. reset next
Answers: 2
You know the right answer?
Given the following code, where id indicates a process number or ID), launch() indicates concurrent...
Questions
question
Mathematics, 20.07.2019 09:00
Questions on the website: 13722363