An RTOS is an OS for response time-controlled and event-
controlled processes. It is very essential for large scale embedded
systems.
RTOS occupy little space from 10 KB to 100KB The
main task of a RTOS is to manage the
resources of the computer such that a particular operation
executes in precisely the same amount of time every time it occur.
Hard Real time system: Failure to meet such a deadline
is considered to be a fatal fault and will lead to disastrous
consequences e.g. Response of the break system of a
speeding Train approaching a Red Signal to the stop
command must come before the train crosses the Red signal.
Soft Real time system : Failure to miss a Soft Deadline
is undesirable but a few misses does no serious harm like
occasional delay in an on line trading of stocks. However the
system’s overall performance becomes poorer and poorer as
more and more jobs starts missing the deadline.
The most important component of RTOS
is its kernel (Monolithic & Microkernel).
BSP or Board Support Package makes an
RTOS target-specific (It’s a processor
specific code onto (processor) which we
like to have our RTOS running).
8051, ARM7,ARM9, Intel
Xscale, AVR, Blackfin, C167, Coldfire,, MIPS, MSP430, PIC, PowerPC, R
8C, SHARC, ST6, SuperH, TLCS-47, TLCS-870, TLCS-900, Tricore, etc.
1. Task Management
2. Intertask Communication &
Synchronization
3. Dynamic Memory Allocation
4. Timers
5. Devices I/O Supervisor
An operating system generally consists of two parts:
kernel space (kernel mode) and user space (user mode).
Kernel is the smallest and central component of an
operating system.
Its services include managing memory and devices and
also to provide an interface for software applications to
use the resources.
Additional services such as managing protection of
programs and multitasking may be included depending
on architecture of operating system.
There are three broad categories of kernel models
available, namely:
Monolithic kernel
Microkernel
Exokernel
These are the embedded program that run on CPU.
It consist of :
 Sequentially executable program
 State information
Task states consists of
1. Idle
2. Ready
3. Running
4. Blocked
5. Deleted
Idle
Task is created and memory is allocated but it is not
scheduled by kernel.
Ready
Task is ready and scheduled by kernel but not running
Running state :
Task will be running it will need some input
Blocked state :
Execution of the codes terminates after saving the needed
parameter
Deleted state :
The task created the memory has been de allocated and
frees the memory.
 Direct call to an ISR
1. Process running at CPU is interrupted and ISR starts
executing
2. ISR sends a enter message to RTOS
3. ISR code can send into mailbox
4. When the ISR completes the execution it sends Exist
message to OS
1. RTOS first itself gets the hardware source call
2.Initiates the ISR for saving the processor
status.
3. ISR during execution can post 2 or more
outputs.
4. Message is send
5.Involves the one ISR function and two
processes
Multiprocessing :
 Ability of an operating system to have
multiple programs.
 In uniprocessor system this wont be
possible.
Multitasking :
 Ability of an operating system to have
multiple process in memory .
 Co-operative multitasking
Holds CPU as much time it needs for executing
 Preemptive multitasking
Ensures every task will get a chance for
processing
 Non- Preemptive multitasking
Process or task given can be executed until it
terminates
The scheduler keeps record of the state of each task
and selects from among them that are ready to
execute and allocates the CPU to one of them.
A scheduler helps to minimize CPU utilization
among different tasks in a multi-tasking program and
to minimize waiting time.
There are generally two types of schedulers: non-
preemptive and priority-based preemptive.
•Non-preemptive scheduling or cooperative multitasking requires the tasks
to cooperate with each other to explicitly give up control of the processor.
•When a task releases the control of the processor, the next most important
task that is ready to run will be executed.
•A task that is newly assigned with a higher priority will only gain control of
the processor when the current executing task voluntarily gives up the
control.
•Priority-based preemptive scheduling requires control of the
processor be given to the task of the highest priority at all
•time.
•In the event that makes a higher priority task ready to run,
the current task is immediately suspended and the control of
the processor is given to the higher priority task.
In RTOS, the OS copies a pointer to the
message, delivers the pointer to the message-receiver
task, and then deletes the copy of the pointer with
message-sender task.
Message Sender
Task
RAM
Message Receiver
Task
RTOS
msg_ptr
msg_ptr
Message Message
in RTOS
RTOS does it by a mechanism known as Pools.
Pools memory allocation mechanism allows application software to
allocate chunks of memory of 4 to 8 different buffer sizes per
pool.
Pools avoid external memory fragmentation, by not permitting a
buffer that is returned to the pool to be broken into smaller
buffers in the future.
20
Intertask communication involves sharing of data
among tasks through sharing of memory space,
transmission of data and etc.
Few of mechanisms available for executing intertask
communications includes:
Message queues
Pipes
Remote procedural calls (RPC)
 It is a variable or signal which provides
