Real-Time Operating Systems RTOS

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 38

Real-Time Operating Systems

RTOS

For Embedded systems

BY Abebe B.
Real-Time Systems
• Result in severe consequences if logical
and timing correctness are not met
• Two types exist
– Soft real-time
• Tasks are performed as fast as possible
• Late completion of jobs is undesirable but not
fatal.
• System performance degrades as more & more
jobs miss deadlines.
Real-Time Systems (cont.)
– Hard real-time
• Tasks have to be performed on time
• Failure to meet deadlines is fatal
• Example :
– Flight Control System
Hard and Soft Real Time Systems
(Operational Definition)

• Hard Real Time System


– Validation by provably correct procedures
or extensive simulation that the system
always meets the timings constraints
• Soft Real Time System
– Demonstration of jobs meeting some
statistical constraints suffices.
• Example – Multimedia System
– 25 frames per second on an average
Most Real-Time Systems are
embedded
• An embedded system is a computer built into
a system but not seen by users as being a
computer
• Examples
– FAX machines
– Copiers
– Printers
– Scanners
– Routers
– Robots
Role of an OS in Real Time Systems

• Standalone Applications
– Often no OS involved
– Micro controller based Embedded Systems
• Some Real Time Applications are huge &
complex
– Multiple threads
– Complicated Synchronization Requirements
– File system / Network / Windowing support
– OS primitives reduce the software design time
Features of Real Time OS
(RTOS)
• Scheduling.

• Resource Allocation.

• Interrupt Handling.

• Other issues like kernel size.


Scheduling in RTOS
• More information about the tasks are
known
– Number of tasks
– Resource Requirements
– Execution time
– Deadlines
• Being a more deterministic system
better scheduling algorithms can be
devised.
Scheduling Algorithms in RTOS
• Clock Driven Scheduling

• Weighted Round Robin Scheduling

• Priority Scheduling
Scheduling Algorithms in RTOS (cont.)

• Clock Driven
– All parameters about jobs (execution
time/deadline) known in advance.
– Schedule can be computed offline or at
some regular time instances.
– Minimal runtime overhead.
– Not suitable for many applications.
Scheduling Algorithms in RTOS (cont.)

• Weighted Round Robin


– Jobs scheduled in FIFO manner
– Time quantum given to jobs is proportional to it’s
weight
Scheduling Algorithms in RTOS (cont.)

• Priority Scheduling
– Processor never left idle when there are
ready tasks
– Processor allocated to processes according
to priorities
– Priorities
• Static - at design time
• Dynamic - at runtime
Priority Scheduling
• Earliest Deadline First (EDF)
– Process with earliest deadline given highest
priority
• Least Slack Time First (LSF)
– slack = relative deadline – execution left
• Rate Monotonic Scheduling (RMS)
– For periodic tasks
– Tasks priority inversely proportional to it’s period
Schedulers
• Also called “dispatchers”
• Schedulers are parts of the kernel
responsible for determining which task
runs next
• Most real-time kernels use priority-
based scheduling
– Each task is assigned a priority based on its
importance
– The priority is application-specific
Preemptive Kernels
• The highest-priority task ready to run
is always given control of the CPU
– If an ISR makes a higher-priority task
ready, the higher-priority task is resumed
(instead of the interrupted task)
• Most commercial real-time kernels are
preemptive
Preemptive Kernels (cont.)
Advantages of Preemptive
Kernels
• Execution of the highest-priority task
is deterministic
Resource Allocation in RTOS
• Resource Allocation
– The issues with scheduling applicable here.
– Resources can be allocated in
• Weighted Round Robin
• Priority Based
• Priority inversion problem may occur if
priority scheduling is used
Assigning Task Priorities
• Not trivial
• In most systems, not all tasks are
critical
– Non-critical tasks are obviously low-
priorities
• Most real-time systems have a
combination of soft and hard
requirements
A Technique for Assigning Task
Priorities
• Rate Monotonic Scheduling (RMS)
– Priorities are based on how often tasks
execute
Other RTOS issues
• Interrupt Latency should be very small
– Kernel has to respond to real time events
– Interrupts should be disabled for minimum
possible time
• For embedded applications Kernel Size should
be small
– Should fit in ROM
• Sophisticated features can be removed
– No Virtual Memory
– No Protection
Linux for Real Time Applications
• Scheduling
– Priority Driven Approach
• Optimize average case response time
– Interactive Processes Given Highest
Priority
• Aim to reduce response times of processes
– Real Time Processes
• Processes with high priority
• There was no notion of deadlines
Interrupt Handling in Linux
• Interrupts were disabled in ISR/critical
sections of the kernel
• There was no worst case bound on
interrupt latency avaliable
– eg: Disk Drivers might disable interrupt for
few hundred milliseconds
Interrupt Handling in Linux
(cont.)
• Linux was not suitable for Real Time
Applications
– Interrupts may be missed
Other Problems with Linux
• Processes were not preemtible in Kernel Mode
– System calls like fork take a lot of time
– High priority thread might wait for a low priority
thread to complete it’s system call
• Processes are heavy weight
– Context switch takes several hundred
microseconds
Part II

