2 CPU scheduling criteria CPU Utilization How busy is the CPU ? - - PowerPoint PPT Presentation

2
SMART_READER_LITE
LIVE PREVIEW

2 CPU scheduling criteria CPU Utilization How busy is the CPU ? - - PowerPoint PPT Presentation

Chapter 2 (Fourth Part) Scheduling Mechanisms and Policies Slide Credits: Jonathan Walpole Andrew Tanenbaum 1 Process state model New Process Termination Ready Running Blocked 2 CPU scheduling criteria CPU Utilization How busy is


slide-1
SLIDE 1

1

Chapter 2 (Fourth Part)

Scheduling Mechanisms and Policies

Slide Credits: Jonathan Walpole Andrew Tanenbaum

slide-2
SLIDE 2

2

Process state model

New Process Ready Blocked Running Termination

slide-3
SLIDE 3

3

CPU scheduling criteria

CPU Utilization – How busy is the CPU? Throughput – How many jobs finished (per unit time)? Turnaround Time – How long from job submission to job termination? Response Time – How long (on average) does it take to get a “response” from a “stimulus”? Missed deadlines – Were any deadlines missed?

slide-4
SLIDE 4

4

Scheduler Options

Priorities May use priorities to determine who runs next

amount of memory, order of arrival, etc..

Dynamic vs. Static algorithms

Dynamically alter the priority of the tasks while they are in the system (possibly with feedback) Static algorithms typically assign a fixed priority when the job is initially started.

Preemptive vs. Nonpreemptive Preemptive systems allow the task to be interrupted at any time so that the O.S. can take over again.

slide-5
SLIDE 5

5

Scheduling Policies

First-Come, First Served (FIFO) Shortest Job First (non-premeptive) Shortest Job First (with preemption) Round-Robin Scheduling Priority Scheduling Real-Time Scheduling

slide-6
SLIDE 6

6

First-Come, First-Served (FIFO)

Start jobs in the order they arrive (FIFO queue) Run each job until completion

slide-7
SLIDE 7

7

First-Come, First-Served (FIFO)

Start jobs in the order they arrive (FIFO queue) Run each job until completion

Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

slide-8
SLIDE 8

8

First-Come, First-Served (FIFO)

Start jobs in the order they arrive (FIFO queue) Run each job until completion

Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Total time taken, From submission to completion

slide-9
SLIDE 9

9

First-Come, First-Served (FIFO)

Start jobs in the order they arrive (FIFO queue) Run each job until completion

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Total time taken, From submission to completion

Arrival Times of the Jobs

slide-10
SLIDE 10

10

First-Come, First-Served (FIFO)

Start jobs in the order they arrive (FIFO queue) Run each job until completion

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Total time taken, From submission to completion

slide-11
SLIDE 11

11

First-Come, First-Served (FIFO)

Start jobs in the order they arrive (FIFO queue) Run each job until completion

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Total time taken, From submission to completion

slide-12
SLIDE 12

12

First-Come, First-Served (FIFO)

Start jobs in the order they arrive (FIFO queue) Run each job until completion

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Total time taken, From submission to completion

slide-13
SLIDE 13

13

First-Come, First-Served (FIFO)

Start jobs in the order they arrive (FIFO queue) Run each job until completion

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Total time taken, From submission to completion

slide-14
SLIDE 14

14

First-Come, First-Served (FIFO)

Start jobs in the order they arrive (FIFO queue) Run each job until completion

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Total time taken, From submission to completion

slide-15
SLIDE 15

15

First-Come, First-Served (FIFO)

Start jobs in the order they arrive (FIFO queue) Run each job until completion

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Total time taken, From submission to completion

slide-16
SLIDE 16

16

First-Come, First-Served (FIFO)

Start jobs in the order they arrive (FIFO queue) Run each job until completion

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Total time taken, From submission to completion

slide-17
SLIDE 17

17

First-Come, First-Served (FIFO)

