What will happen when a process terminates?
2023
What will happen when a process terminates?
- A.
It is removed from all queues
- B.
It is removed from all, but the job queue
- C.
Its process control block is de-allocated
- D.
Its process control block is never de-allocated
Attempted by 219 students.
Show answer & explanation
Correct answer: A
Concept
Process termination is the final transition in a process's lifecycle. When a process finishes, the operating system performs cleanup: it detaches the process from every scheduling and device structure it was linked into, and it reclaims the resources (memory, open files, I/O devices) the process held and returns them to the OS. A key subtlety is that the process's bookkeeping entry (its PCB / process-table entry) is not necessarily reclaimed at the same instant.
Applying it here
A running or waiting process is linked into OS queues (the ready queue and various device/waiting queues). On termination the OS unlinks it from all of these queues so the scheduler will never pick it again.
All resources allocated to it are deallocated and returned to the OS for reuse by other processes.
The PCB, however, is commonly retained for a short while: in UNIX-like systems a terminated child becomes a zombie and its entry survives until the parent reads its exit status (via wait). So PCB removal is part of reaping, not the defining act of termination itself.
Why the keyed answer holds
The statement that is universally true the moment a process terminates is that it leaves every queue it was in. It is removed from all queues captures exactly the cleanup that always happens on termination.
Contrast with the other choices
It is removed from all, but the job queue — wrong: termination removes the process from every queue; there is no queue it is specially kept in after it ends.
Its process control block is de-allocated — this can eventually happen, but it is not what defines termination: the PCB is typically held until the parent collects the exit status, so it is not the immediate, always-true outcome.
Its process control block is never de-allocated — wrong: the PCB is temporary; once the exit status is collected the OS does reclaim it.