CPU scheduling 6. Schedulers, CPU Scheduling 6.1. Schedulers Short term, Long term, Medium term schedulers. 6.2. CPU Scheduling 6.2.1. CPU- I/O burst cycle 6.2.2. CPU scheduler 6.2.3. Dispatcher 6.3. Scheduling Criteria 6.4. Scheduling Algorithms First Come First Served. Shortest Job First. Priority Scheduling. Round Robin. Multilevel queues, Multilevel feedback queues. Textbook Silberschatz 6th ed. Chapter 6
CPU scheduling Schedulers Long Term Scheduler Is called not so often. Controls the degree of multiprogramming (# of processes in memory). Good mix of I/O bound and CPU bound proc. ? Some systems do not have long term scheduler. ? Short Term (CPU) Scheduler Is called very often Decides how to pick a process Does Context Switching Must be very fast A process migrates between the various scheduling queues throughout its lifetime.
Medium Term Scheduling CPU scheduling Medium Term Scheduling
Medium Term Scheduling CPU scheduling Medium Term Scheduling Some operating systems, such as time-sharing systems, may introduce an additional, intermediate level of scheduling. This medium-term scheduler, removes processes from memory (and from active contention for the CPU), and thus reduces the degree of multiprogramming.
CPU scheduling CPU-I/O Burst Cycle Scheduling is a fundamental operating-system function. Almost all computer resources are scheduled before use. The CPU is, of course, one of the primary computer resources. Thus, its scheduling is central to operating-system design. The success of CPU scheduling depends on the following observed property of processes:
Histogram of CPU-burst Times CPU scheduling CPU-I/O Burst Cycle Histogram of CPU-burst Times I/O Bound program many very short CPU bursts CPU Bound program a few very long CPU bursts
Preemptive and Non-Preemptive CPU scheduling Preemptive and Non-Preemptive CPU scheduler Selects from among the processes in ready queue, and allocates the CPU to one of them Queue may be ordered in various ways CPU scheduling decisions may take place when a process: 1. Switches from running to waiting state 2. Switches from running to ready state 3. Switches from waiting to ready Terminates Scheduling under only 1 and 4 is nonpreemptive Otherwise scheduling is preemptive
Preemptive and Non-Preemptive CPU scheduling Preemptive and Non-Preemptive
CPU scheduling Dispatcher Dispatcher – Does the remaining tasks after the process selection – Gives control to the process. Context Switch Switching between Kernel-User modes Jumping to the proper location in the program to continue it. Dispatch latency - stop one process and start another – Should be very short