Stored instructions and static data
An executable is a passive file. It does not have a current instruction, CPU registers, scheduling state or open runtime resources merely because it exists on storage.
Code
Bhavya
A process is more than program code. Trace its changing state, inspect the Process Control Block that preserves its identity, and see exactly what the OS saves during a context switch.
The same executable file can support several independent processes, each with its own execution state and resources.
An executable is a passive file. It does not have a current instruction, CPU registers, scheduling state or open runtime resources merely because it exists on storage.
A process includes code plus a program counter, registers, address space, stack, heap, open objects, credentials and OS bookkeeping.
Identifies the next instruction for this process when it receives CPU time.
Provides the process’s protected view of code, data, heap, stack and mapped regions.
Open files, communication endpoints, credentials, timers and limits are associated with the process.
A process identifier and relationships let the OS distinguish, control and account for executions.
A state answers one immediate question: what must happen before this process can execute or continue?
| State | Meaning | What moves it onward? |
|---|---|---|
| New | The OS is creating the process and its management structures. | Admission into the ready population. |
| Ready | The process has what it needs except a CPU. | Scheduler dispatches it. |
| Running | Its instructions are currently executing on a CPU. | Preemption, blocking, or completion. |
| Waiting / blocked | It cannot proceed until an event such as I/O completion occurs. | The awaited event completes, making it ready. |
| Terminated | Execution has ended; the OS is reclaiming remaining state. | Final cleanup and parent acknowledgement where applicable. |
Use only the enabled events. The simulator prevents impossible moves and explains each valid transition.
The OS is assigning identity and constructing the process’s management state before it can compete for CPU time.
Select each field in the simplified Process Control Block to see why the OS needs it.
Records whether the process is new, ready, running, waiting or terminated.
New work waits for the OS to admit it according to resource and policy limits.
Eligible processes wait for a CPU. Scheduling policy decides their order; “queue” need not imply simple FIFO.
Blocked processes are grouped by the event or resource whose completion can wake them.
A context switch preserves enough of Process A to resume it later, then restores Process B’s saved execution state.
0x4012A0
0x52F010 (saved)
Create a PID and parent/ownership relationships.
Initialize state, scheduling and accounting fields.
Map program code, data, stack and required libraries.
Place the process where the scheduler can select it.
fork(): create a new processIn Unix-like systems, fork creates a child with a new PID and a logical copy of the parent’s execution environment. Modern systems commonly use copy-on-write rather than immediately duplicating every physical page.
exec(): replace the current program imageExec loads a new program into the calling process. The PID can remain the same because exec transforms an existing process—it does not necessarily create another one.
wait(): coordinate with a childA parent can wait for child completion and collect its termination status, allowing the OS to release the remaining process record.
After creation, scheduler decisions determine which runs first. Source-code order alone does not guarantee whether the parent or child prints first.
| Situation | Meaning | Important distinction |
|---|---|---|
| Normal exit | The program finishes or explicitly returns an exit status. | The OS closes/reclaims resources and records the status. |
| Abnormal termination | An unhandled fault, protection violation or external termination ends it. | One process can be ended without stopping all processes. |
| Zombie | The child has finished, but a small record remains until its parent collects status. | It is terminated and does not continue executing. |
| Orphan | A parent ends while its child is still running. | The child is still alive and is adopted/managed by a system process. |
Every choice explains the exact reasoning error or correct principle.
A ready process needs only a CPU and can be selected by the scheduler. A waiting process cannot progress even if a CPU is free because it awaits an event such as I/O completion. When that event occurs, it normally becomes ready; it does not automatically become running.
Mark Level 3 after you can justify every transition and explain what the PCB saves.
Saved only in this browser.