Start jobs in the order they arrive (FIFO queue) Run each job until completion

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Total time taken, From submission to completion

slide-18
SLIDE 18

18

First-Come, First-Served (FIFO)

Start jobs in the order they arrive (FIFO queue) Run each job until completion

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Total time taken, From submission to completion

slide-19
SLIDE 19

19

First-Come, First-Served (FIFO)

Start jobs in the order they arrive (FIFO queue) Run each job until completion

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Total time taken, From submission to completion

slide-20
SLIDE 20

20

First-Come, First-Served (FIFO)

Start jobs in the order they arrive (FIFO queue) Run each job until completion

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Total time taken, From submission to completion

slide-21
SLIDE 21

21

First-Come, First-Served (FIFO)

Start jobs in the order they arrive (FIFO queue) Run each job until completion

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Total time taken, From submission to completion

slide-22
SLIDE 22

22

First-Come, First-Served (FIFO)

Start jobs in the order they arrive (FIFO queue) Run each job until completion

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 0 2 2 6 1 3 4 4 5 4 6 5 7 5 8 2 10

Total time taken, From submission to completion

slide-23
SLIDE 23

23

First-Come, First-Served (FIFO)

Start jobs in the order they arrive (FIFO queue) Run each job until completion

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 0 3 2 2 6 1 7 3 4 4 5 9 4 6 5 7 12 5 8 2 10 12

Total time taken, From submission to completion

slide-24
SLIDE 24

24

Shortest Job First

Select the job with the shortest (expected) running time Non-Preemptive

slide-25
SLIDE 25

25

Shortest Job First

Select the job with the shortest (expected) running time Non-Preemptive

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Same Job Mix

slide-26
SLIDE 26

26

Shortest Job First

Select the job with the shortest (expected) running time Non-Preemptive

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

slide-27
SLIDE 27

27

Shortest Job First

Select the job with the shortest (expected) running time Non-Preemptive

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

slide-28
SLIDE 28

28

Shortest Job First

Select the job with the shortest (expected) running time Non-Preemptive

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

slide-29
SLIDE 29

29

Shortest Job First

Select the job with the shortest (expected) running time Non-Preemptive

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

slide-30
SLIDE 30

30

Shortest Job First

Select the job with the shortest (expected) running time Non-Preemptive

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

slide-31
SLIDE 31

31

Shortest Job First

Select the job with the shortest (expected) running time Non-Preemptive

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

slide-32
SLIDE 32

32

Shortest Job First

Select the job with the shortest (expected) running time Non-Preemptive

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

slide-33
SLIDE 33

33

Shortest Job First

Select the job with the shortest (expected) running time Non-Preemptive

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

slide-34
SLIDE 34

34

Shortest Job First

Select the job with the shortest (expected) running time Non-Preemptive

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

slide-35
SLIDE 35

35

Shortest Job First

Select the job with the shortest (expected) running time Non-Preemptive

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

slide-36
SLIDE 36

36

Shortest Job First

Select the job with the shortest (expected) running time Non-Preemptive

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

slide-37
SLIDE 37

37

Shortest Job First

Select the job with the shortest (expected) running time Non-Preemptive

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

slide-38
SLIDE 38

38

Shortest Job First

Select the job with the shortest (expected) running time Non-Preemptive

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 0 2 2 6 1 3 4 4 7 4 6 5 9 5 8 2 1

slide-39
SLIDE 39

39

Shortest Job First

Select the job with the shortest (expected) running time Non-Preemptive

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 0 3 2 2 6 1 7 3 4 4 7 11 4 6 5 9 14 5 8 2 1 3

slide-40
SLIDE 40

40

Shortest Remaining Time

Preemptive version of SJF

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Same Job Mix

slide-41
SLIDE 41

41

Shortest Remaining Time

Preemptive version of SJF

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

slide-42
SLIDE 42

42

Shortest Remaining Time

