Process SchedulingIntroductionTopics for discussionThe CPU-I/O CycleCPU/IO BurstsMotivationSlide 7Types of schedulingScheduling Algorithm GoalsScheduling in Batch Systems (1)Scheduling in Batch Systems (2)Classification of Scheduling ActivityShort-term schedulingShort-term scheduling criteriaPriority queuesPolicy versus MechanismAlternative scheduling policiesCase-studyFirst Come First Served (FCFS)FCFS drawbacksRound robinRound-RobinTime Quantum for Round RobinRound Robin: critiqueShortest process nextShortest process next (contd.)Shortest Process Next (SPN)Estimating the required CPU burstSlide 29Exponentially Decreasing CoefficientsSlide 31Shortest Process Next: critiqueOther policiesScheduling in Real-Time SystemsSummary01/14/19 1Process SchedulingB.Ramamurthy01/14/19 2IntroductionAn important aspect of multiprogramming is scheduling. The resources that are scheduled are IO and processors. The goal is to achieveHigh processor utilizationHigh throughputnumber of processes completed per unit timeLow response timetime elapse from the submission of a request to the beginning of the response01/14/19 3Topics for discussionMotivationTypes of schedulingShort-term schedulingVarious scheduling criteriaVarious algorithmsPriority queuesFirst-come, first-servedRound-robinShortest process firstShortest remaining time and othersQueuing Model and Performance Analysis01/14/19 4The CPU-I/O CycleWe observe that processes require alternate use of processor and I/O in a repetitive fashionEach cycle consist of a CPU burst (typically of 5 ms) followed by a (usually longer) I/O burst A process terminates on a CPU burstCPU-bound processes have longer CPU bursts than I/O-bound processes01/14/19 5CPU/IO BurstsBursts of CPU usage alternate with periods of I/O waita CPU-bound processan I/O bound process01/14/19 6MotivationConsider these programs with processing-component and IO-component indicated by upper-case and lower-case letters respectively. A1 a1 A2 a2 A30 30 50 80 120 130 ===> JOB A B1 b1 B20 20 40 60 ====> JOB B C1 c1 C2 c2 C3 c3 C4 c4 C5 0 10 20 60 80 100 110 130 140 150 =>JOB C01/14/19 7MotivationThe starting and ending time of each component are indicated beneath the symbolic references (A1, b1 etc.)Now lets consider three different ways for scheduling: no overlap, round-robin, simple overlap.Compare utilization U = Time CPU busy / Total run time01/14/19 8Types of schedulingLong-term : To add to the pool of processes to be executed.Medium-term : To add to the number of processes that are in the main memory.Short-term : Which of the available processes will be executed by a processor?IO scheduling: To decide which process’s pending IO request shall be handled by an available IO device.01/14/19 9Scheduling Algorithm Goals01/14/19 10Scheduling in Batch Systems (1)An example of shortest job first scheduling01/14/19 11Scheduling in Batch Systems (2)Three level scheduling01/14/19 12Classification of Scheduling ActivityLong-term: which process to admitMedium-term: which process to swap in or outShort-term: which ready process to execute next01/14/19 13Short-term schedulingShort-term scheduler is invoked whenever an event occurs that may lead to the interruption of the current process or that may warrant the preemption of the current process in favor of another.Clock-interrupts, IO interrupts, OS calls, signals, real-time system policies are some such events.The main objective of short-term scheduling is to allocate processor time in such a way as to optimize one or more aspects of system behavior.01/14/19 14Short-term scheduling criteriaUser-oriented: Response time: is the elapsed time between the submission of a request until the response begins to appear at the output.Typical goal of such system should be maximize the number of users who would experience average or better than average response time.System-oriented:Throughput: is the rate at which processes are completed.Focus is on the efficient and effective use of processors.Utilization : % of time a processor is kept busy.01/14/19 15Priority queuesAn important aspect of scheduling is the use of priorities. One ready queue for each priority level;Or one priority queue. Insertion into the queue is done according to the priority.When released from a blocked queue, a process enters a queue according to its priority.01/14/19 16Policy versus MechanismSeparate what is allowed to be done with how it is donea process knows which of its children threads are important and need priorityScheduling algorithm parameterizedmechanism in the kernelParameters filled in by user processespolicy set by user process01/14/19 17Alternative scheduling policies A selection function determines which among the ready processes is next selected for execution Selection functions are based on one or more of these items:1) w - time spent in system so far, waiting and executing.2) e - time spent on execution so far.3) s - total service time required by the process.4) resources required by the processWhen to apply the selection function is dependent on whether a preemptive or non-preemptive scheduling is used.01/14/19 18Case-studyLets study each of policies with a sample problem:Process Arrival time Service time===========================1 0 32 2 63 4 44 6 55 8 201/14/19 19First Come First Served (FCFS)Selection function: the process that has been waiting the longest in the ready queue (hence, FCFS)Decision mode: nonpreemptivea process run until it blocks itself01/14/19 20FCFS drawbacksA process that does not perform any I/O will monopolize the processorFavors CPU-bound processesI/O-bound processes have to wait until CPU-bound process completesThey may have to wait even when their I/O are completed (poor device utilization)we could have kept the I/O devices busy by giving a bit more priority to I/O bound processes01/14/19 21Round robinCPU is time-sliced among the ready processes.Time-quantum slightly higher than the typical interaction time.Appears fair but tends to favor CPU-bound jobs.01/14/19 22Selection function: same as FCFSDecision mode: preemptivea process is allowed to run until the time slice period (quantum, typically from 10 to 100 ms) has expiredthen a clock interrupt occurs and the running process is put on the ready
View Full Document