1Definition
CPU Scheduling is the process by which the short-term operating system scheduler dispatches CPU execution time among processes residing in the ready queue. Scheduling performance is evaluated using metrics including CPU Utilization, Throughput, Turnaround Time (TAT), Waiting Time (WT), Response Time (RT), and Completion Time (CT).
2Simple Explanation
The CPU is the most expensive engine in a computer. The goal of CPU scheduling is to keep that engine operating at 100% capacity without letting any job starve. When multiple processes arrive in memory, the scheduler uses specific rules to decide who gets the CPU next. To measure which rule works best, engineers track how long processes spend waiting in line, how fast they get their first response, and how many jobs finish per minute.
3Real-Life Example / Analogy
A Bank Teller Queue:
- Arrival Time (AT): The time you walk into the bank lobby.
- Burst Time (BT): The time it takes the teller to process your cash deposit.
- Completion Time (CT): The timestamp when you walk out of the bank with your receipt.
- Turnaround Time (TAT): The total time you spent inside the bank ().
- Waiting Time (WT): The time you spent standing in line before reaching the teller ().
- Throughput: The number of customers the bank teller serves per hour.
4Diagram / Visual Representation
5Working / How It Works
- Job Arrival: Process enters Ready Queue at timestamp Arrival Time (AT).
- Scheduler Dispatch: Short-term scheduler selects process; CPU touches it for the first time (Response Time reference).
- Execution: Process executes for its Burst Time (BT) (may be interrupted).
- Termination: Process completes execution at Completion Time (CT).
- Metric Calculations:
6Types / Components / Characteristics
- Primary Optimization Goals:
- Maximize: CPU Utilization (Keep CPU as busy as possible, ideally 100%) and Throughput.
- Minimize: Turnaround Time, Waiting Time, and Response Time.
- Scheduling Modes:
- Non-Preemptive Scheduling: Once a process gets the CPU, it holds it until termination or manual I/O wait.
- Preemptive Scheduling: Operating system can forcibly suspend a running process when its time quantum expires or a higher-priority job arrives.
7Solved Examples / Problems
Problem: Given Process P1 with Arrival Time AT = 0 ms, Burst Time BT = 8 ms, and Completion Time CT = 8 ms, calculate its Turnaround Time and Waiting Time. Solution:
8Advantages, Disadvantages & Applications
- Preemptive Advantages: High system responsiveness, low process starvation.
- Preemptive Disadvantages: Context-switching overhead; requires hardware timer interrupts.
- Non-Preemptive Advantages: Simple design, zero context-switch overhead.
- Non-Preemptive Disadvantages: Convoy effect; long jobs block short jobs.
9Important Points to Remember
- Non-preemptive algorithms cannot be interrupted once executed.
10Test Your Understanding
- MCQ: What is the correct formula to calculate the Waiting Time (WT) of a process?
- A)
- B)
- C)
- D)
Show answer
B. - Conceptual Question: Define Throughput and explain how it relates to CPU Utilization.
- Application Question: Differentiate between Response Time and Waiting Time in interactive multi-user operating systems.
