22 votes 22 votes Consider the concurrent program x := 1; cobegin x := x + x + 1 || x := x + 2 coend; Reading and writing of a variable is atomic, but evaluation of an expression is not atomic. The set of possible values of variable $x$ at the end of execution of the program is $\left\{3\right\}$ $\left\{7\right\}$ $\left\{3, 5, 7\right\}$ $\left\{3, 7\right\}$ $\left\{3, 5\right\}$ Operating System tifr2012 process-synchronization operating-system + – makhdoom ghaya asked Oct 31, 2015 edited Jun 17, 2018 by kenzou makhdoom ghaya 2.1k views answer comment Share Follow See 1 comment See all 1 1 comment reply Ashwani Kumar 2 commented Aug 30, 2019 reply Follow Share Repeated question: https://gateoverflow.in/18751/tifr2010-b-28 0 votes 0 votes Please log in or register to add a comment.
Best answer 18 votes 18 votes $1. x = 1$, Run $x = x + 2$ then $x= x + x + 1$ finally $x$ will be $7$. $2. x = 1$, run $x = x + 2$ and $x = x + x + 1$, parallely .. $x = 5 , 3$ Final answer would be $\{3, 5, 7\}$ Digvijay Pandey answered Oct 31, 2015 edited Jun 17, 2018 by kenzou Digvijay Pandey comment Share Follow See all 10 Comments See all 10 10 Comments reply Show 7 previous comments talha hashim commented Apr 27, 2018 reply Follow Share nice explanation @Bikaram sir u remove all the doubts 0 votes 0 votes `JEET commented Dec 5, 2019 reply Follow Share Bikram Sir's comment should become the answer. 0 votes 0 votes Chinmay Agnihotri commented Jul 7, 2020 reply Follow Share Since it is given that the evaluation of an expression is not atomic, can 4 be an answer as well? (Although not mentioned in options) While evaluating the first expression x = x+x+1, if after evaluation of x=x+x, resulting in value of x equal to 2, can the process preempt to the other condition , i.e x= x+2, to give the value 4? 0 votes 0 votes Please log in or register to add a comment.