Uniprocessor Scheduling - PowerPoint PPT Presentation

1 / 44
About This Presentation
Title:

Uniprocessor Scheduling

Description:

Uniprocessor Scheduling Operating System * : Multilevel Feedback Queue Scheduling I/O-bound process ... – PowerPoint PPT presentation

Number of Views:197
Avg rating:3.0/5.0
Slides: 45
Provided by: Mario377
Category:

less

Transcript and Presenter's Notes

Title: Uniprocessor Scheduling


1
Lecture 7
  • Uniprocessor Scheduling

2
CPU Scheduling
  • ?? ????? ????? ???? ??? ???? ??? ??? ??? ?????
    ???? CPU? ???? ??
  • ? ?
  • High processor utilization
  • High throughput
  • number of processes completed per unit time
  • Low response time
  • elapsed time from the submission of a request to
    the beginning of the response

3
(No Transcript)
4
???? ??? ??
  • Long-term which process to admit
  • Medium-term which process to swap in or out
  • Short-term which ready process to execute next

5
Queuing Diagram for Scheduling
6
Long-Term Scheduling
  • ?? ????? ????? ??? ? ??? ??? ???? ???? ??
  • ?? ????? ??(the degree of multi-programming)?
    ????
  • ?? ????? ???? ??
  • ?? ????? ????(blocked)? ? ???? ????
  • CPU ???? ?? ? ??
  • ? ????? ?? CPU ?? ??? ????
  • ? ????? ?? ??? ????
  • Processor-bound ????? I/O-bound ????? ???? ??? ?
    ??? ???? ?? ???

7
Medium-Term Scheduling
  • Swapping decisions based on the need to manage
    multiprogramming
  • ?? ????? swapping ? ???? ??
  • ??? ?? ?????? ?? ??

8
Short-Term Scheduling
  • ?? ????? ??? ??? ???? ??
  • CPU scheduling
  • Dispatcher
  • ?? ??? ???? ??? ??? ??? ????? ??
  • ??? ?????? CPU? ??
  • ??? ??
  • ??? ??? ??
  • ???? ??? ?? ??? ????? ??? ??? ?? PC(program
    count) ??
  • CPU ????? ???? ??(events)
  • clock interrupts
  • I/O interrupts
  • operating system calls and traps
  • signals

9
CPU-I/O Burst Cycle
? ? ? load store add
store read from file store
increment index write to file
load store add store read from
file ? ? ?
  • ??? ????? CPU ??? I/O ??? ??? ???? ??? ????? ??
  • ? ???? CPU burst (typically of 5 ms)? I/O
    burst(usually longer)? ??
  • ????? CPU burst? ???? CPU burst? ??
  • CPU-bound process? I/O-bound process?? ? ? CPU
    bursts? ???

CPU Burst
I/O Burst
CPU Burst
I/O Burst
CPU Burst
I/O Burst
10
CPU ???? ??(Criteria)
  • ??? ?? ??
  • Response Time(?? ??) ????? ??? ??? ??? ????? ???
    ??
  • Turnaround Time(?? ?? ??) ????? ??? ??? ??? ??
    ??? ??
  • ??? ?? ??
  • processor utilization(CPU ???)
  • Fairness(???)
  • Throughput(???) ?? ??? ?? ???? ???? ?

11
(No Transcript)
12
(No Transcript)
13
CPU ???? ????? ??
  • ????(selection function)
  • ready queue? ?? ????? ??? ??? ??? ????? ????
    ??(??)
  • ????(decision mode)
  • ????? ??? ??? ??
  • Non-preemptive(???)
  • ?? ????? ????? ?? ??? ????? I/O? ?? ????? ? ???
    ??? ???? ??
  • Preemptive(??)
  • ?? ???? ????? ???? ready queue? ??? ?? ??? ?????
    ???? ??
  • ??? ????? ?? ???? CPU? ???? ???? ???? ? ?? ????
    ????

