CONTEXT_SWITCH: SAVE_PCB / LOAD_PCB
TURNAROUND = COMPLETION - ARRIVAL
SCHEDULER: ROUND_ROBIN
STATE: PREEMPTING
ASKiIMAN™ DOOR 01 / FOUNDATIONS / REALM 12
--:-- · -- --- ----

Ontological Layer: Active Execution Contexts

The Process & Scheduling

How the Operating System Gives Time to Living Programs

The Illusion of Simultaneous Life

A program is passive code stored on a disk. A Process is that code brought to life—an active execution entity assigned memory, security context, and CPU time. Because a single CPU core can only execute one process at a time, the OS must ruthlessly manage a state machine: swapping PCBs in and out of the CPU via Context Switches, utilizing complex Scheduling Algorithms (like Round Robin or SJF) to create the illusion that dozens of programs are running simultaneously.

PROGRAM → READY QUEUE → DISPATCH TO CPU → RUNNING → WAITING (I/O) vs PREEMPTED (TIME OUT) → TERMINATED

The 12 Execution Chambers

Ontological Mapping: States, PCBs, and Dispatching

CHAMBER 01

Program → Process

  • Program as passive static code
  • Process as active execution entity
  • Resource ownership changes
  • Execution state instantiation
CHAMBER 02

Process Address Space

  • Code (Text) Segment
  • Data and BSS Segments
  • Heap (Dynamic memory)
  • Stack (Function calls & locals)
CHAMBER 03

Process States

  • New, Ready, Running, Waiting, Terminated
  • Scheduler dispatch (Ready → Running)
  • Preemption (Running → Ready)
  • I/O Blocking (Running → Waiting)
CHAMBER 04

Process Control Block

  • The OS data structure for a process
  • Process ID (PID) and State
  • Program Counter & CPU Registers
  • Memory and I/O tracking info
CHAMBER 05

Creation & Termination

  • Parent / Child hierarchy
  • Fork vs Spawn execution models
  • Normal vs Abnormal termination
  • Zombie and Orphan processes
CHAMBER 06

Scheduling Fundamentals

  • Multiprogramming objective
  • Ready Queue management
  • The Dispatcher mechanism
  • Preemptive vs Non-Preemptive
CHAMBER 07

Scheduling Algorithms

  • FCFS (First-Come, First-Served)
  • SJF (Shortest Job First) / SRTF
  • Priority Scheduling (Starvation/Aging)
  • Round Robin (Time Quantum slicing)
CHAMBER 08

Multilevel Scheduling

  • Multiple distinct ready queues
  • Foreground vs Background priority
  • Multilevel Feedback Queue (MLFQ)
  • Dynamic priority adjustment
CHAMBER 09

Metrics & Gantt Charts

  • Turnaround Time (Completion - Arrival)
  • Waiting Time (Turnaround - Burst)
  • Response Time vs Throughput
  • Visualizing CPU allocation
CHAMBER 10

Threads & Context Switches

  • Threads as smallest schedulable units
  • Shared Heap/Data vs Private Stacks
  • Context Switch (Save old PCB, Load new)
  • Pure overhead cost of switching
CHAMBER 11

Multicore & IPC

  • Global vs Per-Core scheduling
  • Load balancing and CPU Affinity
  • Inter-Process Communication (IPC)
  • Shared Memory vs Message Passing
FINAL PROTOCOL

12 — The Scheduling Laboratory

1. ARRIVAL: P1(0), P2(1). BURST: P1(5), P2(2)
2. ALGO: SRTF (Preemptive SJF)
3. t=1: P2(2) < P1(4). PREEMPT P1!
4. GANTT: [P1:0-1][P2:1-3][P1:3-7]
[1] CALCULATE TURNAROUND [2] IDENTIFY STARVATION [3] TRACE CONTEXT SWITCH [4] DRAW GANTT CHART [5] ANALYZE THREADS

We now understand that programs are active, concurrent entities fighting for the CPU. But what happens when these multiple threads or processes try to access the exact same shared memory at the exact same time? This chaos leads us directly into Realm 13: Concurrency, Synchronization & Deadlock.

SCHEDULER DIAGNOSTIC RUNNING