Cs238 CPU Scheduling Dr. Alan R. Davis. CPU Scheduling The objective of multiprogramming is to have some process running at all times, to maximize CPU.
Published byModified over 5 years ago
Presentation on theme: "Cs238 CPU Scheduling Dr. Alan R. Davis. CPU Scheduling The objective of multiprogramming is to have some process running at all times, to maximize CPU."— Presentation transcript:
CPU Scheduling The objective of multiprogramming is to have some process running at all times, to maximize CPU utilization. A process is executed until it must wait, usually for completion of some I/O request. The OS then switches the process with another ready process which can use the CPU. Processes alternate between CPU bursts and I/O bursts.
Scheduling Algorithms What criteria should be used? CPU Utilization: keep the CPU as busy as possible Throughput: maximize the number of processes completed per unit of time Turnaround time: minimize the time interval between submission and completion of processes Waiting time: minimize the time a process remains in the waiting queue Response time: minimize the time between submission of a process and the first response
Scheduling Algorithms First-come, First-served (FCFS) Works as its name implies. Example (Process, Burst Time): (P1, 24), (P2, 3), (P3, 3) If they arrive in the order P1, P2, P3, then the average waiting time is (0 + 24 + 27)/3 = 17 If they arrive in the order P2, P3, P1, then the average waiting time is (6 + 0 + 3)/3 = 3
Scheduling Algorithms Shortest-Job-First (SJF) Choose the job with the next shortest CPU burst Example (Process, Burst Time): (P1, 6), (P2, 8), (P3, 7), (P4, 3) They are processed in the order P4, P1, P3, P2 then the average waiting time is (3 + 16 + 9 + 0)/4 = 7
Scheduling Algorithms Priority Scheduling Associate a priority with each process, and schedule the process with the highest priority next. Equal priority processes can be scheduled FCFS. SJF is priority scheduling with shorter jobs having higher priority. Example (Process, Burst Time, Priority): (P1, 10, 3), (P2, 1, 1), (P3, 2, 3), (P4, 1, 4), (P5, 5, 2) They are processed in the order P2, P5, P1, P3, P4 then the average waiting time is (6 + 0 + 16 + 18 + 1)/5 = 8.2
Scheduling Algorithms Round-Robin (RR) A fixed time quantum is chosen, then each process is given the CPU for that amount of time, then placed at the end of the queue if necessary.
Scheduling Algorithms Multilevel Queue Scheduling For example, create queues for 1. System processes 2. Interactive processes 3. Interactive editing processes 4. Batch processes 5. Student processes
Scheduling Algorithms Multilevel Feedback Queues Allows a process to move between queues
Multiple-Processor Scheduling Load sharing schedules processes among several identical processors. Each processor could have its own ready queue, but then some processors must be idle. The processors could share a single ready queue. One processor could be appointed as the scheduler for all of them (asymmetric multiprocessing).
Real-Time Scheduling Hard real-time systems are required to complete a critical task within a guaranteed amount of time. The scheduler must then know that time requirement for each process. It then either accepts or rejects the process if it can’t meet the requirement. If the system has secondary storage or virtual memory, the scheduler can not know how long the process will take.
Real-Time Scheduling A soft real-time system requires that critical processes receive priority over less important ones. The system must have priority scheduling. Steps must be taken to prevent starvation of less important processes. Priority of real-time processes must not degrade over time.
Real-Time Scheduling Dispatch Latency Dispatch latency must be low. System calls must be preemptible. Preemption points can be inserted into long duration system calls, so that a ready high priority process can be detected. Or we could make the entire kernel preemptible. We would need to make all kernel data structures protected through various synchronization mechanisms.
Algorithm Evaluation Choose the important criteria, then evaluate the various algorithms under consideration. Deterministic modeling: calculate the cost of each algorithm on a given set of input data Queuing models: measure the distribution of CPU and I/O bursts, as well as the arrival times of processes, and use formulas and concepts of queuing-network theory to calculate other quantities Simulations: program a model of the computer system, generate test data randomly Implementation: code all the algorithms, include them in the OS, and test under real conditions