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 14:40
For this assignment you have to write a c program that will take an infix expression as input and display the postfix expression of the input. after converting to the postfix expression, the program should evaluate the expression from the postfix and display the result. what should you submit? write all the code in a single file and upload the .c file. compliance with rules: ucf golden rules apply towards this assignment and submission. assignment rules mentioned in syllabus, are also applied in this submission. the ta and instructor can call any students for explaining any part of the code in order to better assess your authorship and for further clarification if needed. problem: we as humans write math expression in infix notation, e.g. 5 + 2 (the operators are written in-between the operands). in computer's language, however, it is preferred to have the operators on the right side of the operands, ie. 5 2 +. for more complex expressions that include parenthesis and multiple operators, a compiler has to convert the expression into postfix first and then evaluate the resulting postfix write a program that takes an "infix" expression as input, uses stacks to convert it into postfix expression, and finally evaluates it. it must support the following operations: + - / * ^ % ( example infix expression: (7-3)/(2+2) postfix expression: 7 3 2 2 result: rubric: 1) if code does not compile in eustis server: 0. 2) checking the balance of the parenthesis: 2 points 3) incorrect postfix expression per test case: -2 points 4) correct postfix but incorrect evaluation per test case: -i points 5) handling single digit inputs: maximum 11 points 6) handling two-digit inputs: 100 percent (if pass all test cases)
Answers: 3
question
Computers and Technology, 23.06.2019 16:00
Write a grading program for a class with the following grading policies: a. there are two quizzes, each graded on the basis of 10 points. b. there is one midterm exam and one final exam, each graded on the basis of 100 points. c. the final exam counts for 50% of the grade, the midterm counts for 25%, and the two quizzes together count for a total of 25%. (do not forget to normalize the quiz scores. they should be converted to a percentage before they are averaged in.) any grade of 90 or more is an a, any grade of 80 or more (but less than 90) is a b, any grade of 70 or more (but less than 80) is a c, any grade of 60 or more (but less than 70) is a d, and any grade below 60 is an f. the program will read in the student’s scores and output the student’s record, which consists of two quiz and two exam scores as well as the student’s average numeric score for the entire course and final letter grade. define and use a structure for the student reco
Answers: 2
question
Computers and Technology, 23.06.2019 17:30
What are the most commonly found items in the trash according to the municipal solid waste report?
Answers: 1
question
Computers and Technology, 23.06.2019 19:00
Whose task it is to ensure that the product flows logically from one step to another?
Answers: 3
You know the right answer?
Given the following code, where id indicates a process number or ID), launch() indicates concurrent...
Questions
question
Mathematics, 20.05.2021 05:50
question
Mathematics, 20.05.2021 05:50
question
Mathematics, 20.05.2021 05:50
question
Computers and Technology, 20.05.2021 05:50
Questions on the website: 13722363