1. LPU MCA Semester 1
  2. CAP366
  3. 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.

TransitionCause
New to ReadyAdmitted by the long-term scheduler
Ready to RunningDispatcher selects it
Running to ReadyTime slice expires / preemption
Running to WaitingRequests I/O or waits for an event
Waiting to ReadyI/O or event completes
Running to Terminatedexit

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

Question 1 · Tier 3, Apply

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?

  1. Ready
  2. Running
  3. Waiting
  4. 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.

Question 2 · Tier 4, Analyse

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?

  1. 2
  2. 3
  3. 4
  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.