2 votes 2 votes int x=0,y=0; par begin begin x=1; y=y+x; end begin y=2; x=x+3; end par end what are the possible values of x and y after completion of the program? a. x=1 ,y=2 b.x=1,y=3 c.x=4,y=6 Operating System operating-system process-synchronization + – sampad asked Dec 31, 2015 retagged Dec 31, 2015 by Himanshu1 sampad 554 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
2 votes 2 votes b,c are possible There are total 6 orders possible for executing these 4 statements concurrently (like in DBMS transactions) x=1; y=2; y=y+x; x=x+3; possible values for x,y : A) 4,2 B) 4,3 C) 1,3 D) 4,6 So, b,c is the answer. Himanshu1 answered Jan 1, 2016 Himanshu1 comment Share Follow See all 4 Comments See all 4 4 Comments reply sampad commented Jan 1, 2016 reply Follow Share please explain. 0 votes 0 votes Himanshu1 commented Jan 1, 2016 reply Follow Share x=1; y=2; y=y+x; x=x+3; These left side & right side codes are running concurrently. so, they can overlap in any order. like one order is y=2; x=x+3; x=1; y=y+x; This should give 4,6 0 votes 0 votes Anmol Verma commented Jan 17, 2017 reply Follow Share explain b part how x=1 and y=3.....??? 0 votes 0 votes afroze commented Oct 25, 2021 reply Follow Share y=2 x=x+3 x=0+3=3 now x=1 //overlap y=y+x y=2+1 =3 (1,3) 0 votes 0 votes Please log in or register to add a comment.