Operating Systems Level 3
PART 1 • EXECUTION FOUNDATIONS

See a Running Program as a Managed Process

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.

Level 03 of 15 Intermediate 90–120 minutes Requires Levels 1–2
BY THE END, YOU CAN

Track execution precisely

  • Distinguish program, process and processor.
  • Justify every process-state transition.
  • Explain each major PCB field.
  • Separate mode switch from context switch.
  • Describe creation, fork, exec, wait and termination.
01 • DEFINE EXECUTION

A Program Is Passive; a Process Is Active

The same executable file can support several independent processes, each with its own execution state and resources.

PROGRAM

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.

load + state
PROCESS

A program in execution

A process includes code plus a program counter, registers, address space, stack, heap, open objects, credentials and OS bookkeeping.

PC

Program counter

Identifies the next instruction for this process when it receives CPU time.

AS

Address space

Provides the process’s protected view of code, data, heap, stack and mapped regions.

R

Resources

Open files, communication endpoints, credentials, timers and limits are associated with the process.

ID

Identity

A process identifier and relationships let the OS distinguish, control and account for executions.

02 • FOLLOW THE LIFECYCLE

Five-State Process Model

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.
03 • INTERACTIVE LAB

Drive a Process through Legal State Transitions

Use only the enabled events. The simulator prevents impossible moves and explains each valid transition.

PROCESS CREATED

New process is being initialized

The OS is assigning identity and constructing the process’s management state before it can compete for CPU time.

04 • INSPECT SAVED IDENTITY

The PCB Is the OS Record That Makes a Process Manageable

Select each field in the simplified Process Control Block to see why the OS needs it.

PCB • PID 4217
EXECUTION STATUS

Process state

Records whether the process is new, ready, running, waiting or terminated.

Why it matters: The scheduler and event handlers use this field to decide whether the process is eligible to run and which transition is legal.
05 • ORGANIZE COMPETITION

Processes Wait in Different Scheduling Structures

Job / admission collection

New work waits for the OS to admit it according to resource and policy limits.

P4217 P4218

Ready queue

Eligible processes wait for a CPU. Scheduling policy decides their order; “queue” need not imply simple FIFO.

P102 P305 P88

Device / event wait

Blocked processes are grouped by the event or resource whose completion can wake them.

Disk: P54 Pipe: P73
06 • INTERACTIVE DEEP TRACE

Watch the CPU Switch from One Process to Another

A context switch preserves enough of Process A to resume it later, then restores Process B’s saved execution state.

COST TO REMEMBER Useful application work pauses during save, schedule and restore.
STEP 1 OF 8 PROCESS A • RUNNING

PROCESS A PC 0x4012A0
PROCESS B PC 0x52F010 (saved)
07 • CREATE EXECUTION

Process Creation Builds Identity, Resources and an Initial Context

01

Assign identity

Create a PID and parent/ownership relationships.

02

Create PCB

Initialize state, scheduling and accounting fields.

03

Prepare address space

Map program code, data, stack and required libraries.

04

Become ready

Place the process where the scheduler can select it.

fork(): create a new process

In 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 image

Exec 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 child

A parent can wait for child completion and collect its termination status, allowing the OS to release the remaining process record.

Parent and child execute independently

After creation, scheduler decisions determine which runs first. Source-code order alone does not guarantee whether the parent or child prints first.

08 • END SAFELY

Termination Ends Execution, but Cleanup May Have Stages

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.
09 • CHECK YOUR UNDERSTANDING

Ten Misconception-Specific Checks

Every choice explains the exact reasoning error or correct principle.

Answered correctly: 0 of 10
10 • EXPLAIN & PREPARE

University and Placement Questions

2-MARK QUESTIONS
  1. Define a process.
  2. What is a PCB?
  3. Differentiate ready and waiting.
  4. What is a zombie process?
  5. Define context switch.
5-MARK QUESTIONS
  1. Explain the five-state process model.
  2. Describe major PCB fields.
  3. Trace a context switch.
  4. Explain process creation and termination.
  5. Compare program and process.
INTERVIEW QUESTIONS
  1. Why is context switching overhead?
  2. Does every system call switch processes?
  3. Why does I/O completion move waiting to ready?
  4. fork versus exec—what changes?
  5. Zombie versus orphan?
Show a strong answer: “Explain a context switch”
  1. State the trigger: timer, blocking event or scheduling decision.
  2. The kernel saves the outgoing process’s program counter, registers and required execution state in its PCB.
  3. It updates state/queues and selects an eligible process according to scheduling policy.
  4. The kernel restores the selected process’s memory context and saved CPU state.
  5. Execution resumes at that process’s saved program counter.
  6. Finish with cost: save/restore and cache effects perform no direct application work.
Show a strong answer: “Ready versus waiting”

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.

LEVEL 3 SUMMARY

You Can Now Track a Process throughout Its Lifetime

  • A process combines a program with live CPU, memory, resource and identity state.
  • New, ready, running, waiting and terminated describe different scheduling conditions.
  • The PCB stores what the OS needs to stop, manage and later resume execution.
  • A context switch saves one process, schedules, then restores another; it is not merely a privilege change.
  • fork creates a child, exec replaces a program image, and wait collects completion status.
COURSE CHECKPOINT

Mark Level 3 after you can justify every transition and explain what the PCB saves.

Saved only in this browser.