Determine the proper lower hound and upper hound on the fina
Solution
On casual inspection, it appears that tally will fall in the range of 50<=tally<=100 since from 0 to 50 increments could go unrecorded due to the lack of mutual exclusion. on running the two processes concrrently, we shouldnot be able to derive a result lower than result produced by executed by just onw of these processes sequentially . The logic is quite clear.
but , consider the sequence of load, increment and store operations performed by these two rpocesses when altering the value of the shared variable,
1)Process A loads the value of tally ,increments tally, but then looses the processor ,it has incremented accumulator ro 1 but not yet stored the value
2)Process B loads the value of tally(still 0) , performs complete 49 increment operations, losing the processor after it has stored the value 49 into shared variable tally
3)Process A regains it control to perform its first store operation ,replacing tally value if 49 with 1 , but it then immediately has to give control of the processor to B
4)The process B resumes long enough to load 1 into its accumulator ,then it is als oforces to give up the processor
5)Process A is rescheduled, now it is not interrupted and it tends to completion (since B has its final load done) performings the remaining 49 load , increment and store operations , making value of tally to be 50
6)Process B is reactivated with only one increment and store operation left ,it increments accumulator to 2 , stores this value as final value of the shared variable .
All the values in range 2 to 49 are likewise potential results
The interleaved sequences cause process B to loose processor after completing 50-k incremental cycles .
so 1<=k<=48 are the upper and lower bounds of k
