Following is the code for two threads T1 and T2; x and y are global variables initialized to 0.
T1: T2:
x++ while (x==0) ; //busy wait
y++ x++
y++
- What is the value (or possible values) of x and y, after T1 and T2 finish executing?
- If the final value of y can be something other than 2, fix the program so that the value is always 2. Use busy waiting (no atomic instructions, no semaphores).