Question: Problem 4 In this problem, we consider mutual exclusion of concurrent processes running on a multipro- cessor system. Assume that the execution of the code

Problem 4 In this problem, we consider mutual exclusion of concurrent processes running on a multipro- cessor system. Assume that the execution of the code xx 1 consists of the following three operations: (i) load the inia value of x to a register R from a memory addrss A add 1 to R, and) store the value of R to A Answer the following questions. (1) Consider the case where two processes share a variable x and execute x x + 1 concurrently on this multiprocessor system without mutual exclusion. Assuming that the nitial value of x is 0, answer al the possible values of x after both the processes complete the executions of x=x+1. (2) A standard way to achieve mutual exclusion of the executions of x = x + 1 is to use the TestAndSet instruction as in the followg C code. while (TestAndSet (&lock)); lock0; Here, x and lock are shared variables, whose initial values are 0. The TestAndSet instruction. with a hardware support atomically executes the functionality that s dscibed by the following C code. Answer appropriate expressions thatl the blanks from (A) to (E). int TestAndSet (int *a) int b; return (E)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
