CIS250 OPERATING SYSTEMS
Chapter 6 - CPU Scheduling Basic Concepts The objective of multi-programming is have a program running at all times Maximize CPU utilization A process executes until it has to wait for something: O/S takes the CPU away and gives it to another process CPU scheduler is central to O/S design
CPU-I/O Burst Cycle Process CPU, wait… Last instruction, terminate, CPU > short CPU bursts < long CPU bursts
CPU Scheduler Short-term scheduler - when the CPU is idle, a process is selected
Preemptive Scheduling The process scheduler interrupts a process and transfers the CPU to another process –switch from run to ready –switch from wait to ready
Non-Preemptive No interrupts; once a process has the CPU, it runs until there is an I/O interrupt or the process terminates No choice; the process keeps CPU until it releases it –process switches from running to wait –process terminates No timer is required
Dispatcher Gives the control of the CPU to a selected process: –switch context –switch to user mode –jump to a location in the user program and restart Should be fast; the time to stop one process and start another is called dispatch latency
Scheduling Criteria Algorithms are used to schedule the CPU time Consider the properties for each algorithm –CPU utilization –throughput –turnaround time –waiting time –response time
Scheduling Criteria CPU Utilization - keep the CPU busy as much as possible; utilize as close to 100%; realistic % Throughput - the number of processes that complete in a given time; a measurement of the amount of work being done –10 processes per second
Scheduling Criteria Turnaround Time - how long it takes for a process to run; subtract time of completion from submission start time –wait states are included in this time Waiting Time - total amount of time a process spends in the ready queue Response Time - amount of time it takes to get a response
Maximize CPU and throughput Minimize turnaround, wait and response time
Scheduling Algorithms A method for deciding which process in the ready queue should be allocated the CPU
Scheduling Algorithms First-Come, First-Served - non-preemptive; the first process to request the CPU, gets it –uses FIFO queue: PCB is linked to the tail of the queue; the head gets allocated CPU Shortest-Job-First - shortest CPU burst first; if there is a tie, uses FIFO
Scheduling Algorithms Priority Round-Robin
Scheduling Algorithms Multilevel Queue Multilevel Feedback Queue
Other Scheduling Models Multi-Processor Scheduling Real-Time Scheduling
Algorithm Evaluation Deterministic modeling Queuing models Simulations Implementation