ES&RTOS Unit-2
ES&RTOS Unit-2
• OS services to Application
• GPOS – can also run embedded systems – having large memory and
soft real time systems
• RTOS – suited for low memory, hard real time systems, high
performance required
Defining an RTOS
• Objects – its special kernel constructs – helps to develop applications for Real time
embedded systems
• EX: Tasks, Semaphores, and Message queues
• A real-time kernel might have multiple tasks that it has to schedule to run
The Scheduler
The Scheduler
• In the above scenario, the kernel multitasks in such a way that many
threads of execution appear to be running concurrently;
• The scheduler must ensure that the appropriate task runs at the right
time
The Scheduler
• A context switch occurs when the scheduler switches from one task to another
• Every time a new task is created, the kernel also creates and maintains an associated task
control block (TCB).
• TCBs are system data structures that the kernel uses to maintain task-specific information.
• When a task is running, its context is highly dynamic
The Scheduler
• This dynamic context is maintained in the TCB.
• When the task is not running, its context is frozen within the TCB, to
be restored the next time the task runs
The Scheduler
The Scheduler
• When the kernel s scheduler determines that it needs to stop running task
1 and start running task 2, it takes the following steps:
1. The kernel saves task 1’s context information in its TCB.
2. It loads task 2’s context information from its TCB, which becomes the current
thread of execution.
3. The context of task 1 is frozen while task 2 executes, but if the scheduler needs to
run task 1 again, task 1 continues from where it left off just before the context
switch.
The Scheduler
• The time it takes for the scheduler to switch from one task to another
is the context switch time.
• It is relatively insignificant
• The Dispatcher
• The dispatcher is the part of the scheduler that performs context switching and
changes the flow of execution
• The dispatcher that does the actual work of context switching and passing execution
control
The Scheduler
• The Dispatcher working
• At any time an RTOS is running, the flow of execution, also known as
flow of control, is passing through one of three areas:
• through an application task, or
• through an ISR, or
• through the kernel.
• When a task or ISR makes a system call, the flow of control passes to
the kernel to execute one of the system routines provided by the
kernel.
The Scheduler
• It will not necessarily be the same task that made the system call.
• Scheduling Algorithms
• The scheduler determines which task runs by following a scheduling
algorithm - also known as scheduling policy
• Round-robin scheduling
• Predictability,
• Performance,
• Compactness,
• Scalability.
Key Characteristics of an RTOS - Reliability
• Embedded systems must be reliable
• Depending on the application, the system might need to operate for
long periods without human intervention
• Degrees of reliability
• Ex: Solar Calculator and Telecom Switch
• While RTOS’s must be reliable, note that the RTOS by itself is not what
is measured to determine system reliability
• It is the combination of all system elements-including the hardware,
BSP, RTOS, and application-that determines the reliability of a system
Key Characteristics of an RTOS - Reliability
• Acceptable Down Time
Number of 9s Downtime per year Typical application
3 Nines (99.9%) ~9 hours Desktop
4 Nines (99.99%) ~1 hour Enterprise Server
5 Nines (99.999%) ~5 minutes Carrier-class Server
6 Nines (99.9999%) ~31 seconds Carrier Switch Equipment
Key Characteristics of an RTOS - Predictability
• Many embedded systems are also real-time systems, meeting time
requirements is key for proper operation
• The RTOS used in this case needs to be predictable to a certain
degree.
• For this, operating system calls occurs within known timeframes.
• Developers can write simple benchmark programs to validate the
determinism of an RTOS
• In a good deterministic RTOS, the variance of the response times for
each type of system call is very small.
Key Characteristics of an RTOS - Performance
• This requirement dictates that an embedded system must perform
fast enough to fulfill its timing requirements
• The more deadlines to be met-and the shorter the time between
them-the faster the system's CPU must be.
• Underlying hardware can dictate a system's processing power, its
software can also contribute to system performance
• Typically, the processor's performance is expressed in million
instructions per second (MIPS).
Key Characteristics of an RTOS - Performance
• Throughput also measures the overall performance of a system, with
hardware and software combined
• Throughput : The rate at which a system can generate output based on the
inputs coming in. (or)
• Amount of data transferred divided by the time taken to transfer it
• Data transfer throughput is typically measured in multiples of bits per second
(bps)
• Sometimes developers measure RTOS performance on a call-by-call
basis
• Benchmarks are written by producing timestamps when a system call
starts and when it completes - helpful in the analysis stages of design
Key Characteristics of an RTOS - Compactness
• Application design constraints and cost constraints help determine how
compact an embedded system can be
• Ex: A cell phone clearly must be small, portable, and low cost.
• These design requirements limit system memory, which in turn limits the size of the
application and operating system
• In such embedded systems, where hardware real estate is limited due to
size and costs, the RTOS clearly must be small and efficient
• In these cases, the RTOS memory footprint can be an important factor.
• To meet total system designers must understand both the static and
dynamic memory consumption of the RTOS and the application that will
run on it.
Key Characteristics of an RTOS - Scalability
• RTOSes can be used in a wide variety of embedded systems, they
must be able to scale up or down to meet application-specific
requirements
• Depending on how much functionality is required, an RTOS should be
capable of adding or deleting modular components, including file
systems and protocol stacks.
• If an RTOS does not scale up well, development teams might have to
buy or build the missing pieces.
Key Characteristics of an RTOS - Scalability
• Suppose that a development team wants to use an RTOS for the
design of a cellular phone project and a base station project.
• If an RTOS scales well, the same RTOS can be used in both projects,
instead of two different RTOSes, which saves considerable time and
money.