Professional Documents
Culture Documents
RTOS
Realtime OS
Embedded applications Industrial robots, spacecraft, industrial control, flight control, and scientific research equipment High degree of configurability and extensibility required
Linux? RT Linux VxWorks Windows CE QNX LynxOS RTEMS OS-9
delays)
Multitasking/scheduling
provided through system calls does not take time into account (introduce unbounded
achieved by setting interrupt priority > than process priority increase system reactivity but may cause unbounded delays on process execution even due to unimportant interrupts may cause priority inversion (high priority task blocked by a low priority task)
Interrupt management
No concept of RT clock/deadline
Goal: Minimal Response Time
3
Performance measure
Key property
Predictability
Core of an RTOS!
to guarantee in advance the deadline satisfaction to notify when deadline cannot be guaranteed Affected by several issues such as
characteristics of the processor (pipelinig, cache, DMA, ...), I/O & interrupts, Synchronization & IPC, Architecture, Memory management, Applications and Scheduling!
5
Fault tolerance HW/SW failures must not cause a crash Design for peak load
All scenarios must be considered
Tasks in RTOS
Job (unit of work) a computation, a file read, a message transmission, etc Attributes Resources required to make progress Timing parameters
Released Execution time Absolute deadline
Relative deadline
10
10
15
11
12
5
5
10
10
15
15
13
5
5
10
10
15
15
14
Task assignment
Cyclic executive scheduling Cooperative scheduling
scheduler relies on the current process to give up the CPU before it can start the execution of another process
A static priority-driven scheduler can preempt the current process to start a new process. Priorities are set pre-execution
A dynamic priority-driven scheduler can assign, and possibly also redefine, process priorities at run-time.
E.g., Earliest Deadline First (EDF), Least Laxity First (LLF)
15
Soft deadline
16
Schedulability
Property indicating whether a real-time system (a set of real-time tasks) can meet their deadlines
(4,1) (5,2) (7,2)
17
Real-Time Scheduling
Determines the order of real-time task executions Static-priority scheduling Dynamic-priority scheduling
(4,1) (5,2) (7,2)
5
5
10
10
15
15
18
RM (Rate Monotonic)
Optimal static-priority scheduling It assigns priority according to period A task with a shorter period has a higher priority Executes a job with the shortest period T1 (4,1) T2 (5,2) T3 (7,2)
5
5
10
10
15
15
19
RM (Rate Monotonic)
Executes a job with the shortest period
5
5
10
10
15
15
20
RM (Rate Monotonic)
Executes a job with the shortest period
Deadline Miss !
T1 (4,1) T2 (5,2) T3 (7,2)
5
5
10
10
15
15
21
5
5
10
10
15
15
22
5
5
10
10
15
15
23
5
5
10
10
15
15
24
5
5
10
10
15
15
25
5
5
10
10
15
15
26
T1 0 3
T2
T3 T4 5 6 7
Better schedules :
T1 0 3
T3 5 6 7 0
T1 3
T4 5 6 7
27
RM vs. EDF
Rate Monotonic Simpler implementation, even in systems without explicit support for timing constraints (periods, deadlines) Predictability for the highest priority tasks EDF Full processor utilization Misbehavior during overload conditions
28
Priority(P1) > Priority (P2) P1, P2 share a critical section (CS) P1 must wait until P2 exits CS even if P(P1) > P(P2) Maximum blocking time equals the time needed by P2 to execute its CS In general the blocking time cannot be bounded by CS of the lower priority process
It is a direct consequence of mutual exclusion
29
30
Priority Inheritance
Basic protocol [Sha 1990] 1.A job J uses its assigned priority, unless it is in its CS and blocks higher priority jobs In which case, J inherits PH, the highest priority of the jobs blocked by J When J exits the CS, it resumes the priority it had at the point of entry into the CS 2.Priority inheritance is transitive Advantage Transparent to scheduler Disadvantage Deadlock possible in the case of bad use of semaphores Chained blocking: if P accesses n resources locked by processes with lower priorities, P must wait for n CS
31
32
Deadlocks
33
34
Priority Ceiling
In priority ceiling protocol, each resource is assigned a priority ceiling, which is a priority equal to the highest priority of any task which may lock the resource. A task T is allowed to enter a critical section only if its assigned priority is higher than the priority ceilings of all semaphores currently locked by tasks other than T. Task T runs at its assigned priority unless it is in a critical section and blocks higher priority tasks. When a task exits the critical section it resumes the priority it had at the point of entry into the critical section. Prevents Deadlocks and Chained Blocking
35
36
If messages are sent more quickly than they can be handled, the OS provides message queues for holding the messages until they can be processed.
38
Message passing in OS
Most General Purpose OS actually copy messages twice as they transfer them from task to task via a message queue. Message Sender Task Message
RAM
Message RAM
39
RAM
msg_ptr msg_ptr
RTOS
40
Classification (based on architectures) and applications of various RTOS RTOS for small footprint, mobile and connected
devices
RTOS for complex, hard real-time applications
The real-time features of Windows CE 3.0, a highly modular real-time embedded OS for small footprint, mobile 32-bit intelligent connected devices.
LynxOS , a POSIX-compatible, multiprocess, multithreaded OS designed for complex real-time applications that require fast and deterministic response.
VxWorks, the most widely adopted RTOS in the embedded industry. VxWorks is a flexible, scalable RTOS with over 1800 APIs and is available on all popular CPU platforms.
41
Classification (based on architectures) and applications of various RTOS RTOS for the Java Platform
Objected-oriented RTOS
pSOSystem is a modular object-oriented operating system. The objects in pSOS include tasks, memory regions, message queues, and semaphores.
The Jbed RTOS package is a real-time capable virtual machine developed for embedded systems and Internet applications under the Java platform.
Adding real-time features to common general purpose operating systems viz., Windows NT and UNIX.
Real-time kernels such as Spring and Arx are used for ongoing research on RTOS
42