overview of rtos
DESCRIPTION
RTOSTRANSCRIPT
RTOS
M. Muthu Senthil Kumar
S. Rampraveen
H & S
Storage
An Overview of RTOS
What is Real-Time ?
• Real-time denotes the ability of the control system to keep up with the system being controlled.
• Deterministic performance is key to real-time performance.
• RTOS multitasking OS intended for real time applications.
Differences
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.
Applications
• Embedded systems• household appliance controllers• Industrial Robots• Spacecrafts• Industrial control like SCADA• scientific research equipments.
Pictorial view
Kernel
MemoryMgmt
I/OSystem
FileSystems
DeviceDrivers
NetworkStack
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,ABSSoft real time systems tolerate the latency
and respond with retardation of quality.eg: video streaming
Basic Concepts contd…
Latency
a time delay between the moment an event is initiated and the moment its first effect begins.
- interrupt latency- thread switching latency
Scheduling
• 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.
Contd…
Three states of a task
1.running
2.ready
3.blocked
a task may be in any of these states while a process is carried on.
Rescheduling
• The method of changing the task’s state from one to another.
• Priority of the tasks play pivot role in rescheduling
Preemptive:• same priority tasks cant preemptive another• Rescheduling can occur at any time as a result of:
• Kernel calls• Interrupts (e.g.,System clock tick)
Contd..
Round robin:
Share the CPU among all ready tasks of same priority. Allows equal priority tasks to pre-empt each other
time slicing is usedPriority 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
• semaphores
• messages
are used
Semaphores
• A semaphore is a kernel primitive object.• Semaphore operations Can change a task’s 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.
Solution:• 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 C).
Handling multiple levels of inheritance without introducing instability in cycles is not straightforward
Deadlock
In a deadlock, two or more tasks lock a number of binary semaphores and then wait forever for other binary semaphores.
Messages are used to overcome this scenarioThe 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.
Interrupts
The tasks are also triggered by the events as interruptthrough an interface.
The interrupts are tabled as address vector entity and theroutines are defined as short as possible.
ISRs can give semaphores,message passing.
LimitationISRs should not take a semaphoreISRs must not call floating point functions implicitly
Timers
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) RTEMS (OAR) ThreadX (Express Logic) Linux/RT (TimeSys) VRTX (Mentor Graphics) VxWorks (Wind River)
Bibliography
www.Wikipedia.org
www.Netrino.com