2. RTOS
• As the complexities in the embedded applications increase,
use of an operating system brings in lot of advantages.
• Most embedded systems also have real-time requirements
demanding the use of Real time Operating Systems (RTOS)
capable of meeting the embedded system requirements.
• Real-time Operating System allows realtime applications to be
designed and expanded easily.
• The use of an RTOS simplifies the design process by splitting
the application code into separate tasks.
• An RTOS allows one to make better use of the system
recourses by providing with valuable services such as
semaphores, mailboxes, queues, time delays, time outs…etc.
3. RTOS
• One major subclass of embedded systems is real-time
embedded systems.
• A real time system is one that has timing constraints.
• Real-time system’s performance is specified in terms of ability
to make calculations or decisions in a timely manner.
• These important calculations have deadlines for completion.
• For example if the real-time system is a part of an airplane’s
flight control system, single missed deadline is sufficient to
endanger the lives of the passengers and crew.
4. WHAT IS AN OPERATING SYSTEM?
• The operating system organizes and controls the hardware and
it is that piece of software that turns the collection of hardware
blocks into a powerful computing tool.
• Broadly the tasks of the Operating system are:
• Processor Management
– Each process and application receives enough of the
processor's time to function properly
– maximum processor cycles for real work as is possible and
switch between processes in a multi-tasking environment.
• Memory and Storage Management
• Device Management
5. OS
• Providing Common Application Interface
– The programmer uses the APIs, the operating system, connected to
drivers for the various hardware subsystems, deals with the changing
details of the hardware.
• Providing Common User Interface
– interaction between a user and the computer
– area of the graphical user interface (GUI).
6. Basic functions of OS
• Process management
• Memory management
• Interrupt handling
• Exception handling
• Process Synchronization (IPC)
• Process scheduling
• Disk management
7. Types
• Four types of Operating systems, based on the kind of
applications they support are:
• Single-user, single task: Palm OS for Palm hand-held
computers
• Single-user, multi-tasking: desktop and laptop computers
• Multi-user: Various users are balanced, Unix is an example of
multi-user operating system.
• Real-time operating system (RTOS)-manage the resources of
the computer such that a particular operation executes in
precisely the same amount of time every time it occur.
8. RTOS
• “A good RTOS is one that has a bounded (predictable)
behavior under all system load scenario i.e. even under
simultaneous interrupts and thread execution
• RTOS occupy little space from 10 KB to 100KB as compared
to the General Operating systems which take hundreds of
megabytes
9. WHY OPERATING SYSTEMS FOR REAL-TIME APPLICATIONS
• complexity of applications expands beyond simple
tasks eg: PDAs, cell phones, VCRs, industrial robot
control.
• meet the system response requirements
• to be designed and expanded easily.
• It allows one to make better use of the system
resources by providing valuable services such as
semaphores, mailboxes, queues, time delays, time
outs…etc.
10. Basic functions of RTOS kernel
• Task management
• Interrupt handling
• Memory management
– no virtual memory for hard RT tasks
• Exception handling
• Task synchronization
– Avoid priority inversion
• Task scheduling
• Time management
12. Task
• Task = thread (lightweight process)
– A sequential program in execution
– It may communicate with other tasks
– It may use system resources
• We may have timing constraints for tasks
• Task Classification by deadlines
– Hard RT task must be computed within the given deadline (otherwise system
failure), e.g ABS control(anti-lock braking system)
– Soft RT task may be computed after the given deadline e.g.Multi-
media, the web etc
– On-time RT tasks (e.g alarm, robotics)
13. Signals in real-time systems can be classified based on their arrival time and
occurrence patterns
• 1. Periodic Signals:
• Arrival Time: Periodic signals have a regular and predictable
arrival time. They repeat their pattern or waveform at fixed
intervals. Occurrence Pattern: The signal occurrence follows
a well-defined periodic schedule.
• Ex: Clock signals, sensor readings in a control loop with a fixed
sampling rate, and regularly scheduled data transmissions in
communication
14. • 2. Aperiodic Signals:
• Arrival Time: Aperiodic signals do not have a
regular or predictable arrival time. They may occur
sporadically or in response to specific events.
• Occurrence Pattern: The signal occurrence is
irregular and does not follow a fixed schedule. Ex:
Event-driven signals, interrupts in response to
external stimuli, and sporadic data transmissions
triggered by certain conditions.
15. • Periodic Signals: Fixed-priority scheduling
algorithms can be effective for handling
periodic tasks with predictable arrival times.
• Rate-monotonic scheduling assigns higher
priorities to tasks with shorter periods.-
Aperiodic Signals: Earliest Deadline First
(EDF) scheduling can be suitable for a mix of
periodic and aperiodic tasks.
16. Task Classification
• Periodic tasks
– arriving at fixed frequency, can be characterized by 3 parameters (C,D,T)
where
C = computing time
D = deadline
T = period (e.g. 20ms, or 50HZ)
– Also called Time-driven tasks, their activations are generated by timers
• Non-Periodic or aperiodic tasks
– all tasks that are not periodic, also known as Event-driven,
– activations are generated by interrupts
• Sporadic tasks
– aperiodic tasks with minimum interarrival time Tmin
19. Interrupt Handling
• Types of interrupts
Asynchronous (or hardware interrupt) by hardware event (timer, network card
…)
• Synchronous (or software interrupt, or a trap) by software instruction (swi in
ARM, int in Intel 80x86), a divide by zero, a memory segmentation fault, etc.
Challenges in RTOS
• Interrupt latency
– The time between the arrival of interrupt and the start of corresponding
ISR.
– Modern processors with multiple levels of caches and instruction pipelines
that need to be reset before ISR can start might result in longer latency.
• Interrupt enable/disable
– The capability to enable or disable (“mask”) interrupt individually.
• Interrupt priority
– the ISR of a lower-priority interrupt is preempted by a higher-priority
interrupt.
20. Memory Management/Protection
• Standard methods
– Block-based, Paging, hardware mapping for protection
• No virtual memory for hard RT tasks
– Lock all pages in main memory
• Many embedded RTS do not have memory protection – tasks
may access any blocks
– to achieve predictable timing
– to avoid time overheads
• Most commercial RTOS provide memory protection as an
option
– Run into ”fail-safe” mode if an illegal access trap occurs
– Useful for complex reconfigurable systems
21. Exception handling & Task Synchronization
• Exceptions e.g missing deadline, running out of memory, timeouts,
deadlocks
– Error at system level, e.g. deadlock
– Error at task level, e.g. timeout
• Standard techniques:
– System calls with error code
– Watch dog
– Fault-tolerance (later)
• Task Synchronization
– Synchronization primitives
a) Semaphore
b) Mutex
c) Spinlock
d) Read/write locks
e) Barrier
24. Real time system characteristics:
Hard real time - ex. Airbags, ABS and antimissile system.
Firm real time - DVD with audio or video lag
Soft real time - Air conditioner
26. Application
System Calls
File Systems / Device
Drivers
Processor,
Peripherals, Memory.
Process Control
- Scheduler, Memory
Management, Inter
Communication
Kernel Architecture
34. Real-Time Operating Systems
A real-time operating system (RTOS) is a program that schedules execution in a
timely manner, manages system resources, and provides a consistent foundation
for developing application code.
For example, in some applications, an RTOS comprises only a kernel, which is the
core supervisory software that provides minimal logic, scheduling, and resource-
management algorithms. Every RTOS has a kernel.
Board specific drivers
with board support
package
Portable operating
system interface
35. Most RTOS kernels contain the following components:
Scheduler-is contained within each kernel and follows a set of algorithms that determines
which task executes when. Some common examples of scheduling algorithms include round-
robin and preemptive scheduling.
Objects-are special kernel constructs that help developers create applications for real time
embedded systems. Common kernel objects include tasks, semaphores, and message queues.
Services-are operations that the kernel performs on an object or, generally operations
such as timing, interrupt handling, and resource management.
36. The Scheduler
The scheduler is at the heart of every kernel. A scheduler provides the algorithms
needed to determine which task executes when.
Scheduling describes the following;
schedulable entities,
multitasking,
context switching,
dispatcher, and
scheduling algorithms.
A schedulable entity is a kernel object that can compete for execution time on a
system, based on a predefined scheduling algorithm.
Tasks and processes are all examples of schedulable entities found in most kernels.
A task is an independent thread of execution that contains a sequence of
independently schedulable instructions.
Processes are similar to tasks in that they can independently compete for CPU
execution time.
Processes differ from tasks in that they provide better memory protection features,
at the expense of performance and memory overhead.
37. Multitasking
Multitasking is the ability of the operating system to handle multiple activities within set
deadlines. A real-time kernel might have multiple tasks that it has to schedule to run.
An important point to note here is that the tasks follow the kernel’s scheduling algorithm, while
interrupt service routines (ISR) are triggered to run because of hardware interrupts and their
established priorities.
As the number of tasks to schedule increases, so do CPU performance requirements. This fact is
due to increased switching between the contexts of the different threads of execution.`
38. The Context Switch
Each task has its own context, which is the state of the CPU registers required each time it is
scheduled to run. 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. TCBs contain everything a kernel needs to know about a particular task.
When a task is running, its context is highly dynamic. 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.
39. The Dispatcher
The dispatcher is the part of the scheduler that performs context switching and changes the
flow of execution. 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, 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.
Scheduling Algorithms
preemptive priority-based scheduling
round-robin
41. RTOS Vendors
• QNX RTOS v6.1
– client-server based architecture.
• VRTX
– multitasking facility to solve the real-time performance
requirements found in embedded systems
• POSIX
– POSIX 1003.1a- Defines interface to basic OS fn
– POSIX 1003.1a
• Timers,
• Priority scheduling
• Semaphore, Memory queue and shared memory
42. Real-time systems are designed to respond to input or events within a
specified time frame, making them crucial for applications where timing and
predictability .
1.Aviation Systems: Flight control systems and air traffic control systems
require real-time processing to ensure the safety and efficiency of air travel.
2.Automotive Systems: Modern vehicles use real-time systems for functions
such as engine control, anti-lock braking systems (ABS), and advanced driver
assistance systems (ADAS).
3. Industrial Automation: Manufacturing and process control systems often
utilize real-time capabilities to monitor and control machinery and
43. processes.
4. Telecommunications: Networks rely on real-time systems to manage
call routing, data transfer, and other communication protocols.
5. Medical Devices: Devices such as pacemakers and infusion pumps
require real-time processing to ensure timely and accurate responses to
physiological signals.
6. Financial Trading Systems: High-frequency trading systems operate in
real-time to execute trades within extremely short time frames.
7. Gaming: Real-time processing is critical in the gaming industry to
provide seamless and responsive user experiences
.
44. • Real-time systems can be classified based on various criteria, including their timing
constraints, criticality, and applications.
• classifications of real-time systems:
• 1. Hard Real-Time Systems: - Hard real-time systems have strict and non-
negotiable timing constraints. Failure to meet these deadlines can result in
catastrophic consequences.
• Ex: Flight control systems, medical devices, automotive airbag deployment
systems.
• 2. Soft Real-Time Systems- Soft real-time systems have timing constraints that are
important but not critical. Missing a deadline in a soft real-time system may
degrade performance but does not lead to catastrophic failures.
• Ex: Streaming media applications, online gaming, multimedia systems.
45. • 3. Firm Real-Time Systems: Firm real-time systems have deadlines that are
important, and a late response is tolerable for a certain period. However, a response
after the specified time period is considered useless. - Ex: Online financial trading
systems, industrial automation systems.
• 4. Event-Driven Systems
• Event-driven real-time systems respond to external events or stimuli. These
systems are designed to react to specific occurrences in a timely manner.
• Ex: Embedded systems in smart appliances, traffic signal control systems.
• 5. Time-Triggered Systems: Time-triggered real-time systems operate based on a
predetermined schedule or time intervals. Actions are initiated at specific time
points.
Ex: Automotive control systems, industrial process control.
46. • 6. Control Systems: Control systems regulate the behavior of dynamic processes or
devices. They continuously monitor and adjust the system's output to achieve a
desired response.
• Ex: Flight control systems, industrial process control, robotics.
• 7. Embedded Real-Time Systems: Embedded real-time systems are integrated into
larger systems and are dedicated to specific tasks. They often operate within
resource-constrained environments. -
• Ex: Microcontroller-based systems in appliances, automotive engine control units.
47. • 8. Distributed Real-Time Systems: Distributed real-time systems involve multiple
interconnected nodes or processors working together to achieve a common goal. These
systems may be geographically distributed. Ex:Networked control systems,
distributed industrial automation.
• 9. Networked Real-Time Systems: - Networked real-time systems involve
communication and coordination between multiple entities over a network. Timing
constraints are considered in the networked communication. - Ex:Telecommunication
systems, distributed databases with real-time requirements.
• 10. Critical Real-Time Systems: Critical real-time systems are those where failure to
meet timing constraints can result in severe consequences, including loss of life or
significant damage.
• Ex: Nuclear reactor control systems, medical life support systems.These classifications
help in understanding the diverse nature of real-time systems and their specific
requirements based on the application context. The choice of classification depends on
the system's purpose, criticality, and the consequences of not meeting timing
constraints.
Editor's Notes
#25:Soft-real:even after the dead lines tasks can be completed but system won’t be collapsed.
Hard-real time: system may collapse. Ex:flight control.