- LPU MCA Semester 1
- CAP366
- Unit 2
CAP366 · Unit 2: Process
Process states and transitions
11 practice questions · in the MTE and ETE syllabus
Key points
- Five states: New, Ready, Running, Waiting, Terminated
- Preemption: Running to Ready
- I/O request: Running to Waiting
- I/O completion: Waiting to Ready, never straight to Running
A process moves through five states: New, Ready, Running, Waiting (Blocked), Terminated.
| Transition | Cause |
|---|---|
| New to Ready | Admitted by the long-term scheduler |
| Ready to Running | Dispatcher selects it |
| Running to Ready | Time slice expires / preemption |
| Running to Waiting | Requests I/O or waits for an event |
| Waiting to Ready | I/O or event completes |
| Running to Terminated | exit |
On one CPU at most one process is Running at a time. Example: with 7 live processes, 3 Waiting and 1 Running, there are 7 - 3 - 1 = 3 Ready.
Exam pitfall: there is no Waiting to Running and no Ready to Waiting arrow. After I/O completes a process must pass through Ready, even if it is dispatched immediately afterwards.
Try two questions
A process is admitted, dispatched, makes an I/O request, has that I/O complete, is dispatched again, and then its timer expires. In which state is it now?
- Ready
- Running
- Waiting
- Terminated
Show the answer
A. A timer expiry moves a running process back to the ready queue. The earlier I/O completion also returned it to ready.
Why not B: A timer interrupt takes the process off the CPU, so it is no longer running.
Why not C: The I/O already completed earlier, so it is not waiting any more.
Why not D: Nothing in this sequence ends the process.
A process is admitted, dispatched, requests I/O, completes the I/O, is dispatched, is preempted by the timer, is dispatched, requests I/O, completes the I/O, is dispatched and finally exits. How many times does it enter the Ready state?
- 2
- 3
- 4
- 5
Show the answer
C. Entries into Ready: admission, first I/O completion, preemption and second I/O completion, giving 4. Dispatches leave Ready.
Why not A: This counts only the two I/O completions and misses admission and preemption.
Why not B: This misses one of the entries into Ready.
Why not D: Every dispatch moves it out of Ready, not into it, so this overcounts.