Overview of RTOS

22
RTOS M. Muthu Senthil Kumar S. Rampraveen H & S Storage

description

RTOS

Transcript of Overview of RTOS

Page 1: Overview of RTOS

RTOS

M. Muthu Senthil Kumar

S. Rampraveen

H & S

Storage

Page 2: Overview of RTOS

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.

Page 3: Overview of RTOS

Differences

RTOS Standard OS

Page 4: Overview of RTOS

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.

Page 5: Overview of RTOS

Applications

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

Page 6: Overview of RTOS

Pictorial view

Kernel

MemoryMgmt

I/OSystem

FileSystems

DeviceDrivers

NetworkStack

Page 7: Overview of RTOS

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

Page 8: Overview of RTOS

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

Page 9: Overview of RTOS

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.

Page 10: Overview of RTOS

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.

Page 11: Overview of RTOS

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)

Page 12: Overview of RTOS

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.

Page 13: Overview of RTOS

Inter task commn

In order to access the shared resources safely

• semaphores

• messages

are used

Page 14: Overview of RTOS

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).

Page 15: Overview of RTOS

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.

Page 16: Overview of RTOS

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.

Page 17: Overview of RTOS

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

Page 18: Overview of RTOS

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.

Page 19: Overview of RTOS

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

Page 20: Overview of RTOS

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.

Page 21: Overview of RTOS

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)

Page 22: Overview of RTOS

Bibliography

www.Wikipedia.org

www.Netrino.com