← CSC 214 Operating Systems
Process Management and CPU Scheduling
Notes
Introduction to Processes
An operating system executes diverse programs ranging from background daemons to user applications. In modern computing, a process represents a program in execution. A process requires computing resources such as CPU time, memory space, files, and input-output devices. The core responsibility of the process manager is to schedule these processes efficiently, balancing system throughput, latency, and CPU utilization.
Process States and the Process Control Block
A process transitions through various lifecycle states: New, Ready, Running, Waiting (or Blocked), and Terminated. The operating system tracks each process using a kernel data structure called the Process Control Block (PCB). The PCB stores the Process Identifier (PID), process state, program counter, CPU registers, CPU scheduling information, and memory management pointers. When the CPU switches execution from one process to another, a context switch occurs. This mechanism saves the state of the active process and restores the saved state of the incoming process, introducing an unavoidable overhead.
CPU Scheduling Algorithms
Scheduling algorithms dictate how the operating system assigns CPU execution time to ready processes. Key metrics include turnaround time, response time, waiting time, and CPU throughput. Common scheduling approaches include First-Come, First-Served (FCFS), Shortest Job Next (SJN), Priority Scheduling, and Round Robin (RR). While FCFS causes the convoy effect where short processes wait behind long CPU-bound jobs, Round Robin allocates each process a fixed slice of time termed a quantum, ensuring fairness and responsiveness in interactive systems.
Practical example
Consider an integration gateway hosted in Nairobi that handles M-Pesa Daraja API payment notifications for retail merchants. Three distinct tasks arrive simultaneously at time zero: Process A (Merchant SMS alert) requiring 2 milliseconds of CPU time, Process B (Core Ledger debit) requiring 8 milliseconds, and Process C (Receipt PDF generation) requiring 4 milliseconds.
Under FCFS scheduling, the execution order is A, B, and C. Process A finishes at 2ms (waiting time 0ms), Process B finishes at 10ms (waiting time 2ms), and Process C finishes at 14ms (waiting time 10ms). The average waiting time is (0 + 2 + 10) / 3 = 4.0 milliseconds.
Under Round Robin scheduling with a time quantum of 3 milliseconds, Process A executes for 2ms and finishes early. Process B executes for 3ms (leaving 5ms). Process C executes for 3ms (leaving 1ms). Process B returns for 3ms (leaving 2ms). Process C finishes with its remaining 1ms. Finally, Process B finishes. Round Robin avoids starvation, ensuring time-critical customer notifications are dispatched without being blocked by intensive accounting updates.
Quiz
1. Which scheduling algorithm assigns each process a predetermined time slice called a quantum to guarantee fair access?
2. What kernel data structure maintains the state, program counter, and register contents of an active process?
3. In the M-Pesa payment processing example, what issue occurs under FCFS when small notification jobs are stuck behind long ledger tasks?
Sign in to submit and securely grade your quiz.