synchronization mechanism
 synchronization mechanism is required at the
entry and the exist of critical section .
 Two purposes:
Mutex- ensures the thread doesn’t access the
cirtical section at the same time .
Scheduling constraints –ensures the thread
operates at specific order.
 When the semaphore is used at the beginning
and the end of critical section in that case
only one section code can run then the
semaphore.
 A piece of code that access a shared resource
but that must not be used by one or more
thread at the same time
 Deadlock – two or more processes are waiting indefinitely for
an event that can be caused by only one of the waiting
processes
 Let S and Q be two semaphores initialized to 1
P0 P1
wait (S); wait (Q);
wait (Q); wait (S);
Starvation: indefinite blocking. A process may never
be removed from the semaphore queue in which it
is suspended
Consider the executions of four periodic threads: A, B, C, and D; two
resources : Q and V
Thread Priority Execution Sequence Arrival Time
 A 1 EQQQQE 0
 B 2 EE 2
 C 3 EVVE 2
 D 4 EEQVE 4
Where E is executing for one time unit, Q is accessing resource Q for one time
unit, V is accessing resource V for one time unit
 From the previous figure we can see that thread D has the
higher priority and finished the last one, this is the problem
of priority inversion ( the threads with medium priority
suspend the higher priority threads) .
 Priority Inheritance: Let the lower priority task use the
highest priority of the higher priority tasks it blocks. In this
way, the medium priority tasks can no longer preempt low
priority task , which has blocked the higher priority task.
 Linux
◦ Is Linux
◦ Runs on anything, even toasters
◦ Hardware support for anything
◦ Linux
◦ RTLinux
◦ RTAI
◦ RTEMS
◦ QNX
◦ VxWorks
◦ LynxOS

