23
Uniprocessor Scheduling Chapter 9 (Continued)

Uniprocessor Scheduling

  • Upload
    ula

  • View
    31

  • Download
    1

Embed Size (px)

DESCRIPTION

Uniprocessor Scheduling. Chapter 9 (Continued). Acknowledgment. Several (most?) transparencies are from the slide set prepared by Patricia Roy, and available on the Stallings OS site (many transparencies have been modified, and some added, to suit my plans). - PowerPoint PPT Presentation

Citation preview

Page 1: Uniprocessor Scheduling

Uniprocessor Scheduling

Chapter 9(Continued)

Page 2: Uniprocessor Scheduling

Acknowledgment

• Several (most?) transparencies are from the slide set prepared by Patricia Roy,

and available on the Stallings OS site (many transparencies have been modified, and some added, to suit my plans)

Page 3: Uniprocessor Scheduling

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– Allows for better service since any one process

cannot monopolize the processor for very long

Page 4: Uniprocessor Scheduling

Process Scheduling Example

Page 5: Uniprocessor Scheduling

FCFS Assuming processes do not perform any I/O

• 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

1

2345

Page 6: Uniprocessor Scheduling

First-Come-First-Served(FCFS)

• If processes do not perform I/O, a short process may have to wait a very long time before it can execute

• If processes perform I/O, and both I/O-bound and CPU-bounds processes exist,

FCFS policy favors CPU-bound processes.

**** Someone explain this!!!

Page 7: Uniprocessor Scheduling

Round-Robin

• Uses preemption based on a clock• Again, someone explain this!!!

0 5 10 15 20

1

2345

Page 8: Uniprocessor Scheduling

Round-Robin

• Clock interrupt is generated at periodic intervals

• When an interrupt occurs, the currently running process is placed in the ready queue– Next ready process is selected

• Known as time slicing

Page 9: Uniprocessor Scheduling

Shortest Process Next

• Nonpreemptive policy• Process with shortest expected processing time

is selected next• Short process jumps ahead of longer processes

0 5 10 15 20

1

2345

Page 10: Uniprocessor Scheduling

Shortest Process Next• 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• Very difficult to use in practice!• Q: Does it offer better throughput than,

say, FCFS or round-robin?

Page 11: Uniprocessor Scheduling

Shortest Remaining Time

• Preemptive version of shortest process next policy

• Must estimate processing time correctly

0 5 10 15 20

1

2345

Page 12: Uniprocessor Scheduling

Highest Response Ratio Next (HRRN)

• Choose next process with the highest ratio

time spent waiting + expected service timeexpected service time

1

2345

0 5 10 15 20

Page 13: Uniprocessor Scheduling

Feedback

• Penalize processes that use too much CPU time by reducing priority of a process every time it gets preempted

• High priority given when it finishes I/O

0 5 10 15 20

1

2345

Page 14: Uniprocessor Scheduling
Page 15: Uniprocessor Scheduling

Fair-Share Scheduling• User’s application runs as a collection of

processes (threads)• User is concerned about the performance

of the application• Need to make scheduling decisions

based on process sets in an application• A `fair share’ for an application (or

group of processes) is a specified fraction of CPU time

Page 16: Uniprocessor Scheduling

Fair-share scheduling

• Specify fair shares for different applications/groups of processes

• Try to provide the fair share to each group

• Accumulate the CPU time used -- individually by each process -- by groups of processes and adjust process priorities accordingly

Page 17: Uniprocessor Scheduling

Fair-share scheduling

• CPU(i) = CPU(i-1)/2 -- for a process• GCPU(i) = GCPU(i-1)/2 – for a group

• P(i) = Base + CPU(i-1)/2 + GCPU(i-1)/(4 x W) where `w’ is the fair share of the group of processes

Page 18: Uniprocessor Scheduling
Page 19: Uniprocessor Scheduling

UNIX Scheduling

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

• Priorities are recomputed once per second

• A large numerical value of priority indicates low effective priority

Page 20: Uniprocessor Scheduling

UNIX Scheduling

Compute P(i) every second as follows: CPU(i) = CPU(i-1)/2• P(i) = Base + CPU(i-1)/2 + nice• *** Change CPU(i-1) to CPU(i) ***??!!• Base priority divides all processes into

fixed bands of priority levels• Adjustment factor used to keep process

in its assigned band

Page 21: Uniprocessor Scheduling

Priority Bands

• Base priorities are defined to provide decreasing order of priority to– Swapper– Block I/O device control– File manipulation– Character I/O device control– User processes

Page 22: Uniprocessor Scheduling
Page 23: Uniprocessor Scheduling

Unix scheduling

• How is this scheduling different from round robin scheduling with time slicing?