1,220 views
2 votes
2 votes
Consider the program segment:
x= 0; y=0;
Cobegin
begin
x= 1;
y= y + x;
end
begin
y= 2;
x= x + 3;
end
Coend;
Which of the following indicates possible values for the variables when the segment finishes
execution?
(1) x= 1, y= 2
(2) x= 1, y= 3
(3) x= 4, y= 6
(a) 1 only (b) 1 & 2 only
(c) 1 & 3 only (d) 2 & 3 only
(e) 1, 2, 3

1 Answer

2 votes
2 votes
x= 1;   ....1
y= y + x; ....2
y= 2;.....3
x= x + 3;....4

Consider following order 3,4,1,2 i.e Y=2,X=0+3,X=1,Y=1+2  so 1,3

Consider the following order 1,3,4,2 i.e X=1,Y=2,X=1+3,Y=2+4 so 4,6

so option D only 2 and 3

Related questions

1 votes
1 votes
2 answers
3
Ankit Sahu asked Feb 4, 2019
1,140 views
Why the value of D is 80 in concurrent process question and not 0? The question didn't mention that each statement take 3 instruction to execute so why assume that?