Vous êtes sur la page 1sur 22


M. Muthu Senthil Kumar

S. Rampraveen

H & S
An Overview of RTOS
What is Real-Time ?

Real-time denotes the ability of the control
system to keep up with the system being
Deterministic performance is key to real-time
RTOS multitasking OS intended for real time

RTOS Standard OS
Features of RTOS
- Multitasking.
- Task scheduling.
- Inter task communication.
- Inter task synchronization.
- Interrupt Handling.
- Exception handling.
- Memory Management
- Timers
- Performance evaluation.
- Scalability.
- BSP to isolate H/W.

Embedded systems
household appliance controllers
Industrial Robots
Industrial control like SCADA
scientific research equipments.

Pictorial view

Basic Concepts
Hard & Soft Real-time systems
Hard real time systems are used when it is
imperative that an event is reacted to within a
strict deadline.
eg: pacemaker,ABS
Soft real time systems tolerate the latency
and respond with retardation of quality.
eg: video streaming

Basic Concepts contd

a time delay between the moment an event is
initiated and the moment its first effect begins.

- interrupt latency
- thread switching latency

Preemptive scheduling

It (Event-driven designs priority scheduling) designs
switchs tasks only when an event of higher priority needs
service, called preemptive priority

Round Robin

It (Time-sharing designs) switch tasks on a clock
interrupt, and on events, called round robin.

Three states of a task
a task may be in any of these states while a process is
carried on.
The method of changing the tasks state from one to
Priority of the tasks play pivot role in rescheduling

same priority tasks cant preemptive another
Rescheduling can occur at any time as a result of:
Kernel calls
Interrupts (e.g.,System clock tick)


Round robin:
Share the CPU among all ready tasks of same
Allows equal priority tasks to pre-empt each
time slicing is used
Priority scheduling always takes precedence.
If pre-empted by higher priority task, remaining
time count is saved.
Priority based rescheduling can happen any time.
- Round-robin rescheduling can only happen every
few clock ticks.

Inter task commn

In order to access the shared resources safely

are used
A semaphore is a kernel primitive object.
Semaphore operations Can change a tasks state. The
Semaphores are fast.
Three semaphore types available
1) Binary semaphores allow a task to block until a
given event occurs (e.g., an interrupt).
2) Counting semaphores. They can store a value. Less
commonly used.
3) Mutual exclusion semaphores allow a task to
acquire an exclusive lock to a shared resource (e.g., a
file or a device).

Task Synchronisation requirements
The task may need to wait for an event to occur.
Busy waiting for the event to happen ( Polling) is very inefficient.
Blocking until the event happens is much better.
Create a binary semaphore for the event.
Binary semaphores exist in one of two states:
Full (event has occurred)
Empty (event has not occurred).
Task waiting for the event calls take a semaphore , and blocks
until semaphore is given.
Task or interrupt service routine detecting the event calls
gives out semaphore , which unblocks the waiting task.

Multi task sync
all the tasks waiting for its semaphore are unblocked
by either giving out semaphore or deleting it.

the tasks that came to the ready state are arranged
according to their priority.

Priority inversion

In priority inversion, a high priority task waits
because a low priority task has a semaphore.

Solution is to have the task that has a semaphore run
at (inherit) the priority of the highest waiting task.
But this simplistic approach fails when there are
multiple levels of waiting (A waits for a binary semaphore
locked by B, which waits for a binary semaphore locked by
Handling multiple levels of inheritance without
introducing instability in cycles is not straightforward


In a deadlock, two or more tasks lock a number of
binary semaphores and then wait forever for other binary
Messages are used to overcome this scenario
The messages are passed between the task and higher
priority task to avoid the semaphore dependency.
Protocol deadlocks occur when two or more tasks
wait for each other to send response messages.

The tasks are also triggered by the events as interrupt
through an interface.
The interrupts are tabled as address vector entity and the
routines are defined as short as possible.
ISRs can give semaphores,message passing.

ISRs should not take a semaphore
ISRs must not call floating point functions implicitly


The timers generate a CPU interrupt at each of its tick.

They provide to have user routines for a periodic interval

Watch dogs:
To run a routine after the expiration of a delay.

Some RTOS Vendors
RTX (CMX Systems) eCos (Red Hat)
INTEGRITY (Green Hills Software)
LynxOS (LynuxWorks)
C/OS-II (Micrium) Nucleus (Mentor Graphics)
RTOS-32 (OnTime Software) OS-9 (Microware)
OSE (OSE Systems)
pSOSystem (Wind River)
QNX (QNX Software Systems)
Quadros (RTXC)
ThreadX (Express Logic)
Linux/RT (TimeSys)
VRTX (Mentor Graphics)
VxWorks (Wind River)