chap09
DESCRIPTION
OS SLIDESTRANSCRIPT
-
SchedulingDecide what processes should be executed by the processorLong-term schedulingDeals with creating a new processControls degree of multiprogrammingMay be FCFS or priority basedInteractive systems tend to accept users unless the system is swampedMedium-term schedulingDeals with swapping processes in/outShort-term schedulingWhat process should we run next?Invoked on:clock or I/O interruptsystem call, signal
-
Short-term CriteriaOrientation: User vs. SystemPerformance Related: measurable?Criteria (table 9.2, pg 400):Response Time Start to first outputImportant in interactive systemsTurnaround Time Start to finishDeadlinesPredictability Time doesnt depend on what else is going onThroughput Jobs finished/unit timeProcessor UtilizationFairness Processes treated equallyEnforcing PrioritiesBalancing Resources Try to keep all system resources busy
-
SchedulingPrioritiesAre some processes more important than others?Dont want to starve low-priority processesDecision ModeWill we suspend the currently active process if it can continue?No:NonpreemptiveYes:PreemptiveSome systems (Win 3.1, early Mac) used cooperative multitasking (processes voluntarily give up the CPU)Preemption incurs more O.S. overhead, but prevents monopolizing the processorAlso helps with infinite loops
-
AlgorithmsFirst Come First ServedProcesses queued in order of arrivalRuns until finished or blocks on I/OTends to penalize short processesHave to wait for earlier long processesFavors processor-bound processes I/O processes block quicklyRound RobinFCFS with preemptionSize of ticks affects performanceWant processes to block in one tickFavors processor-bound processesVirtual Round Robin (figure 9.7)Second queue for formerly blocked processes given priorityAt end of time slice, add to end of standard queue
-
Algorithms 2Shortest Process NextSelect process with shortest expected running time (nonpreemptive)Difficult to estimate required timeCan estimate from previous runsTends to be less predictableCan starve long processesShort processes may still wait if a long process has just startedShortest Remaining TimePreemptive version of Shortest Process NextMay switch processes when a new process arrivesStill may starve long processes
-
Algorithms 3Highest Response Ratio NextNonpreemptive, tries to get best average normalized turnaround timeDepends on Response RatioW = time spent waitingS = expected service timeRR = (W + S) / SSelect process with highest RRFeedbackStarts in high-priority queue, moves down in priority as it executesLower-priority queues often given longer time slicesCan starve long processesMove up processes if they wait too long
-
Starvation
Effect on Processes
Overhead
Response Time
Throughput
Preemptive
Selection Function
Characteristics of Various Scheduling Policies (Table 9.3, page 402)
No
Penalizes short and I/O processes
Minimum
May be high
Not Emphasized
No
Max time waiting
FCFS
No
Fair
Low
Good for short processes
Low if quantum too small
At time quantum
-
Round Robin
Possible
Penalizes Long processes
Can be High
Good for short processes
High
No
Shortest process
SPN
Possible
Penalizes long processes
Can be High
Good
High
At arrival
Min time left
SRT
No
Good balance
Can be High
Good
High
No
See Notes
HRRN
Possible
May favor I/O bound processes
Can be High
Not emphaisized
Not emphaisized
At time quantum
See Notes
Feedback
-
Comparison (fig 9.5)P1: arrives at time 0, requires 3 unitsP2: arrives at time 2, requires 6 unitsP3: arrives at time 4, requires 4 unitsP4: arrives at time 6, requires 5 unitsP5: arrives at time 8, requires 2 units
-
Comparison (Table 9.5)
Sheet1
P1P2P3P4P5Mean
Arrival02468
Serv Time36452
FCFS
Finish39131820
Turn.37912128.60
Norm T.1.001.172.252.406.002.56
RR (q=1)
Finish418172015
Turn.4161314710.80
Norm T.1.332.673.252.803.502.71
RR (q=4)
Finish317112019
Turn.3157141110.00
Norm T.1.002.501.752.805.502.71
SPN
Finish39152011
Turn.37111437.60
Norm T.1.001.172.752.801.501.84
SRT
Finish31582010
Turn.31341427.20
Norm T.1.002.171.002.801.001.59
HRRN
Finish39132015
Turn.3791478.00
Norm T.1.001.172.252.803.502.14
Feedback (q=1)
Finish420161911
Turn.4181213310.00
Norm T.1.333.003.002.601.502.29
Feedback ( q=2^(i-1) )
Finish417182014
Turn.4151414610.60
Norm T.1.332.503.502.803.002.63
Sheet2
Sheet3
-
Performance ComparisonBased on queuing theoryAssume Poisson arrivals and exponential service timesExample:Two priority levelsLow-priority processes five times longer on averageOverall Normalized Response Times (Figure 9.11, Page 416)
-
Performance ComparisonNormalized response times for shorter processes (Fig 9.12, p. 417)
Normalized response times for longer processes (Fig 9.13, p. 417)
-
Performance ComparisonSimulation modeling50,000 simulated processes, grouped by size, 80% CPU UtilizationNormalized turnaround time (Fig 9.14, p. 418)
Waiting time (Fig 9.15, p. 419)
-
Fair Share SchedulingThink of processes as part of a groupEach group has a specified share of the machine it is allowed to usePriority is based on the time this processes is active, and the time the processes in the group have been activeValuesPjPriority of process jUjjProcessor use by process jGUkProcessor use by group kCPUjExponentially weighted average for process jGCPUkExponentially weighted average for group kWkWeight assigned to group kCalculations (done each second):Pj := Basej + CPUj/2 + GCPUk/(4*Wk)CPUj := Uj-1/2 +CPUj-1/2GCPUk := GUk-1/2 + GCPUk-1/2
-
Fair Share ExampleFigure 9.16, page 421Three processes A, B, CB,C are in one group, A is by itselfBoth groups get 50% weighting
Sheet1
Process AProcess BProcess C
PriorityProcessGroupPriorityProcessGroupPriorityProcessGroup
t=0600060006000
A+60+600000
t=190303060006000
B00+60+600+60
t=274151590303075030
A+60+600000
t=396373774151567015
C000+60+60+60
t=478181881737933037
A+60+600000
t=598393970318761518
B00+60+600+60
t=678191994313982739
A+60+600000
t=798393976151970319
C000+60+60+60
t=878191982739943139
A+60+600000
t=998393970319761519
B00+60+600+60
t=1078191994313982739
A+60+600000
t=1198393976151970319
C000+60+60+60
t=1278191982739943139
Sheet2
Sheet3
-
Unix SchedulingSame for both SVR3 and 4.3 BSD (SVR4 is different)Similar to Fair-share schedulingValuesPjPriority of process jUjProcessor use by jCalculations (done each second):CPUj := Uj-1/2 +CPUj-1/2Pj := Basej + CPUj/2 + nicejRestrictions on CPU and Nice to prevent a process from getting too far away from its base priority bandSwapperBlock I/O Device controlFile ManipulationCharacter I/O Device controlUser Processes
-
Response TimeIf the system gets too slow to a user, they may slow down or abort the operationMust balance response time with the cost requiredFaster/more expensive hardware may be requiredPriorities that may penalize certain processesRanges (table 9.7, page 429)15 seconds or greaterRules out conversational interaction.Most users will not wait this longIf it cannot be avoided, allow the user to continue on to something elseForeground/background threads
-
Response Time (Tab 9.7)4 to 15 secondsGenerally user loses track of the current operation in short-term memoryOk after end of a major closure2 to 4 secondsInhibits user concentrationBothers a user who is focused on the jobOk after end of a minor closure1 to 2 secondsImportant when information has to be remembered over several responsesImportant limit for terminal activitiesLess than 1 secondFor keeping users attention for thought-intensive activitiesExample: graphicsLess than 1/10 secondResponse to key presses or mouse clicks
-
Response TimeUser productivity tends to improve with a more rapid response timeEspecially true for expert usersBecomes very noticeable as response time drops below 1 secondUser time think time, time user spends thinking about the responseSystem time Time system takes to generate its responseShort response times are importantUser response time tends to decrease as system response time decreasesWeb Pages Loading a page in 3 seconds or less increases the users attentionUser may abort after 10s or more
-
Response TimeResponse time results for High-Function Graphics (Figure 9.20, page 430)
Response time requirements (Figure 9.21, page 431)