Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
the dispatcher operates here
CPU scheduling requires an algorithm to determine which process to dispatch next Scheduling algorithms include: First-Come, First-Served (FCFS) Shortest-Job-First (SJF) Round-Robin (RR) Priority Multilevel Queue (MQ)
Preemptive scheduling preempts a running process before its time slice expires Or it preempts a process because its time slice has expired Non-preemptive scheduling gives a process exclusive uninterrupted access to the CPU for the entirety of its execution process
Compare scheduling algorithms by measuring CPU utilization – keep CPU as busy as possible Throughput – maximize the number of processes that complete their execution per unit time Turnaround time – minimize the elapsed time to fully execute a particular process Waiting time – minimize the elapsed time a process waits in the ready queue
RR is a preemptive algorithm that gives all ready processes a fair time slice of CPU time Using a time slice of 2 ms.... time ProcessCPU Burst Time P1P1 6 ms P2P2 2 ms P3P3 5 ms P1P1 P3P3 P2P P3P P1P1 10 P1P1 P3P3
Associate a priority number with each process The dispatcher selects the process with the highest priority For multiple ready processes with identical priority numbers, use FCFS (or...) Key problem is starvation ▪ Overcome starvation by aging, increasing the priority of a process as it ages
(use this one for Project #1) Is priority scheduling preemptive or non-preemptive? Non-preemptive priority scheduling places higher-priority processes at the head of the queue Preemptive priority scheduling requires a running process to be interrupted and preempted upon the arrival of a higher-priority process process
Operating systems that support priority schemes are often called multiclass systems use a separate scheduling algorithm for each queue
Assign processes to multiple queues, each with its own scheduling algorithm
Dynamically assign processes to multiple queues based on actual CPU burst times i.e. feedback quantum is synonymous with time slice
Apply the FCFS, SJF, RR, and Preemptive Priority scheduling algorithms to this table: For RR, use a time slice of 10 ms Calculate the wait and turnaround times of each process, as well as overall averages ProcessArrival TimeCPU Burst TimePriority P1P1 045 ms5 P2P2 05 ms3 P3P3 20 ms15 ms1 P4P4 60 ms25 ms2 lower number indicates a higher priority recalculate using context switch time t cs = 20 μs recalculate using context switch time t cs = 20 μs