GATE CS 2019 Set 1 — Question 33
Go beyond PYQs with Success TrackerAI-powered personalised practice and doubt support. Unlimited practice on eligible plans; AI usage limits apply.NAT+1 / -0HardRace Conditions & Critical SectionProcess SynchronizationOperating System
Operating System → Process Synchronization → Race Conditions & Critical Section
Last updated
Question
Consider three concurrent processes P1, P2 and P3 as shown below, which access a shared variable D that has been initialized to 100.
The processes are executed on a uniprocessor system running a time-shared operating system. If the minimum and maximum possible values of D after the three processes have completed execution are X and Y respectively, then the value of Y – X is __________.
| P1 | P2 | P3 |
|---|---|---|
| : | : | : |
| D = D + 20 | D = D - 50 | D = D + 10 |
| : | : | : |
Correct answer
80 to 80
Solution
Each statement
D = D + c runs as three steps on a uniprocessor: read into a register, modify the register, write it back. A process can be preempted between these steps, so a write can overwrite (lose) other processes' updates.Minimum . Let P2's write come last, based on the original value:1.P2 reads and is preempted.
2.P1 runs completely: .
3.P3 runs completely: .
4.P2 resumes and writes .
Both increments are lost, so . No smaller value is possible: the only negative update is , applied to a value read as at least . So .Maximum . Lose the decrement and keep both increments:1.P1 reads and is preempted.
2.P2 runs completely: .
3.P1 resumes and writes (P2's update is lost).
4.P3 runs completely: .
The largest possible result is , so .Answer: 80Continue learning with Success Tracker
A step still unclear? Work through it with support
Use Success Tracker to ask about the reasoning, then try another GATE CS question to check your understanding.
AI-powered practice· Unlimited practice on eligible plans
- PYQs with solutions
- Attempt available previous-year questions, then compare your reasoning with the worked solution. Coverage varies by stream.
- Practice that adapts
- Choose a topic, work on weaker areas and bookmark questions to revisit. Your attempts feed your progress tracking.
- AI doubt support
- Ask follow-up questions about a step or concept while practising, instead of stopping at the final answer.
Unlimited practice is available on eligible plans. Free practice and AI usage have limits; check the current plan allowances before choosing.
This page stays readable without an account. AI responses can be wrong; check them against the solution and source material.
More questions on Process Synchronization
2026 Set 2 Q23Which one of the following CPU scheduling algorithms cannot be preemptive?2026 Set 1 Q29With respect to deadlocks in an operating system, which of the following statements is/are FALSE?2026 Set 1 Q31In the context of relational database normalization, which of the following statements is/are true?2026 Set 1 Q35Consider a system consisting of instances of a resource , being shared by 5 processes.…2026 Set 2 Q51Consider three processes P1, P2, and P3 running identical code, as shown in the pseudocode below. A…