1.Interrupt latency
– aka interrupt response time is the time elapsed between the last instruction executed on the current interrupted task and start of the interrupt handler.
2.Dispatch latency
– time it takes for the dispatcher to stop one process and start another running. To keep dispatch latency low is to provide preemptive kernels.
Real-Time CPU Scheduling
The RTOS schedules all tasks according to the deadline information and ensures that all deadlines are met.
Static scheduling
A schedule is prepared before execution of the application begins
.
Priority-based scheduling
The
priority assigned to the tasks
depends on how quickly a task has to respond to the event.
Dynamic scheduling
There is complete knowledge of tasks set, but new arrivals are not known. Therefore,
the schedule changes
over the time
.
Timing constraints
The
timing constraints(时序约束)
are in the form of
period
and
deadline
.
The
period
is the amount of time between iterations of a regularly repeated task. Such repeated tasks are called
periodic tasks
.
The
deadline
is a constraint of the
maximum time limit
within which the operation must be complete.
scheduling criteria
•
The timing constraints of the system must be met.
• The cost of context switches, while preempting, must be reduced
.
The scheduling in real-time systems may be performed in the following ways:
preemptively, non-preemptively, statically
, and
dynamically
.
Characteristics of processes
Processes are considered periodic (repeated tasks).
Once a periodic process has acquired the CPU, it has:
- fifixed
processing time
t
,
-
deadline
d
by which it must be serviced by the CPU, and
-
period
p
.
0 ≤ t ≤ d
≤
p
Rate
of a periodic task is
1/
p
A process may have to announce its deadline requirements to the scheduler.
Rate Monotonic Scheduling (RMS)
It is a static priority-based preemptive scheduling algorithm.
The task with the shortest period will always preempt the executing task.
The shortest period = the highest priority
The CPU utilization of a process Pi
t
i
= the execution time
p
i
= the period of process
ti/pi
The deadline for each process requires that it complete its CPU burst by the start of its next period.
e.g.
1) P1 a higher priority than P2
.
P1 p
1
= 50, t
1
= 20 the CPU utilization of P1 = 20/50 = 0.4
P2 p
2
= 100, t
2
= 35. the CPU utilization of P2 = 35/100 = 0.35
total CPU utilization – 75%
2) P2 a higher priority than P1.
P1 p
1
= 50, t
1
= 20
P2 p
2
= 100, t
2
= 35.
(55>50)
3) A set of processes that cannot be scheduled using the RM algorithm
P1: p
1
= 50, t
1
= 25.
P2: p
2
= 80, t
2
= 35.
process P1 is high priority
The total CPU utilization: (25/50)+(35/80) = 0.94 (though the data seems good, not good for CPU
Earliest-Deadline-First Scheduling
The scheduling criterion is
based on the deadline of the processes
.
When a process becomes runnable, it must announce its deadline
requirements to the system.
(The processes / tasks need not be periodic
.)
Dynamically assigns priorities
according to deadline
(as the deadlines are computed at run-time and
priorities are not fixed as well)
.
•
the earlier the deadline = the higher the priority;
Proportional Share Scheduling
T
shares are allocated among all processes in the system
An application receives
N
shares where
N < T
This ensures each application will receive
N / T
of the total processor time
Algorithm Evaluation
How do we select a CPU-scheduling algorithm for a particular system
1. Deterministic Modeling
Takes a particular predetermined workload and defines the performance of each algorithm for that workload
What algorithm can provide the minimum average waiting time?
Consider 5 processes arriving at time 0:
2.Queueing Models
If we define a queue for the CPU and a queue for each I/O device, we can test the various scheduling algorithms using
queueing theory
Little ’ s formula – processes leaving queue must equal processes arriving, thus:
n = λ x W
n
= average queue length
W
= average waiting time in queue
λ
= average arrival rate into queue
e.g. if on average 7 processes arrive per second, and normally 14 processes in queue, then average wait time per process = 2 seconds (n=14, λ=7)
3. Simulations
trace tapes
This is data collected from real processes on real machines and is
fed into the simulation
.