1
Cyber-Physical Systems Scheduling
IECE 553/453– Fall 2019
- Prof. Dola Saha
Cyber-Physical Systems Scheduling IECE 553/453 Fall 2019 Prof. - - PowerPoint PPT Presentation
Cyber-Physical Systems Scheduling IECE 553/453 Fall 2019 Prof. Dola Saha 1 Scheduler A scheduler makes the decision about what to do next at certain points in time When a processor becomes available, which process will be executed 2
1
2
Ø A scheduler makes the decision about what to do next at
Ø When a processor becomes available, which process will
3
Ø Different schedulers will have different goals § Maximize throughput § Minimize latency § Prevent indefinite postponement § Complete process by given deadline § Maximize processor utilization
4
Ø High-level scheduling § Determines which jobs can compete for resources § Controls number of processes in system at one time Ø Intermediate-level scheduling § Determines which processes can compete for processors § Responds to fluctuations in system load Ø Low-level scheduling § Assigns priorities § Assigns processors to processes
5
Ø Long-term scheduling § when a new process is created § adds the new process to the set of processes that are active Ø Medium-term scheduling § swapping function, adds a process to those that are at least partially in main memory and therefore available for execution Ø Short-term scheduling § actual decision of which ready process to execute next.
6
Ø Long Term (Infrequently) § Controls degree of multiprogramming Ø Medium Term § swapping-in decision will consider the memory requirements of the swapped-out processes Ø Short Term (Frequently) § Clock interrupts, I/O interrupts, Operating system calls, Signals (e.g., semaphores)
7
Ø Static priorities § Priority assigned to a process does not change § Easy to implement § Low overhead § Not responsive to changes in environment Ø Dynamic priorities § Responsive to change § Promote smooth interactivity § Incur more overhead, justified by increased responsiveness
8
ØConsiderations: § Preemptive vs. non-preemptive scheduling § Periodic vs. aperiodic tasks § Fixed priority vs. dynamic priority § Priority inversion anomalies § Other scheduling anomalies
9
Ø Non-Preemptive
§ 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 ready state by the OS § Decision to preempt may be performed
blocked process in the Ready state, or
10
Ø Assume all threads have priorities § either statically assigned (constant for the duration of the thread) § or dynamically assigned (can vary). Ø Assume that the kernel keeps track of which threads are
Ø Preemptive scheduling: § At any instant, the enabled thread with the highest priority is executing. § Whenever any thread changes priority or enabled status, the kernel can dispatch a new thread.
11
Ø Each execution instance of a task is called a job. Ø For periodic scheduling, the best that we can do is to
Ø A scheduler is defined to be optimal iff it will find a
T1 T2
12
Ø First Come First Serve Ø Round Robin Ø Shortest Process Next Ø Shortest Remaining Time Next Ø Highest Response Ratio Next Ø Feedback Scheduler Ø Fair Share Scheduler
13
Ø Processes dispatched according to arrival time Ø Simplest scheme Ø Nonpreemptible Ø Rarely used as primary scheduling algorithm Ø Implemented using FIFO Ø Tends to favor processor-bound processes over I/O-bound
14
Ø Based on FIFO Ø Processes run only for a limited amount of time called a
Ø Preemptible Ø Requires the system to maintain several processes in
Ø Often used as part of more complex algorithms
15
Process allocated time quantum Time Response time s Quantum q q - s Interaction complete Process allocated time quantum s q Process allocated time quantum Process preempted Other processes run Interaction complete
q < Typical Interaction Time q > Typical Interaction Time
16
Ø Determines response time to interactive requests Ø Very large quantum size
§ Processes run for long periods § Degenerates to FIFO
Ø Very small quantum size
§ System spends more time context switching than running processes
Ø Middle-ground
§ Long enough for interactive processes to issue I/O request § Batch processes still get majority of processor time
17
Ø FCFS auxiliary queue to
Ø When a dispatching decision
I/O 1 Wait I/O 2 Wait I/O n Wait Dispatch Time-out Release Ready Queue Admit
Processor
I/O 1 Queue Auxiliary Queue I/O 1 Occurs I/O 2 Occurs I/O n Occurs I/O 2 Queue I/O n Queue
18
Ø When a process is dispatched
from the auxiliary queue, it runs no longer than a time equal to the basic time quantum minus the total time spent running since it was last selected from the main ready queue.
Ø Performance studies indicate
that this approach is better than round robin in terms of fairness.
I/O 1 Wait I/O 2 Wait I/O n Wait Dispatch Time-out Release Ready Queue Admit
Processor
I/O 1 Queue Auxiliary Queue I/O 1 Occurs I/O 2 Occurs I/O n Occurs I/O 2 Queue I/O n Queue
19
Ø Scheduler selects process with smallest time to finish § Lower average wait time than FIFO
§ Potentially large variance in wait times, starvation for longer processes § Nonpreemptive
§ Relies on estimates of time-to-completion
§ Unsuitable for use in modern interactive systems
20
Ø Store the Sum Ø Higher weight to recent instances Ø The older the observation, the less it is counted in to the average.
21
0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8
= 0.2 = 0.5 = 0.8
10 9 8 7 6 5 4 3 2 1
Coefficient Value
22
2 4 6 8 10 = 0.8 = 0.5 Simple Average Observed value 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 20
Time Observed or average value
10 15 20 = 0.8 = 0.5 Simple Average Observed value 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
(b) Decreasing function Time Observed or average value
23
Ø Preemptive version of SPF Ø Shorter arriving processes preempt a running process Ø Very large variance of response times: long processes wait
Ø Not always optimal § Short incoming process can preempt a running process that is near completion § Context-switching overhead can become significant
24
Ø Chooses next process with the greatest response ratio Ø Min. value of R = 1 (when process is created) Ø Attractive because it accounts for the age of the process Ø While shorter jobs are favored, aging without service increases
25
Ø
Scheduling is done on a preemptive (at time quantum) basis, and a dynamic priority mechanism is used.
Ø
When a process first enters the system, it is placed in RQ0.
Ø
After its first preemption, when it returns to the Ready state, it is placed in RQ1.
Ø
Each subsequent time that it is preempted, it is demoted to the next lower-priority queue.
Ø
Once in the lowest-priority queue, it is returned to this queue repeatedly until it completes execution
Figure 9.10 Feedback Scheduling
Release RQ0 Admit
Processor
Release RQ1
Processor
Release RQn
Processor
26
27
28
29
Ø Any scheduling policy that chooses the next item to be
30
31
32
Ø
A data stream consisting of a mixture of long and short packets being transmitted by a packet- switching node and that the rate of arrival of the two types of packets is equal. Suppose both packets have lengths that are exponentially distributed, and the long packets have a mean packet length of 10 times the short packets. In particular, let us assume a 64-Kbps transmission link and the mean packet lengths are 80 and 800 octets. Then the two service times are 0.01 and 0.1
are not held up by the longer packets, let us assign the shorter packets a higher priority.
33 0.1 1 2 3 4 5 6 7 8 9 10 0.2 0.3 0.4 0.5 Utilization () 2 priority classes 1 = 2 ts2 = 5 ts1 Normalized response time (Tr/Ts)
Figure 9.11 Overall Normalized Response Time
0.6 0.7 0.8 0.9 1.0 No priority Priority Priority with preemption
34 0.1 1 2 3 4 5 6 7 8 9 10 0.2 0.3 0.4 0.5 Utilization () 2 priority classes 1 = 2 ts2 = 5 ts1 Normalized response time (Tr1/Ts1)
Figure 9.12 Normalized Response Time for Shorter Processes
0.6 0.7 0.8 0.9 1.0 No priority Priority Priority with preemption
35
0.1 1 2 3 4 5 6 7 8 9 10 0.2 0.3 0.4 0.5 Utilization () 2 priority classes 1 = 2 ts2 = 5 ts1 Normalized response time (Tr2/Ts2)
Figure 9.13 Normalized Response Time for Longer Processes
0.6 0.7 0.8 0.9 1.0 No priority Priority Priority with preemption
36
Figure 9.14 Simulation Results for Normalized Turnaround Time
Percentile of time required Normalized turnaround time FCFS FCFS HRRN HRRN SPN RR (q = 1) RR (q = 1) FB FB SRT SRT SPN 1 10 100 10 20 30 40 50 60 70 80 90 100
37
Figure 9.15 Simulation Results for Waiting Time
Percentile of time required Wait time FCFS FCFS HRRN HRRN RR (q = 1) RR (q = 1) FB FB SRT SPN SPN 10 20 30 40 50 60 70 80 90 100 1 2 3 4 5 6 7 8 9 10
38
§ Scheduling decisions based on the process sets § Each user is assigned a share of the processor § Objective is to monitor usage to give fewer resources to users who have had more than their fair share and more to those who have had less than their fair share § Some user groups more important than others § Ensures that less important groups cannot monopolize resources § Unused resources distributed according to the proportion of resources each group has been allocated § Groups not meeting resource-utilization goals get higher priority
39
40
Priority 60 1 2
1 2
74 15 16 17
15 16 17
78 18 19 20
18 19 20
67 1 2
15 16 17
74 15 15 16 17
60 1 2
1 2
60 1 2
60 90 30 30 96 37 37 98 39 39 70 3 18 76 15 18 90 30 30 81 7 37 93 30 37 75 30 60 Process CPU count
Process A Group 1 Group 2 Process B Process C
Group CPU count Process CPU count Group CPU count Process CPU count Group CPU count Priority Priority Time 1 2 3 4 5
41
Ø Designed to provide good response time for interactive
Ø Employs multilevel feedback using round robin within
Ø Makes use of one-second preemption Ø Priority is based on process type and execution history
42
43