Top Banner
1 Uniprocessor Scheduling Chapter 9
47

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.

Dec 25, 2015

Download

Documents

August May
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 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.

1

Uniprocessor Scheduling

Chapter 9

Page 2: 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.

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)

Page 3: 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.

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.

Page 4: 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.

4

Types of Processor Scheduling

Page 5: 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.
Page 6: 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.

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.

Page 7: 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.

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.

Page 8: 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.

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.

Page 9: 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.

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.

Page 10: 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.

10

Medium-Term Scheduling

Part of the swapping functionBased on the need to manage the degree of multiprogrammingDone by memory management software.

Page 11: 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.

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.

Page 12: 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.

12

Short-Term Scheduling…

Examples of such event:Clock interruptsI/O interruptsOperating system callsSignals

Page 13: 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.

13

Scheduling Algorithms

Topic covered:Short-Term Scheduling CriteriaThe Use of PrioritiesAlternative Scheduling Policies

Page 14: 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.

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.

Page 15: 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.

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.

Page 16: 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.

16

Short-Tem Scheduling Criteria

System-orientedEffective and efficient utilization of the processorExample:

Throughput– Number of process completed per time.

Page 17: 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.

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.

Page 18: 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.

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

Page 19: 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.
Page 20: 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.

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.

Page 21: 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.

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.

Page 22: 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.

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).

Page 23: 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.

23

Process Scheduling Example

Process Arrival Time Service Time

A 0 3

B 2 6

C 4 4

D 6 5

E 8 2

Page 24: 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.

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

Page 25: 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.

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

Page 26: 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.

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

Page 27: 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.

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

Page 28: 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.

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

Page 29: 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.

29

Shortest Process Next

Calculate the WT and AWT!!

Page 30: 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.

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

Page 31: 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.

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.

Page 32: 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.

32

Shortest Remaining Time

Calculate the WT and AWT!!

Page 33: 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.

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

Page 34: 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.

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

Page 35: 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.

35

Round-Robin

Calculate the WT and AWT!!

Page 36: 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.

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

Page 37: 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.

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.

Page 38: 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.

38

Highest Response Ratio Next (HRRN)Calculate the WT and AWT!!

Page 39: 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.

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

Page 40: 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.

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

Page 41: 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.

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.

Page 42: 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.

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

Page 43: 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.
Page 44: 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.

44

Feedback

Calculate the WT and AWT!!

Page 45: 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.

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.

Page 46: 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.

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)

Page 47: 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.

47

Optimization Criteria

Max CPU utilizationMax throughputMin turnaround timeMin waiting timeMin response time