Following is the code for two threads t1 and t2 x and y are


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

Request for Solution File

Ask an Expert for Answer!!
Cost Accounting: Following is the code for two threads t1 and t2 x and y are
Reference No:- TGS01360020

Expected delivery within 24 Hours