
























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Process scheduling topics covered 1.basic concepts 2.Scheduling criteria 3.Scheduling algorithms
Typology: Lecture notes
1 / 32
This page cannot be seen from the preview
Don't miss anything!
(^) Basic Concepts (^) Scheduling Criteria (^) Scheduling Algorithms
(^) Maximum CPU utilization obtained with multiprogramming (^) CPU–I/O Burst Cycle – Process execution consists of a cycle of CPU execution and I/O wait (^) CPU burst followed by I/O burst (^) CPU burst distribution is of main concern
Large number of short bursts Small number of longer bursts
(^) When scheduling takes place only under circumstances 1 and 4, the scheduling scheme is nonpreemptive. (^) Otherwise, it is preemptive. (^) Under Nonpreemptive scheduling, once the CPU has been allocated to a process, the process keeps the CPU until it releases it either by terminating or by switching to the waiting state. (^) Virtually all modern operating systems including Windows, MacOS, Linux, and UNIX use preemptive scheduling algorithms.
(^) Preemptive scheduling can result in race conditions when data are shared among several processes. (^) Consider the case of two processes that share data. While one process is updating the data, it is preempted so that the second process can run. The second process then tries to read the data, which are in an inconsistent state. (^) This issue will be explored in detail in Chapter 6.
(^) CPU utilization – keep the CPU as busy as possible (^) Throughput – # of processes that complete their execution per time unit (^) Turnaround time – amount of time to execute a particular process (^) Waiting time – amount of time a process has been waiting in the ready queue (^) Response time – amount of time it takes from when a request was submitted until the first response is produced.
(^) Max CPU utilization (^) Max throughput (^) Min turnaround time (^) Min waiting time (^) Min response time
Suppose that the processes arrive in the order: P 2 , P 3 , P 1 (^) The Gantt chart for the schedule is: (^) Waiting time for P 1 = 6 ; P 2 = 0 ; P 3 = 3 (^) Average waiting time: (6 + 0 + 3)/3 = 3 (^) Much better than previous case (^) Convoy effect - short process behind long process (^) Consider one CPU-bound and many I/O-bound processes P (^1) 0 3 6 30 P 2 P (^3)
Shortest-Job-First (SJF) Scheduling (^) Associate with each process the length of its next CPU burst (^) Use these lengths to schedule the process with the shortest time (^) SJF is optimal – gives minimum average waiting time for a given set of processes (^) The difficulty is knowing the length of the next CPU request (^) Could ask the user
ProcessArriva l Time Burst Time P 1 0.0 6 P 2 2.0 8 P 3 4.0 7 P 4 5.0 3 (^) SJF scheduling chart (^) Average waiting time = (3 + 16 + 9 + 0) / 4 = 7 P (^3) 0 3 24 P 4 P (^1) 9 16 P (^2)
(^) Can only estimate the length – should be similar to the previous one (^) Then pick process with shortest predicted next CPU burst (^) Can be done by using the length of previous CPU bursts, using exponential averaging (^) Commonly, α set to ½
Examples of Exponential Averaging (^) = (^) n+1 =^ n (^) Recent history does not count (^) = (^) n+1 =^ ^ t n (^) Only the actual last CPU burst counts (^) If we expand the formula, we get: n +1 = t n +(1 - ) tn -1 + … +( 1 - )j^ tn - j + … +( 1 - )n^ +1^ 0 (^) Since both and (1 - ) are less than or equal to 1, each successive term has less weight than its predecessor
Example of Shortest-remaining-time- first (^) Now we add the concepts of varying arrival times and preemption to the analysis ProcessA arri Arrival TimeT Burst Time P 1 0 8 P 2 1 4 P 3 2 9 P 4 3 5 (^) Preemptive SJF Gantt Chart (^) Average waiting time = [(10-1)+(1-1)+(17-2)+(5-3)]/4 = 26/4 = 6. P (^4) 0 1 26 P 1 P (^2) 10 P 1 P (^3) 5 17