1,153 views
1 votes
1 votes

Consider the following segment:

Note : Assume the count = count + 1; will execute in ‘3’ different instructions.

Where, m[count] refers to memory value of count variable.

Preemption can occur while executing the above instructions. Each of the tally function has a separate register allocated to it in which the value of count is stored. After completion of main function, what will be the minimum and maximum values of count in the end of the program?

a) Min = 5, Maximum = 15

b) Min = 2, Maximum = 15

c) Min = 1, Maximum = 15

d) Min = 15, Maximum = 15

1 Answer

0 votes
0 votes

Min:

To get minimum, we need to exhaust any 2 function calls and make the 3rd call update the count value. Basically make a function call win the race condition, such that the function updates the count variable with lowest possible value. This also means rest two function calls should lose the race.

 


 

Max is 15:
Assume no pre-emption at all. Let the function run one after the other. You get 15.

Related questions

1.7k
views
1 answers
1 votes
Shreya2002 asked Aug 5, 2022
1,656 views
Consider a process P running on a system with non-preemptive Kernel design. Consider following actions by P :(i) A blocking system call.(ii) Servicing a timer ... as ready.Which of the above actions always result in context-switch of P?
269
views
0 answers
0 votes
kidussss asked Sep 1, 2022
269 views
1. Write clearly the dinning philosopher and reader-writer classical problem of process synchronization
639
views
2 answers
1 votes
Tuhin Dutta asked Oct 8, 2017
639 views
I encountered 1 question on context switching in Made Easy test series where it is mentioned:Scheduling policy is preemptive priority. Context switch time is 1 unit. ... 1-time unit gap or they can be done simultaneously in the gantt chart?
482
views
2 answers
1 votes
delxbydelt asked Mar 15
482 views
Consider a uniprocessor system with n processes in the ready queue. Round robin scheduling with time quantum x is used for process scheduling. Assume each process requires kx seconds to complete and ... nkx B) k(nx-1)C) k(nk+n)D) x(nk-n+1)