Uniprocessor Scheduling Scheduling of Processes
Types of Scheduling Long-term (least frequent decision) Medium-term When an new process is created, will it be admitted to the ready queue? Controls degree of multiprogramming (balances response/turnaround time and processor utilization) Can consider priority, expected execution time, I/O requirements, etc. Responds to requests for interactive sessions Medium-term Which processes should have frames allocated? Also affects degree of multiprogramming Already discussed in context of memory management Short-term (most frequent decision) Which process should execute next? Focus of this lesson I/O – next lesson
Short-Term Scheduling Performed by part of kernel referred to as dispatcher Invoked in response to Timer interrupts I/O interrupts System calls Signals (e.g. from semaphores) Some long-term and medium-term scheduling events
Short-Term Scheduling Criteria Performance Related Other User Oriented Turnaround time Response time Deadlines Predictability System Oriented Throughput Processor utilization Fairness Enforcing priorities Balancing resources
Short Term Scheduling Policies Can be described in terms of Selection function Decision mode
Selection Function Determines which of the ready processes to execute Example inputs: s: total service time required by the process e: time spent so far in execution w: time spent so far in system (executing and waiting) May also consider resource management or other execution characteristics of processes
Decision Mode Specifies times at which selection function is invoked Nonpreemptive Selection function used only when running process Blocks for I/O Requests OS service Terminates Preemptive Selection function is used at other times Timer interrupts Process admission Selection function is used when a process blocks terminates enters the system time slice expires.
Process Scheduling Example
FCFS/FIFO Policy Nonpreemptive Always select the process that has been in the ready queue the longest 5 10 15 20 A B C D E
Round Robin Policy Preemptive -- processes run for a time-slice or quantum Always select the process that has been in the ready queue the longest 5 10 15 20 A B C D E
Virtual Round Robin Policy I/O-bound processes typically do not use a complete quantum Put processes with pending I/O in auxiliary queue, remember how much time remains in their time slice Give preference to processes in auxiliary queue Allow to run for remainder of time slice
Shortest Process Next Policy Nonpreemptive Always select process with shortest estimated processing time 5 10 15 20 A B C D E
Shortest Remaining Time Policy Preemptive When a new process enters the system, or when the running process leaves the running state Select process with shortest estimated remaining processing time 5 10 15 20 A B C D E
HRRN Policy HRRN = Highest Response Ratio Next Nonpreemptive Always select the process that has the highest value of A B C D E 5 10 15 20
Multi-Level Feedback Policy Preemptive based on time quantum Maintain a ready queue for each priority When a process is preempted, move it to a lower priority queue Note: If there are no processes waiting, don’t preempt current process With quantum = 1, long processes will have very large turnaround time Give processes from queue RQi quantum = 2i
Quantum = 1 5 10 15 20 A B C D E
Quantum = 2i [[[Need to redo figure]]]