1 uniprocessor scheduling chapter 9. 2 aim of processor scheduling aim: is to assign processes to be...
Post on 25-Dec-2015
229 Views
Preview:
TRANSCRIPT
1
Uniprocessor Scheduling
Chapter 9
2
Aim of Processor Scheduling
Aim: is to assign processes to be executed by the processor or processors over time to meet system objectives.System objectives:
1. Low response timeRT: Time elapse from the submission of a request to the beginning of the response.
2. High ThroughputThroughput: Number of processes completed per unit time
3. Processor efficiencyHigh processor utilization (min processor idle time)
3
Types of Scheduling
1. Long-term scheduling The decision to add to the pool of processes to be
executed.
2. Medium-term scheduling The decision to add to the number of processes
that are partially or fully in main memory.
3. Short-term scheduling The decision as to which available process will be
executed by the processor.
4. I/O scheduling The decision as to which process’s pending I/O
request shall be handled by an available I/O device.
4
Types of Processor Scheduling
6
Long-Term Scheduling
Determines which programs are admitted to the system for processingControls the degree of multiprogrammingIf more processes are admitted, smaller percentage of time each process is executed, i.e more processes are competing for the same amount of processor time.
7
Long-Term Scheduling…
The long term scheduler may limit the degree of multiprogramming to provide satisfactory service to the current set of processes.
The decision as to which job to admit next can be on a simple first-come-first-serve basis or it can be a tool to manage system performance.
8
Long-Term Scheduling…
The criteria used may include priority, expected execution time, and I/O requirements.For interactive programs in a time sharing system, a process request can be generated by the act of user attempting to connect to the system.
9
Long-Term Scheduling…
OS will accept all authorized users until the system is saturated (used some predefined measure of saturation).At this point, a connection request is met with a message indicating that the system is full and the user should try again later.
10
Medium-Term Scheduling
Part of the swapping functionBased on the need to manage the degree of multiprogrammingDone by memory management software.
11
Short-Term Scheduling
Short term scheduler known as the dispatcherExecutes most frequently and makes decision of which process to execute next.Short term scheduler is invoked when an event occurs that may lead to the suspension of the current process or preempt currently running process in favor of another.
12
Short-Term Scheduling…
Examples of such event:Clock interruptsI/O interruptsOperating system callsSignals
13
Scheduling Algorithms
Topic covered:Short-Term Scheduling CriteriaThe Use of PrioritiesAlternative Scheduling Policies
14
Short-Tem Scheduling Criteria
Main objective to allocate processor time to optimize one or more aspect on system behavior.A set of criteria is established against which various scheduling policies may be evaluated.The criteria can be categorized along two dimensions:
1. User-oriented and System-oriented.2. Performance related and Not performance related.
15
Short-Tem Scheduling Criteria
User-orientedRelate to the behavior of the system as perceived by individual user or processExamples:Response Time in an interactive system
RT: Elapsed time between the submission of a request until the response begins to appear as output. Scheduling policy must provide a good service to the various users.For RT, a threshold maybe define e.g. 2 seconds, then the goal of the scheduling mechanism should be to maximize the number of users who experience and average response time of 2 second or less.
16
Short-Tem Scheduling Criteria
System-orientedEffective and efficient utilization of the processorExample:
Throughput– Number of process completed per time.
17
Short-Term Scheduling Criteria
Performance-relatedQuantitative and generally can be measuredMeasurable such as response time and throughput
Not performance relatedQualitative and do not lend to themselves readily to measurement and analysisAn example is predictability
#Table 9.2 summarizes key scheduling criteria.
18
Priorities
Implemented by having a multiple ready queues to represent each level of priority (Figure 9.4)Scheduler will always choose a process of higher priority over one of lower priorityLower-priority may suffer starvationThen allow a process to change its priority based on its age or execution history
20
Alternative Scheduling Algorithms
Table 9.3 summarize the information about the various scheduling algorithms.Selection function:
determine which process among ready process (in Ready Queue) is selected for next execution.the function may be based on priority, resource requirements, or the execution characteristics of the process.
21
Alternative Scheduling Algorithms
Decision mode:Specifies the instant in time at which the selection function is exercisedTwo general categories:
1. Nonpreemptive– Once a process is in the running state, it will
continue until (a) it terminates or (b) blocks itself for I/O or request OS services.
2. Preemptive– Currently running process may be
interrupted and moved to the Ready state by the OS.
22
Scheduling Algorithms
Types of scheduling algorithms:1. First Come First Serve (FCFS)2. Shortest Process Next (SPN)3. Shortest Remaining Time (SRT)4. Round Robin5. Highest Response Ratio Next6. Feedback
Draw the diagramCalculate the waiting time (WT) and average waiting time (AWT).
23
Process Scheduling Example
Process Arrival Time Service Time
A 0 3
B 2 6
C 4 4
D 6 5
E 8 2
24
First-Come-First-Served (FCFS)
Each process arrive will join the Ready queueSelection Function: the process that has been waiting the longest in the ready queue, i.e the oldest process in the Ready queue is selected
5 10 15 20
A
B
C
D
E
25
First-Come-First-Served (FCFS)
Decision Mode: Non-preemptive
A short process may have to wait a very long time before it can execute.A process that does not perform any I/O will monopolize the processorFavors CPU-bound processes
I/O processes have to wait until CPU-bound process completes
26
First-Come-First-Served (FCFS)
Waiting time = start execution time – arrival timeProcess A 0 – 0 = 0Process B 3 – 2 = 1Process C 9 – 4 = 5Process D 13 – 6 = 7Process E 18 – 8 = 10
Average Waiting Time = Total waiting time Number of
processes= 0+1+5+7+10
5= 4.6ms
27
Shortest Process Next
Selection function: the process with the shortest expected CPU burst time.Decision Mode: Nonpreemptive
5 10 15 20
A
B
C
D
E
28
Shortest Process Next
Process with shortest expected processing time is selected nextShort process jumps ahead of longer processesPredictability of longer processes is reducedIf estimated time for process not correct, the operating system may abort itPossibility of starvation for longer processes
29
Shortest Process Next
Calculate the WT and AWT!!
30
Shortest Remaining Time
Selection function: the process with the shortest remaining time.Decision Mode: Preemptive version of shortest process next policy
5 10 15 20
A
B
C
D
E
31
Shortest Remaining Time
Higher overhead than SPN Must estimate processing timeSmall processes will run almost immediately but longer jobs have an even longer waiting time and variant of waiting time that in SPN.
32
Shortest Remaining Time
Calculate the WT and AWT!!
33
Round-Robin
Selection function: same as FCFS
Decision Mode: PreemptiveUses preemption based on a clockAn amount of time is determined that allows each process to use the processor for that length of time
Time quantum = 1 unit
5 10 15 20
A
B
C
D
E
34
Round-Robin
Clock interrupt is generated at periodic intervalsWhen an interrupt occurs, the currently running process is placed in the ready queue
Next ready job is selectedKnown as time slicing
35
Round-Robin
Calculate the WT and AWT!!
36
Highest Response Ratio Next (HRRN)
Selection Function: Choose next process with the highest ratio.Ratio = time spent waiting + expected service time
expected service time
5 10 15 20
A
B
C
D
E
37
Highest Response Ratio Next (HRRN)
Decision mode: Non-Preemptive
This approach is attractive because it accounts the age of the process.While shorter jobs are favored, aging without service increases the ratio so that a longer process will eventually get past competing shorter jobs.Expected service time must be estimated to use HRRN.
38
Highest Response Ratio Next (HRRN)Calculate the WT and AWT!!
39
Feedback
Decision mode: Preemptive (time quantum basis)
Used dynamic priority mechanism.
Time quantum = 1 unit for all Ready Queue
5 10 15 20
A
B
C
D
E
40
Feedback
When a process first enters the system, it is placed in RQ0 (Figure 9.4).After its first execution, when it returns to the Ready state, it is placed in RQ1.Each subsequent time that it is preempted, it demoted to the next lower-priority queue.Penalize jobs that have been running longerDon’t know remaining time process needs to execute
41
Feedback
A shorter process will complete quickly, without migrating very far down the hierarchy process.A longer process will gradually drift downward.Newer shorter processes are favored over older, longer processes.Within each queue, except the lowest priority queue, a simple FCFS mechanism is used.
42
Feedback
In lowest priority queue, a process cannot go lower, but it is returned to this queue repeatedly until it completes execution, it will treated in round robin fashion.Figure 9.10 illustrates the feedback scheduling mechanism by showing the path that a process will follow through the various queues
44
Feedback
Calculate the WT and AWT!!
45
Scheduling Criteria
Different scheduling algorithm have different properties and may favor one class of processes over another.Many criteria have been suggested for comparing Short-Term scheduling algorithms.The characteristics used for comparison can make substantial difference in the determination of the best algorithm.
46
Scheduling Criteria
The criteria are:1. CPU utilization – keep CPU as busy as possible.
2. Throughput – number of processes that complete their execution per time unit.
3. Turnaround time – amount of time to execute a particular process.
4. Waiting time – amount of time a process has been waiting in the ready queue
5. Response time – amount of time it takes from when a request was submitted until the first response is produced, not output (for time-sharing environment)
47
Optimization Criteria
Max CPU utilizationMax throughputMin turnaround timeMin waiting timeMin response time
top related