CPSC 457 Operating Systems Lecture 5 Scheduling Today

  • Slides: 23
Download presentation
CPSC 457 Operating Systems Lecture 5 Scheduling

CPSC 457 Operating Systems Lecture 5 Scheduling

Today Updates Assignment 1 Assignment 2 Concept Review Scheduling Processes Concepts Algorithms CPSC 457

Today Updates Assignment 1 Assignment 2 Concept Review Scheduling Processes Concepts Algorithms CPSC 457 - Tyson Kendon 2016 1

Assignment 1 CPSC 457 - Tyson Kendon 2016 2

Assignment 1 CPSC 457 - Tyson Kendon 2016 2

Assignment 2 CPSC 457 - Tyson Kendon 2016 3

Assignment 2 CPSC 457 - Tyson Kendon 2016 3

Concept Overview CPSC 457 - Tyson Kendon 2016 4

Concept Overview CPSC 457 - Tyson Kendon 2016 4

Last Time Processes Creation Termination Threads Information Context Switching Split Execution from Resources Life

Last Time Processes Creation Termination Threads Information Context Switching Split Execution from Resources Life Span Implementation CPSC 457 - Tyson Kendon 2016 5

Scheduling Processes Scheduling Concepts Scheduling Timing Preemptive vs Nonpreemptive Types of Scheduling Algorithms Scheduling

Scheduling Processes Scheduling Concepts Scheduling Timing Preemptive vs Nonpreemptive Types of Scheduling Algorithms Scheduling Algorithm Goals and Metrics Scheduling Algorithms First Come, First Served Shortest Job First Exponential Average Priority Scheduling Round-Robin Multi-Queue Scheduling And many more! CPSC 457 - Tyson Kendon 2016 6

Scheduling Concepts Deciding which process should be running Defining process behaviour CPU Burst Length

Scheduling Concepts Deciding which process should be running Defining process behaviour CPU Burst Length Deciding when to schedule Do we interrupt a process once it’s running Preemptive vs Nonpreemptive CPSC 457 - Tyson Kendon 2016 7

Scheduling Goals and Metrics Fairness Policy Enforcement Balance Throughput Turnaround Time CPU Utilization Response

Scheduling Goals and Metrics Fairness Policy Enforcement Balance Throughput Turnaround Time CPU Utilization Response Time Wait Time Proportionality Meeting Deadlines e m i Predictability T al Re CPSC 457 - Tyson Kendon 2016 8

Types of Scheduling Algorithm Batch Interactive Real Time CPSC 457 - Tyson Kendon 2016

Types of Scheduling Algorithm Batch Interactive Real Time CPSC 457 - Tyson Kendon 2016 9

Scheduling Algorithms First Come, First Served Shortest Job First Priority Scheduling Round-Robin Multi-Queue Scheduling

Scheduling Algorithms First Come, First Served Shortest Job First Priority Scheduling Round-Robin Multi-Queue Scheduling Guaranteed Scheduling Lottery Scheduling Fair-Share scheduling CPSC 457 - Tyson Kendon 2016 10

Break time

Break time

First Come, First Served Algorithm • As processes arrive to be scheduled, they are

First Come, First Served Algorithm • As processes arrive to be scheduled, they are added to the end of the queue. • When it’s time to schedule a new process, the scheduler picks the head of the queue. CPSC 457 - Tyson Kendon 2016 12

First Come, First Served Comments • Nonpreemptive • Bad for an interactive system •

First Come, First Served Comments • Nonpreemptive • Bad for an interactive system • Turnaround and Wait Times based on the sequence of arrival • Easy to program • Tends to bunch up I/O bound processes CPSC 457 - Tyson Kendon 2016 13

Shortest Job First Algorithm • As processes arrive to be scheduled, they are added

Shortest Job First Algorithm • As processes arrive to be scheduled, they are added to the end of the queue. • When it’s time to schedule a new process, the scheduler picks the process with the shortest CPU burst next. CPSC 457 - Tyson Kendon 2016 14

Shortest Job First Problem • We don’t know how long each CPU burst is

Shortest Job First Problem • We don’t know how long each CPU burst is going to be. • But we’re good at estimating things: CPSC 457 - Tyson Kendon 2016 15

Exponential Average for CPU Burst Time ♣�n+1 = ♥�tn + (1 - ♥�) ♣�n

Exponential Average for CPU Burst Time ♣�n+1 = ♥�tn + (1 - ♥�) ♣�n e Pow to in rpo c… a nm ♣�n - the predicted burst time for the nth burst of the process ♣tn - the actual burst time for the nth burst of the process ♥�- weight to bias the average more to the last burst or the history CPSC 457 - Tyson Kendon 2016 16

Shortest Job First Comments • Preemptive or Nonpreemptive • Can lead to starvation •

Shortest Job First Comments • Preemptive or Nonpreemptive • Can lead to starvation • Provably optimal (if all jobs arrive at the same time) • Slightly harder to program • Need to implement burst estimation and track for processes CPSC 457 - Tyson Kendon 2016 17

Priority Scheduling Algorithm • Processes are assigned different priorities (somehow) • A process is

Priority Scheduling Algorithm • Processes are assigned different priorities (somehow) • A process is added to the queue for it’s priority • The scheduler selects (fcfs, sjf or someotherway) from all of the processes in the highest priority queue CPSC 457 - Tyson Kendon 2016 18

Priority Scheduling Comments • • • Preemptive or Nonpreemptive Can lead to starvation We

Priority Scheduling Comments • • • Preemptive or Nonpreemptive Can lead to starvation We can use aging to stave off starvation Adheres to system policy Still fairly easy to implement CPSC 457 - Tyson Kendon 2016 19

Round Robin Algorithm • Start with FCFS • Preempt processes after a fixed amount

Round Robin Algorithm • Start with FCFS • Preempt processes after a fixed amount of CPU time (called the Time Quantum or the Time Slice) • If you stopped a process for using all of it’s time, put it on the back of the queue. CPSC 457 - Tyson Kendon 2016 20

Round Robin Comments • Preemptive • Have to factor in context switch time •

Round Robin Comments • Preemptive • Have to factor in context switch time • We can adjust the quantum to alter the behaviour of the system • Generally want the quantum to long enough that the majority of processes (I/O bound) finish within it CPSC 457 - Tyson Kendon 2016 21

Where Next? More Scheduling Real World Implementations Memory Management CPSC 457 - Tyson Kendon

Where Next? More Scheduling Real World Implementations Memory Management CPSC 457 - Tyson Kendon 2016 22