Arshad Jhumka Department of Computer Science University of

Transcription

Arshad Jhumka Department of Computer Science University of
Real-time systems
scheduling
Arshad Jhumka
Department of Computer Science
University of Warwick
Previously...
Scheduling algorithms for non-real-time
systems or soft real-time systems.
FCFS, SJF, RR etc
These algorithms are not suitable when
execution has to complete before a deadline.
Real-time systems scheduling
Rate monotonic
Rate monotonic algorithm
Popular static scheduling algorithm for real-time OS
Set of periodic tasks/jobs/processes
Priority of a task is inversely proportional to its
period, i.e., shorter period => higher priority
Several assumptions
some assumptions
No task has any nonpreemptable part and the
cost of preemption is negligible.
Only processing requirements important;
memory, IO negligible.
Independent tasks. No precedence constraints.
All tasks are periodic.
Relative deadline of task equal to its period.
how do we make sure
Tasks are periodic, so multiple instances.
How do we make sure all tasks meet their
deadline?
Roll out all tasks and check.
But how long? infeasible?
Good to have a test!
Schedulability analysis
Process of determining whether a task set can
be scheduled by a scheduler such that all task
instances complete before their deadline.
Typically involves a feasibility test.
Feasibility testing: Given task set and priority
assignment, can task set be scheduled by static
priority algorithm such that all task instances
complete before their deadlines?
feasibility test
Feasibility test is sufficient if a positive answer
shows that the task set is indeed schedulable.
Negative answer does not mean anything.
Feasibility test is necessary if a negative
answer shows that the task set is indeed not
schedulable.
Positive answer does not mean anything.
Interested in exact feasibility.
Sufficient feasibility
For RMA: Given n tasks, RMA will
schedule these tasks to meet their
deadlines if total utilization of the tasks in
no greater than n(2^1/n - 1) = ln 2.
Utilization of task: e/P (exec time/period)
exact feasibility
Given a set of n periodic tasks, with
P1<=P2<=...<=Pn. Task Ti can be feasibly
scheduled using RM iff Li <= 1.
What is Li? Measure of the amount of work
done by the tasks.
communicating tasks
What if tasks are dependent?
Picture this: Three tasks L, M and H with L and
H sharing a resource R.
L holds R, H is scheduled but is blocked since R
is held by L. M comes in and preempts L. M
runs though H is ready - Priority Inversion.
Problem in real-time systems - Mars Pathfinder
Implemented in real-time patch of Linux kernel
What to do?
How can we handle priority inversion?
Use of priority inheritance; when H requests R,
priority of L is temporarily raised to that of H
so M cannot preempt it. Once L releases R, it
gets its original priority.
Can lead to deadlock though!
addressing deadlock
Priority ceiling protocol
Prevents deadlock and reduces worst-case
blocking time.
Priority ceiling of a semaphore S or resource:
highest priority of all processes that may lock S
A process P can start CS only if P’s priority >
PCs of all semaphores locked by all other
processes.
Priority ceiling
Any process can be blocked for at most the
duration of a single CS of lower-priority
process. Very good!
No deadlock, no long blocking time.
Bounded blocking.
Available in VxWorks real-time kernel.
conclusion
RMA for real-time scheduling.
For communicating tasks, priority inversion.
Use of priority inheritance.
Deadlock possible.
Use of priority ceiling.