1,419 views
2 2 votes

Please help with the minimum value. Problem is from the gate wallah study handout.

1 Answer

2 2 votes

2 test() calls with 5 iterations for each. For simplicity let's consider 2 test() as processes P1, P2 .

P1: test() call (first iteration): loads '0', increments it by 1, [gets preempted before storing it back]

P2: 4 iterations of test() runs normally and gets preempted. So, now the value of count is 4.

Now,  P1 is starts again from where it left off. It has count value of 1 incremented locally. It stores back 1 and gets preempted.

Now, P2 resumes execution of it's final iteration. It loads the value of count as 1, increments it to 2 and gets preemted.

NowP1 executes remaining 4 iterations making the value of count as 5.

Finally, P2 executes the 'store' for it's last iteration. It stores back 2 (since it has count value as 2 locally incremented) 

So, minimum turns out to be 2.

The maximum will be 10 (execution happens sequentially)

Position:
Show:

Related questions

0 0 votes
0 0 answers
787
787 views
Answers Copied asked Jan 6, 2023
787 views
Does anyone have updated e-study materials, especially the study handouts provided by big coaching?
0 0 votes
1 1 answer
3.8k
3.8k views
chiranjiv asked Jul 18, 2018
3,800 views
which is the best book for Gate cse topicwise previous year solved paper solution ?
1 1 vote
0 0 answers
1.3k
1.3k views
Kedar S asked Apr 13, 2019
1,330 views
How do I begin my GATE preparation to get in top 50 in GATE 2020 now? I'm a Mechanical Engineering student at an NIT, know basic coding but not the core subjects. Is ther...
7 7 votes
1 answers 1 answer
5.5k
5.5k views
Pratyush Madhukar asked Oct 26, 2016
5,538 views
Given memory partitions of 100kB, 700kB, 500kB, 200kB, 100kB (in order) and requests for processes of size 112kB, 516kB, 180kB, 320kB, 190kB (in order) are placed. Accord...