Question: Consider the following program fragment. Threads T1 and T2 concurrently run in the same address space and complete the functions with corresponding names. Assume that

Consider the following program fragment. Threads T1 and T2 concurrently run in the same address space and complete the functions with corresponding names. Assume that lock is initially unlocked, and is an xv6 spinlock as described in the lecture notes. This question asks you about the state of the process after both threads have completed. Note that x and y are allocated in the static data segment and initially have the value 0: you may treat them as if they are on the heap for this question, and are word-sized and word-aligned. int x = 0; int y = 0; void T1() { acquire(\&lock); x = x + 1; y = y + 1; release (\&lock); } void T2() { acquire(\&lock); x = x + 1; y = y + 1; release (\&lock); } 47. What values could (x, y) have after both threads complete? Select all that apply: (a) (0,0) (b) (0, 1) (c) (1,0) (d) (1,1) (e) (0, 2) (1) (2,0) (g) (1, 2) (h) (2, 1) (i) (2, 2)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