Preemptive version of SJF

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

slide-43
SLIDE 43

43

Shortest Remaining Time

Preemptive version of SJF

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

slide-44
SLIDE 44

44

Shortest Remaining Time

Preemptive version of SJF

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

slide-45
SLIDE 45

45

Shortest Remaining Time

Preemptive version of SJF

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

slide-46
SLIDE 46

46

Shortest Remaining Time

Preemptive version of SJF

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

slide-47
SLIDE 47

47

Shortest Remaining Time

Preemptive version of SJF

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

slide-48
SLIDE 48

48

Shortest Remaining Time

Preemptive version of SJF

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

slide-49
SLIDE 49

49

Shortest Remaining Time

Preemptive version of SJF

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

slide-50
SLIDE 50

50

Shortest Remaining Time

Preemptive version of SJF

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

slide-51
SLIDE 51

51

Shortest Remaining Time

Preemptive version of SJF

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

slide-52
SLIDE 52

52

Shortest Remaining Time

Preemptive version of SJF

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

slide-53
SLIDE 53

53

Shortest Remaining Time

Preemptive version of SJF

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

slide-54
SLIDE 54

54

Shortest Remaining Time

Preemptive version of SJF

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 0 2 2 6 7 3 4 4 0 4 6 5 9 5 8 2 0

slide-55
SLIDE 55

55

Shortest Remaining Time

Preemptive version of SJF

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 0 3 2 2 6 7 13 3 4 4 0 4 4 6 5 9 14 5 8 2 0 2

slide-56
SLIDE 56

56

Round-Robin Scheduling

Goal: Enable interactivity Limit the amount of CPU that a process can have at one time.

Time quantum

Amount of time the OS gives a process before intervention The “time slice” Typically: 1 to 100ms

slide-57
SLIDE 57

57

Round-Robin Scheduling

5 10 15 20 Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

slide-58
SLIDE 58

58

Round-Robin Scheduling

5 10 15 20 Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Ready List:

slide-59
SLIDE 59

59

Round-Robin Scheduling

5 10 15 20 Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Ready List:

slide-60
SLIDE 60

60

Round-Robin Scheduling

5 10 15 20 Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Ready List:

slide-61
SLIDE 61

61

Round-Robin Scheduling

5 10 15 20 Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Ready List:

slide-62
SLIDE 62

62

Round-Robin Scheduling

5 10 15 20 Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Ready List:

slide-63
SLIDE 63

63

Round-Robin Scheduling

5 10 15 20 Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Ready List:

slide-64
SLIDE 64

64

Round-Robin Scheduling

5 10 15 20 Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Ready List:

slide-65
SLIDE 65

65

Ready List:

Round-Robin Scheduling

5 10 15 20 Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

slide-66
SLIDE 66

66

Round-Robin Scheduling

5 10 15 20 Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Ready List:

slide-67
SLIDE 67

67

Round-Robin Scheduling

5 10 15 20 Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Ready List:

slide-68
SLIDE 68

68

Round-Robin Scheduling

5 10 15 20 Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Ready List:

slide-69
SLIDE 69

69

Round-Robin Scheduling

5 10 15 20 Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Ready List:

slide-70
SLIDE 70

70

Round-Robin Scheduling

5 10 15 20 Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Ready List:

slide-71
SLIDE 71

71

Round-Robin Scheduling

5 10 15 20 Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Ready List:

slide-72
SLIDE 72

72

Round-Robin Scheduling

5 10 15 20 Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Ready List:

slide-73
SLIDE 73

73

Round-Robin Scheduling

5 10 15 20 Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Ready List:

slide-74
SLIDE 74

74

Round-Robin Scheduling

5 10 15 20 Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Ready List:

slide-75
SLIDE 75

75

Round-Robin Scheduling

5 10 15 20 Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Ready List:

slide-76
SLIDE 76

76

Round-Robin Scheduling

5 10 15 20 Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Ready List:

slide-77
SLIDE 77

77