Rtos

  • 2.
    An RTOS isan OS for response time-controlled and event- controlled processes. It is very essential for large scale embedded systems. RTOS occupy little space from 10 KB to 100KB The main task of a RTOS is to manage the resources of the computer such that a particular operation executes in precisely the same amount of time every time it occur.
  • 3.
    Hard Real timesystem: Failure to meet such a deadline is considered to be a fatal fault and will lead to disastrous consequences e.g. Response of the break system of a speeding Train approaching a Red Signal to the stop command must come before the train crosses the Red signal. Soft Real time system : Failure to miss a Soft Deadline is undesirable but a few misses does no serious harm like occasional delay in an on line trading of stocks. However the system’s overall performance becomes poorer and poorer as more and more jobs starts missing the deadline.
  • 4.
    The most importantcomponent of RTOS is its kernel (Monolithic & Microkernel). BSP or Board Support Package makes an RTOS target-specific (It’s a processor specific code onto (processor) which we like to have our RTOS running). 8051, ARM7,ARM9, Intel Xscale, AVR, Blackfin, C167, Coldfire,, MIPS, MSP430, PIC, PowerPC, R 8C, SHARC, ST6, SuperH, TLCS-47, TLCS-870, TLCS-900, Tricore, etc.
  • 5.
    1. Task Management 2.Intertask Communication & Synchronization 3. Dynamic Memory Allocation 4. Timers 5. Devices I/O Supervisor
  • 6.
    An operating systemgenerally consists of two parts: kernel space (kernel mode) and user space (user mode). Kernel is the smallest and central component of an operating system. Its services include managing memory and devices and also to provide an interface for software applications to use the resources. Additional services such as managing protection of programs and multitasking may be included depending on architecture of operating system. There are three broad categories of kernel models available, namely: Monolithic kernel Microkernel Exokernel
  • 7.
    These are theembedded program that run on CPU. It consist of :  Sequentially executable program  State information Task states consists of 1. Idle 2. Ready 3. Running 4. Blocked 5. Deleted
  • 8.
    Idle Task is createdand memory is allocated but it is not scheduled by kernel. Ready Task is ready and scheduled by kernel but not running Running state : Task will be running it will need some input Blocked state : Execution of the codes terminates after saving the needed parameter Deleted state : The task created the memory has been de allocated and frees the memory.
  • 9.
     Direct callto an ISR
  • 10.
    1. Process runningat CPU is interrupted and ISR starts executing 2. ISR sends a enter message to RTOS 3. ISR code can send into mailbox 4. When the ISR completes the execution it sends Exist message to OS
  • 12.
    1. RTOS firstitself gets the hardware source call 2.Initiates the ISR for saving the processor status. 3. ISR during execution can post 2 or more outputs. 4. Message is send 5.Involves the one ISR function and two processes
  • 13.
    Multiprocessing :  Abilityof an operating system to have multiple programs.  In uniprocessor system this wont be possible. Multitasking :  Ability of an operating system to have multiple process in memory .
  • 14.
     Co-operative multitasking HoldsCPU as much time it needs for executing  Preemptive multitasking Ensures every task will get a chance for processing  Non- Preemptive multitasking Process or task given can be executed until it terminates
  • 15.
    The scheduler keepsrecord of the state of each task and selects from among them that are ready to execute and allocates the CPU to one of them. A scheduler helps to minimize CPU utilization among different tasks in a multi-tasking program and to minimize waiting time. There are generally two types of schedulers: non- preemptive and priority-based preemptive.
  • 16.
    •Non-preemptive scheduling orcooperative multitasking requires the tasks to cooperate with each other to explicitly give up control of the processor. •When a task releases the control of the processor, the next most important task that is ready to run will be executed. •A task that is newly assigned with a higher priority will only gain control of the processor when the current executing task voluntarily gives up the control.
  • 17.
    •Priority-based preemptive schedulingrequires control of the processor be given to the task of the highest priority at all •time. •In the event that makes a higher priority task ready to run, the current task is immediately suspended and the control of the processor is given to the higher priority task.
  • 18.
    In RTOS, theOS copies a pointer to the message, delivers the pointer to the message-receiver task, and then deletes the copy of the pointer with message-sender task. Message Sender Task RAM Message Receiver Task RTOS msg_ptr msg_ptr Message Message
  • 19.
    in RTOS RTOS doesit by a mechanism known as Pools. Pools memory allocation mechanism allows application software to allocate chunks of memory of 4 to 8 different buffer sizes per pool. Pools avoid external memory fragmentation, by not permitting a buffer that is returned to the pool to be broken into smaller buffers in the future.
  • 20.
    20 Intertask communication involvessharing of data among tasks through sharing of memory space, transmission of data and etc. Few of mechanisms available for executing intertask communications includes: Message queues Pipes Remote procedural calls (RPC)
  • 21.
     It isa variable or signal which provides synchronization mechanism  synchronization mechanism is required at the entry and the exist of critical section .  Two purposes: Mutex- ensures the thread doesn’t access the cirtical section at the same time . Scheduling constraints –ensures the thread operates at specific order.
  • 22.
     When thesemaphore is used at the beginning and the end of critical section in that case only one section code can run then the semaphore.  A piece of code that access a shared resource but that must not be used by one or more thread at the same time
  • 23.
     Deadlock –two or more processes are waiting indefinitely for an event that can be caused by only one of the waiting processes  Let S and Q be two semaphores initialized to 1 P0 P1 wait (S); wait (Q); wait (Q); wait (S); Starvation: indefinite blocking. A process may never be removed from the semaphore queue in which it is suspended
  • 24.
    Consider the executionsof four periodic threads: A, B, C, and D; two resources : Q and V Thread Priority Execution Sequence Arrival Time  A 1 EQQQQE 0  B 2 EE 2  C 3 EVVE 2  D 4 EEQVE 4 Where E is executing for one time unit, Q is accessing resource Q for one time unit, V is accessing resource V for one time unit
  • 26.
     From theprevious figure we can see that thread D has the higher priority and finished the last one, this is the problem of priority inversion ( the threads with medium priority suspend the higher priority threads) .  Priority Inheritance: Let the lower priority task use the highest priority of the higher priority tasks it blocks. In this way, the medium priority tasks can no longer preempt low priority task , which has blocked the higher priority task.
  • 28.
     Linux ◦ IsLinux ◦ Runs on anything, even toasters ◦ Hardware support for anything
  • 29.
    ◦ Linux ◦ RTLinux ◦RTAI ◦ RTEMS ◦ QNX ◦ VxWorks ◦ LynxOS