340 likes | 547 Views
CPU Scheduling. Peng Lu. CPU Scheduling. 1. Basic Concepts 2. Scheduling Criteria 3. Scheduling Algorithms 4. Multiple-Processor Scheduling 5. Real-Time Scheduling. 1. Basic Concepts. Alternating Sequence of CPU And I/O Bursts CPU Scheduler Preemptive Scheduling Dispatcher.
E N D
CPU Scheduling Peng Lu
CPU Scheduling • 1. Basic Concepts • 2. Scheduling Criteria • 3. Scheduling Algorithms • 4. Multiple-Processor Scheduling • 5. Real-Time Scheduling
1. Basic Concepts • Alternating Sequence of CPU And I/O Bursts • CPU Scheduler • Preemptive Scheduling • Dispatcher
CPU Scheduler • Short-term scheduler • First-in, first-out (FIFO)
Preemptive Scheduling • CPU scheduling decisions may take place when a process: 1.Switches from running to waiting state 2. Switches from running to ready state 3. Switches from waiting to ready state 4. Terminates • Non-preemptive (1 and 4) • Preemptive (All other)
Dispatcher • Dispatcher involves: • switching context • switching to user mode • jumping to the proper location in the user program to restart that program • Dispatch latency
2. Scheduling Criteria • CPU utilization • Throughput • Turnaround time • Waiting time • Response time
Optimization Criteria • Max CPU utilization • Max throughput • Min turnaround time • Min waiting time • Min response time
3. Scheduling Algorithms • First-come, First-served (FCFS) • Shortest-Job-First (SJF) • Priority • Round-Robin (RR) • Multilevel Queue • Multilevel Feedback Queue
P1 P2 P3 0 24 27 30 First-Come, First-Served (FCFS) ProcessBurst Time P1 24 P23 P3 3 • If that the processes arrive in the order: P1 , P2 , P3 ,,The Gantt Chart for the schedule is:
P2 P3 P1 0 3 6 30 FCFS Scheduling (Cont.) If that the processes arrive in the order P2 , P3 , P1 • The Gantt chart for the schedule is:
Shortest-Job-First (SJF) ProcessBurst Time P1 6 P2 8 P3 7 P4 3
Priority Scheduling ProcessBurst TimePriority P1 10 3 P2 1 1 P3 2 4 P4 1 5 P5 5 2
Priority Scheduling • Indefinite blocking (Starvation) • Aging
P1 P2 P3 P4 P1 P3 P4 P1 P3 P3 0 20 37 57 77 97 117 121 134 154 162 Round-Robin (RR) Time Quantum = 20 ProcessBurst Time P1 53 P217 P368 P424
4. Multiple-Processor Scheduling • More complex when multiple CPUs are available • Homogeneous • Load sharing • Asymmetric multiprocessing
5. Real-Time Scheduling • Hard real-time • Soft real-time
Summary • Optimization Criteria • Max CPU utilization, throughput; • Min turnaround, waiting and response time • FCFS, SJF, Priority, RR • Multilevel Queue and Feedback Queue
6. Algorithm Evaluation • Deterministic modeling • Queueing models • Simulations • Implementation
Operating System Examples • Solaris scheduling • Windows XP scheduling • Linux scheduling
Operating System Examples:Linux Scheduling • Time-sharing • Real-time