OS, , Part II CPU Scheduling Department of Computer Engineering, PSUWannarat Suntiamorntut
OS, Department of Computer Engineering, PSUWannarat Suntiamorntut Basic Concepts The basic problem is as follows: How can OS schedule the allocation of CPU cycles to processes in system, to achieve “good performance”? Scheduling is a fundamental OS function.
OS, Department of Computer Engineering, PSUWannarat Suntiamorntut CPU- I/O Burst Cycle cpu burst I/O burst cpu burst I/O burst CPU burst I/O burst
OS, Department of Computer Engineering, PSUWannarat Suntiamorntut Preemptive Scheduling process switches from running -> waiting (I/O request,.. ) process switches from running -> ready (interrupt occur) process switches from waiting -> ready (completion of I/O) process terminate
OS, Department of Computer Engineering, PSUWannarat Suntiamorntut Dispatcher Module to give control of CPU to process selected by short-term scheduler. This function involves : - Switching context - Switching to user mode - Jumping to the proper location in user program to restart that program
OS, Department of Computer Engineering, PSUWannarat Suntiamorntut Scheduling Criteria CPU utilization : in a real system, it range from percents. Throughput : number of processes that are completed. Turnaround time : interval from time of submission to completion. Waiting time : time that a process spends waiting in ready queue. Response time : time from the submission of a request until the first response.
OS, Department of Computer Engineering, PSUWannarat Suntiamorntut Scheduling Algorithms First-come, First-served Scheduling (FCFS) mange with FIFO ProcessBurst Time P124 P23 P33 P1 P2 P Average wait time = 17
OS, Department of Computer Engineering, PSUWannarat Suntiamorntut FCFS ProcessBurst Time P124 P23 P P3 P2 P1 Average wait time = 3
OS, Department of Computer Engineering, PSUWannarat Suntiamorntut Scheduling Algorithm Shortest-Job-First Scheduling mange with SJF, minimum average wait time ProcessBurst Time P16 P28 P37 P P4 P1 P3 P2 Average wait time = 7
OS, Department of Computer Engineering, PSUWannarat Suntiamorntut Shortest-remaining-time-First Scheduling mange with SJF, minimum average wait time ProcessArrival timeBurst Time P108 P214 P329 P P1 P2 P4 P1P3 Average wait time = 6.5 Scheduling Algorithm
OS, Department of Computer Engineering, PSUWannarat Suntiamorntut Scheduling Algorithm Priority Scheduling scheduling in term of high priority and low. ProcessBurst TimePriority P1103 P211 P323 P414 P552 P2 P5 P1 P3 P Average wait time = 8.2
OS, Department of Computer Engineering, PSUWannarat Suntiamorntut Scheduling Algorithm Round-Robin Scheduling round-robin (RR), especially for time-sharing. - time quantum, time slice = small unit of time ProcessBurst Time P124 P23 P33 If time quantum = 4 P1 P2 P3P1 P1 P1 P1 P Average wait time = 5.66
OS, Department of Computer Engineering, PSUWannarat Suntiamorntut Scheduling Algorithm Multilevel Queue Scheduling System process Highest priority Interactive process Interactive editing process Bath process student process lowest priority
OS, Department of Computer Engineering, PSUWannarat Suntiamorntut Scheduling Algorithm Multilevel Feedback Queue Scheduling Quantum = 8 Quantum = 16 FCFS
OS, Department of Computer Engineering, PSUWannarat Suntiamorntut Scheduling Algorithm ProcessBurst TimePriorityArrival time P11030 P2512 P3433 P4145 P5327 Do the example
OS, Department of Computer Engineering, PSUWannarat Suntiamorntut Next Lecture in Process Synchronization