Scheduling & Dispatching

Click here to load reader

  • date post

  • Category


  • view

  • download


Embed Size (px)


Scheduling & Dispatching. What is "Scheduling"?. Managing resources and demands for them Determine next "run-user" Determine resources required Add new "run-user" to "ready" list All above usually done in kernel mode "Run-user" Current thread/process that is executing. - PowerPoint PPT Presentation

Transcript of Scheduling & Dispatching

  • Scheduling & Dispatching

  • What is "Scheduling"?Managing resources and demands for themDetermine next "run-user" Determine resources requiredAdd new "run-user" to "ready" listAll above usually done in kernel mode"Run-user"Current thread/process that is executing

  • What is "Dispatching"?Determine user at head of "ready list"Preempt/wait for current run-user to yieldSave state of current run-userLoad state data for new run-userContext switch to new run-user

  • QuestionsHow would you plan a scheduler that runs in user-mode?What problems would you have to handle?Why would you want to run it in user-mode?

  • What is a job?Fixed set of programs (NOT processes)Sort employee recordsCompute wages for each employeePrint checks for all employeesResources pre-specified by job control statementsEmployee DBPayroll DBHigh-speed printerPrograms run in strict sequence

  • How is the scheduler invoked?VoluntaryProcess/thread blocks itself (yields the CPU)Calls schedulerProcesses can yield to each otherProblems-> greed, errorsInvoluntary Pre-emption by interrupt (device/timer)Kernel calls scheduler before/after interrupt is processed, before return to pre-empted user

  • PoliciesIdeallySelectableChangeablePracticallyBuilt into OSCan be changed with versions of OSAdditionallyScheduler can BE the Resource Manager

  • Control Interval timerQuantum or sliceFixed or variableMultiple policies possible in one systemInteractive usersMay become compute-boundBatch usersDeadline productionReal-time process-control systems

  • Policy implimentationMechanism fixedVaries by requirementsCPU usageWait timeJob completion timeControls:Fair shareFavor long/short jobsPrioritiesDeadlines

  • Scheduling VariablesLet P = {pi | 0 i < n}, be a set of processesLet {Pij} = set of threads, j, in PiLet S(pi) {running, ready, blocked}Let t(pi) = required runtime or service timeLet W(pi) = initial wait timeLet TTRnd(pi) = wall clock: endtime start time (turnaround time)Batch Throughput rate = 1/(avg TTRnd)Timesharing response time = W(pi)

  • Optimizing SchedulesCriteriaCPU usageWait timeDeadlinesMethods Restrict # of processes piPre-determine service time (pi) Compute all schedules and choose best

  • Optimization problems(pi) are estimatesSchedule-compute time is O(n2)Only an approximation of optimumNew jobs arrive during processing

  • Estimating CPU Utilizationl = average rate at which processes are placed in the Ready List= arrival rate (arrivals/sec)m = the average service rate 1/ m = the average service time, t(pi), per processr = expected CPU busy time, computed as:r = arrival rate * avg CPU time eachr = l * 1/ m = l / m Notice: must have l < m (i.e., r < 1) What if r approaches 1?

  • Non-preemptive SchedulersUsing the simplified scheduling model: new->ready-> scheduled-> running->doneOnly considers running and ready statesIgnores time in blocked state:New process created when it becomes readyProcess is destroyed when it is blockedOnly looking at small phases of a process

  • Non-Preemptive SchedulersFirst Come First ServedShortest Job NextPriorityDeadline

  • First Come, First ServedSimpleIgnores service timeAverage wait time=simple avg of all W(p)

    Predicted W(p)=WavgWavg=Lw/m + .5/m = (L/m) +1/(2m)

  • Shortest Job NextMinimizes wait timeBad jobs may take excessive timeService times must be known in advanceKnown for batch systems

  • PriorityPre-determined rules requiredLow priority jobs may get poor serviceAddressable viaAgeRe-assesmentOther resource requirements

  • DeadlineBased on required finish timeRequires known runtime

  • Preemptive SchedulingAlmost always by priorityMost common form todayComplex analysisRequires interval timer supportExamples:Round Robin (RR)Round Robin with Overhead (RRO)Multi-level queues

  • Round RobinEach process gets a fixed time slice to run (Time in Queue)Fair shareMost common preemptive scheduler todayOptional placement of new processes: queue vs. ringFor n processes, q CPU units, C contextTotal real time available=n*(q+C)Or q=(T/n)-CC is usually ignored, but should not be

  • RR w/Overhead icludedFixed overhead for C added between slicesChanges average performance time

  • Multi-level QueuesMore than 1 ready listInteractiveLarge batchSmall batchCompute boundTop-level queue must clear before next level runsWithin a level use RR, etc

  • Current systemsLinuxBSD 4.4Win 2K/NT/XPSee book for descriptions

  • Midterm

    CIMPAC is a voluntary system