14
CPU ???? ????
  • ?? ???(First Come First Served) ????
  • ??? ??(Round-Robin) ????
  • ?? ???? ??(Shortest Process NextSPN) ????
  • ?? ?? ??(Shortest Remaining TimeSRT) ????
  • ?? ??? ??(Highest Response Ratio NextHRRN) ????
  • ????(Priority) ????
  • ??? ??? ?(Multi-level Feedback Queue) ????
  • Multiprocessor ????
  • ??? ????(Real-Time Scheduling)

15
CPU ???? ????? ??
- Service time total processor time needed in
one (CPU-I/O) cycle - Jobs with long service time
are CPU-bound jobs and are referred to as long
jobs
16
?? ??? ???? First Come First Served (FCFS)
  • ????
  • ready queue ?? ?? ???? ???? ?? ????? ??
  • First Come First Served(FCFS)
  • ????
  • Non-preemptive(???)
  • ????? ????? ????? ? ??? ????

17
FCFS ????? ??
  • ?? I/O? ???? ?? ????? CPU? ??? ? ??
  • CPU-bound process? ????
  • I/O-bound process? CPU-bound process? ??? ???
    ???? ??
  • I/O-bound process? I/O? ?????? ???? ????? ?? I/O?
    ???? ???(poor device utilization)
  • I/O bound process? ? ?? ?? ????? ?????? I/O
    device? ???? ?? ? ??

18
???-??(Round-Robin) ????
  • ???? FCFS? ??
  • ???? preemptive(??)
  • ????? ??? time slice (quantum, typically from 10
    to 100 ms) ??? ????
  • clock interrupt? ???? ?? ???? ????? ready queue?
    ??? FCFS ???? ??? ????? ????

19
Time Quantum for Round Robin (1)
  • Clock interrupt? dispatching ??? ?? ???? ? ??
    ????? ??
  • should be larger than the typical interaction
  • ?? ?? ??? ?? ? ??

20
Time Quantum for Round Robin (2)
21
Round Robin ???? ??
  • ??? CPU-bound process? ????
  • I/O bound process? time slice?? ?? ???? CPU? ????
    I/O ??? ?? ????? ??
  • CPU-bound process? ?? time slice ?? ???? ready
    queue? ?????. ??, ?? ??? ???? ?? ??? ??
  • ??? ?? ??? ??(virtual round robin)
  • I/O? ????? ?? ?? ??? ????? ready queue?? ?? ?????
    ??? ?? ?(auxiliary queue)? ???

22
Queuing for Virtual Round Robin
23
Shortest Process Next (SPN) ????
  • ????
  • ?? ?? CPU burst time? ?? ????? ????
  • ?? ?? ??(Shortest Job First) ????
  • ???? non-preemptive(???)
  • I/O bound process? ?? ????
  • ? ????? CPU burst time? ?? ????? ??

24
CPU burst time ??(1)
  • Let Ti be the execution time for the i-th
    instance of the process
  • the actual duration of the i-th CPU burst of this
    process
  • Let Si be the predicted value for the i-th CPU
    burst of this process. The simplest choice is
  • Sn1 (1/n) S_i1 to n Ti
  • To avoid recalculating the entire sum we can
    rewrite this as
  • Sn1 (1/n) Tn ((n-1)/n) Sn
  • But this convex combination gives equal weight to
    each instance

25
CPU burst time ??(2)
  • But recent instances are more likely to reflect
    future behavior
  • A common technique for that is to use exponential
    averaging
  • Sn1 a Tn (1-a) Sn 0 lt a lt 1
  • more weight is put on recent instances whenever a
    gt 1/n

26
SPN ???? ??
  • ?? ????? ????? ??? ??? ? ????? starvation ? ????
    ??
  • ??? ????? ??? ??(??? ??)?? ?????
  • CPU bound process? ?? ????? ???? ??? I/O? ???? ??
    ????? CPU? ??? ? ??
  • ??? ?? ???? ???? ???
  • SPN ????? ????? ???? ??? ????
  • shortest jobs are given preferences