Round-Robin Scheduling

5 10 15 20 Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Ready List:

slide-78
SLIDE 78

78

Round-Robin Scheduling

5 10 15 20 Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Ready List:

slide-79
SLIDE 79

79

Round-Robin Scheduling

5 10 15 20 Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Ready List:

slide-80
SLIDE 80

80

Round-Robin Scheduling

5 10 15 20 Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Ready List:

slide-81
SLIDE 81

81

Round-Robin Scheduling

5 10 15 20 Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Ready List:

slide-82
SLIDE 82

82

Round-Robin Scheduling

5 10 15 20 Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

Ready List:

slide-83
SLIDE 83

83

Round-Robin Scheduling

5 10 15 20 Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

slide-84
SLIDE 84

84

Round-Robin Scheduling

5 10 15 20 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 1 4 2 2 6 10 16 3 4 4 9 13 4 6 5 9 14 5 8 2 5 7

slide-85
SLIDE 85

85

Round-Robin Scheduling

Effectiveness of round-robin depends on

  • The number of jobs, and
  • The size of the time quantum.

Large # of jobs means that the time between scheduling of a single job increases

(Slow responses)

Larger time quantum means that the time between the scheduling of a single job also increases

(Slow responses)

Smaller time quantum means higher processing rates but also more overhead!

slide-86
SLIDE 86

86

Scheduling in general purpose systems

slide-87
SLIDE 87

87

Priority scheduling

Assign a priority (number) to each process. Schedule processes based on its priority. Higher priority jobs processes get more CPU time. Managing priorities

Can use “nice” to reduce your priority Can periodically adjust a process’ priority

Prevents starvation of a lower priority process Can improve performance of I/O-bound processes p = aT0 + (1-a)T1 efficient to calculate when a = 1/2

Can use feedback to help determine the priorities

priority = 1/fraction last quantum used

slide-88
SLIDE 88

88

Multi-Level Queue Scheduling

Multiple queues, each with its own priority. (Equivalently: Each priority has its own ready queue) Within each queue... Round-robin scheduling. Simplist Approach: A Process’s priority is fixed & unchanging CPU

High priority Low priority

slide-89
SLIDE 89

89

Multi-Level Feedback Queue Scheduling

Problem: Fixed priorities are too restrictive

Processes exhibit varying ratios of CPU to I/O times.

Dynamic Priorities

Priorities are altered over time, as process behavior changes!

slide-90
SLIDE 90

90

Multi-Level Feedback Queue Scheduling

Problem: Fixed priorities are too restrictive

Processes exhibit varying ratios of CPU to I/O times.

Dynamic Priorities

Priorities are altered over time, as process behavior changes!

Issue: When do you change the priority of a process and how

  • ften?
slide-91
SLIDE 91

91

Multi-Level Feedback Queue Scheduling

Problem: Fixed priorities are too restrictive

Processes exhibit varying ratios of CPU to I/O times.

Dynamic Priorities

Priorities are altered over time, as process behavior changes!

Issue: When do you change the priority of a process and how

  • ften?

Solution: Let the amount of CPU used be an indication of how a process is to be handled

Expired time quantum  more processing needed Unexpired time quantum  less processing needed

Adjusting quantum and frequency vs. adjusting priority??

slide-92
SLIDE 92

92

Multi-Level Feedback Queue Scheduling

n priority levels, round-robin scheduling within a level Quanta increase as priority decreases Jobs are demoted to lower priorities if they do not complete within the current quantum CPU

High priority Low priority

??

slide-93
SLIDE 93

93

Multi-Level Feedback Queue Scheduling

Details, details, details...

  • Starting priority?
  • High priority vs. low priority
  • Moving between priorities?
  • How long should the time quantum be?
slide-94
SLIDE 94

94

Lottery Scheduling

Scheduler gives each thread some lottery tickets. To select the next process to run... The scheduler randomly selects a lottery number The winning process gets to run Example Thread A gets 50 tickets Thread B gets 15 tickets Thread C gets 35 tickets There are 100 tickets outstanding.

