You are on page 1of 23

Embedded System

UNIT -2

K.B.Sathya
Asst Professor
Sathyabama University
RTOS
• RTOS-Real Time Operating System
• Two features of RTOS
predictability and determinism.
• Real Time Applications
• Airline traffic control systems, Command Control Systems, Airlines
reservation system, Heart Pacemaker, Network Multimedia Systems,
Robot etc
• Task and task states
Task
• A task is also called a thread 
• Task is the executing unit of computation, which is controlled by OS
Task States
Depending upon the execution, task has three types namely

A task's state can be defined as follows:

enum TaskState {Ready, Running, Waiting};


Memory management
In general, a kernel’s memory management responsibilities include:
• Managing the mapping between logical (physical) memory and task memory references.
• Determining which processes to load into the available memory space.
• Allocating and deallocating of memory for processes that make up the system.
• Supporting memory allocation and deallocation of code requests (within a process),
such as the C language
“alloc” and “dealloc” functions, or specific buffer allocation and deallocation routines.
• Tracking the memory usage of system components.
• Ensuring cache coherency (for systems with cache).
• Ensuring process memory protection.
Semaphore and types
Semaphores are integer variables that are used to
solve the critical section problem by using two atomic
operations, wait and signal 
Wait and signal
The definitions of wait and signal are as follows −
•Wait
The wait operation decrements the value of its argument S, if it is positive. If S is negative or zero, then no operation is performed.
wait(S) {    while (S<=0);    S--; }
•Signal
The signal operation increments the value of its argument S.
signal(S) {    S++; }

Advantages:
Semaphores allow only one process into the critical section.
They follow the mutual exclusion principle strictly
much more efficient than some other methods of synchronization
Machine independent
Disadvantages:
Semaphores are complicated so the wait and signal operations must be implemented in the correct order to
prevent deadlocks.
Semaphores are impractical due to loss of modularity.
Semaphores may lead to a priority inversion where low priority processes may access the critical section first
and high priority processes later.
Three major categories
• Binary
• Counting
• Mutual exclusion
Binary
• A binary semaphore can have a value of either 0 or 1.
• When a binary semaphore’s value is 0, the semaphore is considered
unavailable (or
• empty);when the value is 1, the binary semaphore is considered
available (or full).
• Note that when a binary semaphore is first created, it can be
initialized to either available
• orunavailable (1 or 0, respectively).
Count
• A counting semaphore uses a count to allow it to be acquired or released
multiple times.
• When creating a counting semaphore, assign the semaphore a count that
denotes the
• numberof semaphore tokens it has initially.
• If the initial count is 0, the counting semaphore is created in the
unavailable state.
• If the count is greater than 0, the semaphore is created in the available
state, and the number
• oftokens it has equals its count
Mutual exclusion
• A mutual exclusion (mutex) semaphore is a special binary semaphore
thatsupports
• ownership, recursive access, task deletion safety, and one or more
protocols for avoiding
• problems inherent to mutual exclusion
Interrupt routines in RTOS environment
• Interrupt Service Routine (ISR) –block of code- determining which hardware device
requires servicing,

Two rules
• An interrupt routine must not call any RTOS functions that might block. could block
the highest priority task. ...
• An interrupt routine must not call any RTOS function that might cause the RTOS to
switch tasks.
Two case:
Low level
High level
Basic Design Using RTOS
RTOS stands for Real-Time Operating System.
As the name suggests, it is an operating system (OS) that is designed to process or respond to incoming data
in real time – but what does “real time” mean?

Real time systems are time-bound systems that have strict timing constraints and requirements.
That means that the processor must complete each task within their given time constraints so that the following
task can be executed on time, otherwise the system is considered to have failed.

The true value of RTOS, however, lies in its ability to maintain timing requirements while enabling
multitasking.

Today, RTOS are used in many embedded applications, such as:


•Medical Equipment such as Pacemakers
•Defence Systems, such as Radars
•Air Traffic / Aircraft Control Systems
•Networked Multimedia Systems
What are the benefits of RTOS?
Traditionally, microcontroller programming involves sequential processing loops and
state machines. While that is typically sufficient for smaller applications, many issues arise
when application complexity is increased.

One key problem lies in the fact that sequential code runs line by line to completion and
cannot truly be interrupted.

Continuing with our previous example: Once we call the function to maintain the server
connection, the code must run to completion before any further action can be taken. On a large
scale, this may introduce significant delays and make timing requirements difficult to meet
without an RTOS.
Types of RTOS
•Hard Real Time – Task timings and deadlines are handled very strictly. (eg. critical
healthcare, aircraft systems)
•Firm Real Time – Deadlines need to be followed, but not as strictly. (eg. video conferencing,
GPS tracking)
•Soft Real Time – Timing constraints are not expressed as absolute values. (eg. online
transactions, web browsing)
RTOS Characteristics

•Performance –High performance
•Features – eg. dynamic memory allocation
•Cost –High
•Ecosystem – The RTOS run on a variety of microprocessor architectures
Regular OS Real-Time OS (RTOS)

 Complex               Simple

 Best effort  Guaranteed response 

 Fairness  Strict Timing constraints

 Average Bandwidth        Minimum and maximum limits    

 Unknown components      Components are known   

 Unpredictable behavior               Predictable behavior

 Plug and play  RTOS is upgradeable


Structure of RTOS

You might also like