27
Shortest Remaining Time (SRT) ????
  • ????
  • ??? ?? ?? ??? ?? ?? ????? ??
  • SPN ????? ???
  • ???? preemptive(??)
  • ??? ????? ?? ?? ??? ?? ???? ????? ?? ?? ???? ??
    ?? ????

28
Shortest Remaining Time (SRT) ????
  • ? ?
  • FCFS ??????? ??? ????? ??
  • ?? ??? ? ?????? ?? ??? ?? ???? ??
  • ???-??? ?? ????? ??? ???? ??
  • ????? ??? SPN?? ???? ??? ?? ??
  • ????? ?? ?? ?? ? ???? ??? ?? ??? ?? ????? ??

29
Highest Response Ratio Next (HRRN) ????
  • ????
  • ?? ??(RR Response Ratio)? ?? ? ????? ??
  • RR (CPU ?? ?? ??? ??? ??)/??? ??? ??
  • ?? ?????? ?? ?? ??? ???? ???
  • ???? nonpreemptive(???)

30
Highest Response Ratio Next (HRRN) ????
  • ? ?
  • ????? ?? ??? ???? ??? ???
  • ????? ?? ????? ?? ????? ??
  • ?? ??? ? ????? ?? ?? ??? ???? ?? ????? ???? ?? ??
    ??? ?????? ?? ??

31
???? ???? Priority Scheduling
  • ???? ?? ?? ??? ????
  • ????? ????? ??
  • ?? ????? ????? ??, ?? ??? ????? ?? ????? ????
    FCFS ???? ??
  • ???? preemptive(??)
  • ? ???? ??? ???? ??? ready queue? ???? ??? ? ??
  • Multi-level queue
  • ?? ???? ????? starvation ? ? ??
  • ?? ????(dynamic priority) ??
  • ?? ?? ??? ?? ????? ????? ???

32
(No Transcript)
33
??? ??? ? ???? Multilevel Feedback Queue
Scheduling
  • Preemptive scheduling with dynamic priorities
  • Several ready queues with decreasing priorities
  • P(RQ0) gt P(RQ1) gt ... gt P(RQn)
  • ??? ????? RQ0? ???
  • Time slice? ???? ????? RQ1?? ???. ??? ? ?? ?????
    RQ2?, ???? RQn?? ???? ??

34
??? ??? ? ???? Multilevel Feedback Queue
Scheduling
  • I/O-bound process? ?? ???? ??? ???? ??? CPU-bound
    process? ?? ???? ?? ????
  • Dispatcher? RQi-1?? RQ0 ??? ?? ???? ?? RQi ?? ???
    ????? ????
  • ? ????? starvation ? ???? ??
  • ?? ???? ??? ?? ??? ????? ?? ???? ??
    ????(aging)??? ??

35
Multiple Feedback Queues
  • ? ???? FCFS ????
  • ?? ?? ???? ???? Round-Robin ????

36
Time Quantum for MFQ Scheduling
  • ?? ??? time slice? ??? ??, ? ????? ?? ?? ??? ???
    ??? ? ??
  • ?? ??? ?? time slice? ??????? ?? ?? ?? ??? ?? ?
    ??
  • ? time slice of RQi 2i-1

37
???? ????? ?? ??
38
(No Transcript)
39
Fair-Share Scheduling(FSS)
  • Users 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

40
(No Transcript)
41
Traditional UNIX Scheduling
  • ??? ??? ??? ??? ????? ??
  • CPU ???? ????? ?? ????
  • ??? ????? ?? ????? ??
  • ?? ????? ??(background) ?????? ?? ??? ??? ?? ??
  • Multilevel feedback using round robin within each
    of the priority queues
  • If a running process does not block or complete
    within 1 second, it is preempted
  • Priorities are recomputed once per second
  • Base priority divides all processes into fixed
    bands of priority levels

42
Bands
  • Decreasing order of priority
  • Swapper
  • Block I/O device control
  • File manipulation
  • Character I/O device control
  • User processes
  • ? ???? ?? ???? ??? ???? ??? ??? ??? ????? ??? ?
    ??? ?? ??

43
Bands of process priorities
  • Kernel and user priorities

44
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com