Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 4 In this problem, we consider mutual exclusion of concurrent processes

ID: 3902025 • Letter: P

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 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)

Explanation / Answer

Hence, A => b, B => *a, C => *a, D => 1, E => b

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote