34
Uniprocessor Scheduling Chapter 9

Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time

  • View
    231

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time

Uniprocessor Scheduling

Chapter 9

Page 2: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time

Aim of Scheduling

• The key to multiprogramming is scheduling

• Scheduling is done to meet the goals of– Response time– Throughput– Processor efficiency

Page 3: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time

Tanenbaum Models

Page 4: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time

Tanenbaum Models

Page 5: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time

Types of Scheduling

Page 6: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time

Three Types

• Long term scheduling: Degree of multiprogramming in the system

• Medium term scheduling: Disk to memory migration

• Short term scheduling: Ready to running migration

Page 7: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time
Page 8: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time
Page 9: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time

Long-Term Scheduling

• Determines which programs are admitted to the system for processing

• Controls the degree of multiprogramming

• More processes, smaller percentage of time each process is executed

Page 10: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time

Medium-Term Scheduling

• Part of the swapping function

• Disk to main memory (swap-in or swap-out)

• Based on the need to manage the degree of multiprogramming

Page 11: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time

Short-Term Scheduling

• Known as the dispatcher

• Executes most frequently

• Invoked when an event occurs– Clock interrupts– I/O interrupts– Operating system calls– Signals

Page 12: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time

Short-Tem Scheduling Criteria

• User-oriented– Response Time

• Elapsed time between the submission of a request until there is output.

• System-oriented– Effective and efficient utilization of the

processor i.e. throughput– Not important on single-user system

Page 13: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time

Short-Term Scheduling Criteria

• Performance-related– Quantitative– Measurable such as response time and

throughput

• Not performance related– Qualitative– Predictability (The system appears same to

the users over a period of time)

Page 14: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time

Priorities

• Scheduler will always choose a process of higher priority over one of lower priority

• Have multiple ready queues to represent each level of priority

• Lower-priority may suffer starvation– allow a process to change its priority based

on its age or execution history

Page 15: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time
Page 16: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time

Decision Mode

• Nonpreemptive– Once a process is in the running state, it will

continue until it terminates or blocks itself for I/O

• Preemptive– Currently running process may be interrupted and

moved to the Ready state by the operating system

– More overhead but allows for better service since any one process cannot monopolize the processor for very long

Page 17: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time

Process Scheduling Example

Page 18: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time

First-Come-First-Served(FCFS)

• Each process joins the Ready queue• When the current process ceases to execute,

the oldest process in the Ready queue is selected

0 5 10 15 20

A

B

C

D

E

Page 19: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time

First-Come-First-Served(FCFS)

• A short process may have to wait a very long time before it can execute

• Favors processor bound processes– I/O processes have to wait until processor

bound process completes– Then the I/O bound process quickly runs its

processor cycle and blocks again for I/O

Page 20: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time

Round-Robin

• Uses preemption based on a clock• An amount of time is determined that allows

each process to use the processor for that length of time

0 5 10 15 20

A

B

C

D

E

Page 21: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time

Round-Robin

• Clock interrupt is generated at periodic intervals• When an interrupt occurs, the currently running

process is placed in the ready queue and the next ready job is selected

• Known as time slicing; If slice is short, large overhead in switching tasks

• If each process runs to completion, RR changes into FCFS

• To avoid unfair treatment of I/O bound processes, VRR prefers older processes over newer ones

Page 22: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time

Shortest Process Next

• Nonpreemptive policy to prefer short processes

• Process with shortest expected processing time is selected next

• Short process jumps ahead of longer processes

0 5 10 15 20

1

2

3

4

5

A

B

C

D

E

Page 23: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time

Shortest Process Next

• How to estimate the process length?• EWMA is used to estimate duration. It

gives more weight to recent burst times• Predictability of longer processes is

reduced• If estimated time for process not correct,

the operating system may abort it• Possibility of starvation for longer

processes

Page 24: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time

Shortest Remaining Time

• Preemptive version of SPN policy• Must estimate processing time• Similar features as SPN but better turnaround

because a short new process is preferred

0 5 10 15 20

1

2

3

4

5

A

B

C

D

E

Page 25: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time

Highest Response Ratio Next (HRRN)

• Choose next process with the lowest ratio R where R is

time spent waiting + expected service timeexpected service time

1

2

3

4

5

0 5 10 15 20

A

B

C

D

E

Page 26: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time

HRRN

• When a process is new, waiting time is zero

• Thus the minimum value of R is 1.0• If the process is short, R is ________?• If the process is waiting for long time, R

becomes________?• Always choose the process with largest

R• No starvation

Page 27: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time

Feedback

• Penalize jobs that have been running longer

• Don’t know remaining time process needs to execute but we know how long the process has executed

• Every time a process is preempted, it is placed in a lower priority queue

0 5 10 15 20

1

2

3

4

5

A

B

C

D

E

Page 28: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time
Page 29: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time

Feedback Scheduling

• All queues run as FCFS except for the lowest priority queue

• The lowest priority queue runs as RR

• The feedback scheduling may punish long processes heavily so a variation is suggested that increases the time slice as a process goes down the lower priority queues

Page 30: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time

Fair-Share Scheduling

• User’s application runs as a collection of processes (threads)

• User is concerned about the performance of the application

• If Computer Science students are running a lot of jobs on the server, Math students should not see performance degradation for their jobs

• We need to make scheduling decisions based on process sets

• Each user or group is allocated a weight and this weight translates to fair share

Page 31: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time
Page 32: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time

Traditional UNIX Scheduling (Timeshared Interactive Model)

• Multilevel feedback using round robin within each of the priority queues

• Priorities are recomputed once per second (time slice = 1 second)

• Base priority divides all processes into fixed bands of priority levels

• Adjustment factor used to keep process in its assigned band

Page 33: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time

Bands

• Decreasing order of priority– Swapper– Block I/O device control– File manipulation– Character I/O device control– User processes (favoring I/O bound)

Page 34: Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time