BY Abebe B.
Characteristics of a real-time
operating system
• Real-time operating systems generally
have the following characteristics:
– Small footprint. Compared to general
OSes, real-time operating systems are
lightweight.
– High performance. RTOSes are typically
fast and responsive.
– Determinism. Repeating inputs end in the
same output.
Cont.…
• Safety and security. Safety-critical and
security standards are typically the highest
priority, as RTOSes are frequently used in
critical systems.
• Priority-based scheduling.Tasks that are
assigned a high priority are executed first
followed by lower-priority jobs.
• Timing information. RTOSes are responsible
for timing and providing application
programming interface
What are Real-Time Operating
System?
There are several examples of RTOS that
are commonly used in embedded systems:
• FreeRTOS
• VxWorks
• QNX
• ThreadX
• Micrium µC/OS
• etc
What are the Best RTOS for
Embedded Systems?
• Choosing the best RTOS for an embedded
system depends on
– the specific requirements of the project,
– Including;
• size of the system,
• performance,
• memory footprint,
• available resources, and real time
requirements.
What are the Best RTOS for
Embedded Systems?
• FreeRTOS:
– It is a popular open-source, real-time
operating system that is designed to be small,
portable, and easy to use.
– FreeRTOS provides a rich set of features,
including task management, interrupt
handling, and synchronization mechanisms.
– It is widely used in various industries,
including automotive, aerospace, and
consumer electronics.
https://www.freertos.org/index.html
What are the Best RTOS for
Embedded Systems?
• Micrium µC/OS:
– It is a scalable, real-time operating
system that provides a robust set of
features for embedded systems.
Micrium µC/OS is widely used in
various industries, including medical
devices, industrial automation, and
telecommunications.

https://blackberry.qnx.com/en
What are the Best RTOS for
Embedded Systems?
• ThreadX:
– It is a small, fast, and efficient real-time
operating system that provides a reliable and
predictable environment for running real-
time applications.
– ThreadX is widely used in various industries,
including automotive, aerospace, and
consumer electronics.

https://www.embeddedtechnology.com/doc/
threadx-rtos-0001
What are the Best RTOS for
Embedded Systems?
• VxWorks:
– It is a real-time operating system that
provides a robust set of features for
embedded systems.
– VxWorks is widely used in various industries,
including aerospace, defense, and
telecommunications.
– For nearly 35 years, VxWorks has been used to
ensure the security, safety, and reliability you need to
design and build mission-critical embedded systems
that simply must work.
https://www.windriver.com/products/vxworks
What are the Best RTOS for
Embedded Systems?
• QNX:
– It is a real-time operating system that
provides a reliable and predictable
environment for running real-time
applications.
– QNX is widely used in various industries,
including automotive, medical devices,
and industrial automation.
Description and Application
RTOS Description Common Applications

An open-source RTOS with a lightweight Embedded devices, IoT,


FreeRTOS kernel. Widely used in embedded systems satellites, drones, robotics,
.and microcontrollers .industrial automation

A commercial RTOS known for reliability Aerospace systems, automotive


VxWorks and scalability. Used in aerospace, control units, industrial
.automotive, and more .machinery

Commercial RTOS with robustness and


Automotive infotainment, medical
QNX fault tolerance. Supports multi-core
.devices, industrial automation
.processors

Compact and efficient RTOS suitable for Consumer electronics, networking


ThreadX
.resource-constrained devices .equipment, IoT devices

Small-footprint RTOS by Mentor Graphics. Telecommunications, automotive,


Nucleus RTOS
.Used in various embedded systems .consumer electronics

 These RTOS options cater to different needs, from open-source flexibility


to commercial reliability, making them essential for time-critical applications.
Compare
RTOS Description Pros Cons

Limited features: Basic -


An open-source RTOS with a Open-source: Easily accessible -
functionality; lacks some
lightweight kernel. Widely used in .and customizable
FreeRTOS advanced features. -
embedded systems and Small footprint: Suitable for -
Community support: May
.microcontrollers .resource-constrained devices
.vary in quality

Robustness: Proven track - Cost: Commercial license -


A commercial RTOS known for
record in critical applications. - required. - Learning
VxWorks reliability and scalability. Used in
Scalability: Supports complex curve: Complex
.aerospace, automotive, and more
.systems .configuration and setup

Cost: Commercial license -


Commercial RTOS with robustness Fault tolerance: High reliability -
required. - Vendor
QNX and fault tolerance. Supports multi- and fault recovery. - Multi-core
dependency: Tied to
.core processors .support: Efficient utilization
.BlackBerry

Low overhead: Minimal impact - Proprietary: Closed- -


Compact and efficient RTOS
on system resources. - Certified: source with licensing fees.
ThreadX suitable for resource-constrained
Used in safety-critical - Limited community:
.devices
.applications .Smaller user base

Small footprint: Ideal for - Commercial license: -


Small-footprint RTOS by Mentor
Nucleus memory-constrained devices. - Requires licensing. -
Graphics. Used in various
RTOS Scalability: Supports various Vendor-specific: Tied to
.embedded systems
.architectures .Mentor Graphics
Next>>>Hardware Elements of Embedded System

You might also like