slide-95
SLIDE 95

95

Lottery Scheduling

Scheduler gives each thread some lottery tickets. To select the next process to run... The scheduler randomly selects a lottery number The winning process gets to run Example Thread A gets 50 tickets 50% of CPU Thread B gets 15 tickets 15% of CPU Thread C gets 35 tickets 35% of CPU There are 100 tickets outstanding.

slide-96
SLIDE 96

96

Lottery Scheduling

Scheduler gives each thread some lottery tickets. To select the next process to run... The scheduler randomly selects a lottery number The winning process gets to run Example Thread A gets 50 tickets 50% of CPU Thread B gets 15 tickets 15% of CPU Thread C gets 35 tickets 35% of CPU There are 100 tickets outstanding.

  • Flexible
  • Fair
  • Responsive.
slide-97
SLIDE 97

97

A Brief Look at Real-Time Systems

Assume processes are relatively periodic

Fixed amount of work per period

(e.g. sensor systems or multimedia data)

slide-98
SLIDE 98

98

A Brief Look at Real-Time Systems

Assume processes are relatively periodic

Fixed amount of work per period

(e.g. sensor systems or multimedia data) Two “main” types of schedulers... Rate-Monotonic Schedulers Earliest-Deadline-First Schedulers

slide-99
SLIDE 99

99

A Brief Look at Real-Time Systems

Assume processes are relatively periodic

Fixed amount of work per period

(e.g. sensor systems or multimedia data) Two “main” types of schedulers... Rate-Monotonic Schedulers

Assign a fixed, unchanging priority to each process

No dynamic adjustment of priorities

  • Less aggressive allocation of processor

Earliest-Deadline-First Schedulers

Assign dynamic priorities based upon deadlines.

slide-100
SLIDE 100

100

A Brief Look at Real-Time Systems

Typically real-time systems involve several steps (that aren’t in traditional systems)

  • Admission control

All processes must ask for resources ahead of time. If sufficient resources exist, the job is admitted “into” the system.

  • Resource allocation

Upon admission... the appropriate resources need to be reserved for the task.

  • Resource enforcement

Carry out the resource allocations properly.

slide-101
SLIDE 101

101

Rate Monotonic Schedulers

For preemptable, periodic processes (tasks) Assigns a fixed priority to each task T = The period of the task C = The amount of processing per task In RMS scheduling, the question to answer is... What priority should be assigned to a given task? Process P1 T = 1 second C = 1/2 second / period

slide-102
SLIDE 102

102

Rate Monotonic Schedulers

P1 P2

slide-103
SLIDE 103

103

Rate Monotonic Schedulers

P1PRI > P2PRI P2PRI > P1PRI P1 P2

slide-104
SLIDE 104

104

Rate Monotonic Schedulers

P1PRI > P2PRI P2PRI > P1PRI P1 P2 The computation for P2 cannot be increased

slide-105
SLIDE 105

105

Rate Monotonic Schedulers

Assign shortest period tasks to the highest priorities Admission control is difficult...

< 70% There is a standard formula. > 70% It may be possible, but need to do more complex analysis.

slide-106
SLIDE 106

106

Rate Monotonic Schedulers

Assumptions:

  • Processes complete (yield) within their period
  • Independent processes
  • Same CPU requirements per burst
  • Other non-periodic processes have no deadlines
  • Instantaneous preemption with no overhead
slide-107
SLIDE 107

107

Earliest Deadline First

When processes do not need periodic execution

  • r have constant CPU requirements...

When processes have deadline specifications... Unlike RMS, EDF uses dynamic priorities (based upon earliest deadline first) (+) 100% processor utilization …? (-) Need to keep track of deadlines Admission Control Just check to see if 100% processor utilization. Sum the Ci/Ti’s and see if less than or equal to 1 What about overhead?