19
Multiprocessor Scheduling • Brief Review – Loosely Coupled (cluster) • Separate main memory and I/O devices – Functionally Specialized • Dedicated I/O processors – Tightly Coupled • Share main memory, O.S. • Granularity – Independent Processes – Very Coarse (>2,000 instructions) Make application – Coarse (200-2,000 instructions) • Many Unix pipe uses – Medium (20-200 instructions) • Threads within a application – Fine (<20 instructions)

Chap10(1)

Embed Size (px)

DESCRIPTION

OS SLIDES

Citation preview

  • Multiprocessor SchedulingBrief ReviewLoosely Coupled (cluster)Separate main memory and I/O devicesFunctionally SpecializedDedicated I/O processorsTightly CoupledShare main memory, O.S.GranularityIndependent ProcessesVery Coarse (>2,000 instructions)Make applicationCoarse (200-2,000 instructions)Many Unix pipe usesMedium (20-200 instructions)Threads within a applicationFine (
  • Design IssuesAssigning processes to processorsAre processes/threads assigned to processors?Who handles the assignment?Master/SlaveSingle processor handles O.S. functionsTends to become a bottleneckPeerO.S. can run on any processorMore complicated operating systemGenerally use simple schemesOverhead is a greater problemThreads add additional concernsGenerally response time is more important than CPU utilization

  • Process SchedulingResponse time is much less sensitive to the algorithm usedFigure 10.1 (page 443)Thread SchedulingLoad SharingGang SchedulingDedicated Processor AssignmentDynamic schedulingLoad SharingSelect threads from a global queueAvoids idle processorsQueue may be a bottleneckDoesnt take advantage of local cacheMay not schedule interacting threads at the same timeWidely used

  • Scheduling 2Gang SchedulingSchedule related threads on processors to run at the same timeLess overhead since we schedule multiple processors at onceInteracting threads are more likely to be running and ready to interactHave to allocate processorsDedicated Processor AssignmentLike gang scheduling, but never switch between applicationsBest to have # threads = # processorsDynamic SchedulingVary the number of threadsJob uses the processors in its partitionAppears better than gang scheduling

  • Real-time SchedulingVery common in embedded systemsRequire results be produced before specified deadlinesHard real-time: missed deadlines result in damage or deathSoft real-time: missed deadlines may result in lower performance, but can be toleratedMost real-time systems are soft real-timeCharacteristicsDeterministicResponsivenessUser ControlReliabilityFail-Soft operation

  • CharacteristicsDeterministicExtent that it performs operations at fixed intervalsRelated to the ability to process external interruptsResponsivenessHow long does the system take to respond to an interrupt?Includes:Time to handle the interrupt and switch to the ISRTime required for the ISREffects of nested interruptsUser ControlMore control over prioritiesAlso can control swapping/paging

  • Characteristics 2ReliabilityVery important in real-time systemsX-29 flight control system Plane becomes uncontrollable in 2 secondsFail-Soft OperationAbility to handle system failures by gently reducing performanceIf a shutdown cant be avoided, then try to do so gracefully(sort of) Example: Fighter flight-control system that adjusts for damage to the systemStability - ability to meet the most important deadlines even if lower priority deadlines cannot be met.

  • Real-Time SystemsFeaturesFast process/thread switchSmall size/minimal functionalityAbility to respond to interrupts quicklyMultitasking with IPC tools like semaphores, signals, and eventsUse of special sequential files that can accumulate data at a fast ratePreemptive scheduling with priorityMinimize time with interrupts offPrimitives to delay tasks for a fixed amount of time, pause/resume tasksSpecial alarms and timeoutsShort-term scheduler is criticalNeed to have priorities, preemption

  • Real-time SchedulingScheduling approaches:Static Table-drivenSchedule periodic tasks in advanceChanges result in redoing scheduleStatic Priority-driven preemptiveTakes advantage or priority-based schedulerGive higher priorities to real-time tasksBased on time constraints, importanceDynamic planning-basedTry to revise schedule when a task arrivesDynamic Best EffortAssign priorities based on the task, such as earliest deadlineUsed by many real-time systemsEasy to implementHard to know if a deadline will be met

  • Deadline SchedulingImportance is meeting deadlines, not mere speed in handling eventsUse more task information:Ready Time (when it is ready to start)Starting Deadline (begin by )Completion Deadline (finish by )Processing Time (time to execute)Resource RequirementsPriority (relative importance)Subtask structureParts of a task may be optionalParts of a task may have lower priorityGenerally best to schedule task with the earliest deadlineIf we dont allow preemption, we may need to let the CPU sit idle and wait for a task to arrive

  • Deadline SchedulingTable 10.2 (pg. 456) Execution profile of two periodic tasksProcess AArrives02040Execution Time101010End by204060Process BArrives050100Execution Time252525End by50100150Figure 10.5 (pg. 457) Scheduling of two periodic tasks

  • Deadline SchedulingTable 10.3 (pg. 459) Execution profile of five aperiodic tasks

    Figure 10.6 (pg. 458) Scheduling of aperiodic tasks (no preemption)

    ProcessArrival TimeExecution TimeStarting DeadlineA1020110B202020C402050D502090E602070

  • Rate Monotonic SchedulingParametersT = Rate between arrivals of the taskC = Time required to do calculationGive shortest-period task the highest priorityIf S Ci/Ti n(21/n - 1), all tasks can be successfully scheduledn(21/n - 1) 0.693 as n This formula is conservative (90% utilization can be done in practice)This formula also holds for earliest deadline schedulingRMS generally used over DeadlinePerformance difference smallHandles soft real-time parts betterStability is easier to achieve

  • Linux SchedulingNormal kernel code nonpreemptibleTimer interrupts during kernel code sets a flag need_resched that causes rescheduling at the end of the kernel callOnly need to avoid accessing user memory and disable interrupts during critical data structure operationsInterrupt Service routinesTop Half Runs with equal or lower-priority interrupts disabledBottom Half Allow all interruptsScheduler ensures a bottom half doesnt interrupt itselfKernel can disable selected bottom halves during critical sections

  • Linux PrioritiesBased on scheduling creditsSelect process with highest number of creditsLoses one credit for each timer interruptSuspended when no credits remainingIf no runnable processes have credits, assign new credits to all processes:Credits = Credits/2 + priorityMultiprocessor SchedulingFirst supported in 2.0.x kernelFiner locking, threaded subsystems in 2.3.x kernelScheduler gives bonus if a thread is rescheduled on the same CPU

  • Linux Real-Time SchedulerLimited by restrictions in preempting kernelThree scheduling classesSCHED_FIFO: FIFO real-timeNot interrupted unless:Higher priority FIFO thread is readyTread blocks (such as I/O)Thread voluntarily yields CPUIf interrupted, put in a queueIf it is ready and has higher priority, the other thread is preemptedSCHED_RR: round-robin real-timeLike FIFO, but with a time quantumAt the end of the quantum, another equal or higher-priority thread is scheduledSCHED_OTHER: non-real-timeOnly run when no real-time thread is ready

  • Unix SVR4 SchedulingTwo major modifications:Addition of a preemptible static priority scheduler with three priority rangesReal-time (159 - 100)Kernel (99 - 60)User time-share (59 - 0)Insertion of preemption points into the kernelAllow the kernel to be interrupted at specified safe locationsAll resources are either not in use or locked via semaphoreCombination allows real-time processes to run before the kernel, and preempt the kernel when necessary

  • Dispatch QueuesDispq - set of dispatch queuesOne for each priority levelRound-robin within each levelDqactmapOne bit per priority levelSet to 1 if the queue contains one or more processKprunrun - used to note that a real-time process is readyChecked at kernel preemption pointsPriority lowered if uses quantum, raised if it blocks on an event

  • Win2000 PrioritiesPriority-driven preemptive scheduler32 total priority levelsReal-time processes use levels 31-16 Other processes use levels 15-0Round-robin within each priority levelProcess base priorityThread base priority Offset from the process base priority (max +/- 2)Thread dynamic priorityVaries from process base priority-2 to 15Raised when the thread blocksLowered when it uses its time quantumMultiprocessor schedulingN-1 highest-priority threads activeOther threads share the remaining processor