RTES-Chapter-Three
RTES-Chapter-Three
Lecture -3
S O F TWAR E F R A M EW OR KS F O R R EA L - TI ME A N D EM BED D ED S Y S TEM S
12/22/2024 REAL TIME AND EMBEDDED SYSTEMS PREPARED BY GIZACHEW B. MTU DEPARTMENT OF CS 1
Contents
❑Real-time operating system: definitions, Characteristics, functionality
❑Features of a real time operation system
❑Inter process communication
❑Real time task scheduling
❑Dynamic allocation of tasks
❑Scheduling
❑Synchronization techniques
❑Real-time applications
12/22/2024 REAL TIME AND EMBEDDED SYSTEMS PREPARED BY GIZACHEW B. MTU DEPARTMENT OF CS 2
Introduction to Real-time operating system
➢ A real time operating system is a type of operating system designed to manage
hardware resources and execute tasks within strict timing constraints.
➢ Unlike general purpose operating systems ,which prioritize maximizing
throughput and resource utilization, an RTOS focuses on meeting deadlines
and ensuring predictable behavior for time sensitive applications.
➢ A real time OS is critical in applications that need immediate and deterministic
behavior, such as in flight control systems, Command Control Systems, Heart
Pacemaker, Robotic Arm control etc..
➢ Generally, a real time operating system ensures that a system is reliable, safe,
and efficient.
12/22/2024 REAL TIME AND EMBEDDED SYSTEMS PREPARED BY GIZACHEW B. MTU DEPARTMENT OF CS 6
Types of Real Time Operating Systems Cont…
❑Hard real time OS: that guarantees that all tasks will be completed within a
certain deadline, without exception. Meeting a deadlines is absolutely critical.
✓ These systems are designed to provide deterministic behavior, ensuring that
critical tasks are completed on time, every time.
✓ Are commonly used in applications where missed deadlines can have serious
consequences, such as in aerospace and defense, medical devices, and certain
types of industrial automation.
❑Soft real time OS: that does not guarantee that all tasks will be completed
within a certain deadline.
✓ Are commonly used in applications where occasionally missed deadlines are
tolerable, such as multimedia streaming, interactive gaming, and certain types
of data processing.
12/22/2024 REAL TIME AND EMBEDDED SYSTEMS PREPARED BY GIZACHEW B. MTU DEPARTMENT OF CS 7
Types of Real Time Operating Systems Cont…
❑Firm real time OS: is a type of real time system that guarantees that tasks will
be completed within a certain deadline but with a degree of flexibility.
✓ Firm real time systems can tolerate occasional deadline misses, but they should
be infrequent and not affect the overall system operation.
✓ Are commonly used in applications that require real-time performance but can
tolerate occasional deadline misses, such as multimedia systems, gaming
systems, and certain types of automation systems.
12/22/2024 REAL TIME AND EMBEDDED SYSTEMS PREPARED BY GIZACHEW B. MTU DEPARTMENT OF CS 8
Characteristics of Real Time Operating Systems
❑Correctness: It is one of the precious parts of a real time OS. A real time
operating system produces a correct result within the given time.
❑Reliability and stability: RTOS is designed to be robust and stable. i.e. They
can perform for a long time without failures.
❑Time Constraints: In real time operating system, the tasks should be completed
within the given time period.
❑Multitasking : real time operating systems supports multitasking based on
priority levels.
❑Priority-based scheduling: Tasks that are assigned a high priority are executed
first followed by lower-priority jobs.
❑Inter -task communication: RTOS provides mechanisms for tasks to
communicate with each other, such as message queues, semaphores, and shared
memory.
12/22/2024 REAL TIME AND EMBEDDED SYSTEMS PREPARED BY GIZACHEW B. MTU DEPARTMENT OF CS 9
Popular Examples of RTOS
❑FreeRTOS (used in Amazon IoT ❑MQX (Philips NXP / Freescale)
services to connect and manage devices)
❑Nucleus (Mentor Graphics)
❑VxWorks (Wind River) used in
aerospace and defense systems like the ❑Neutrino (BlackBerry)
mars rover and various satellite systems.
❑PikeOS (Sysgo)
❑Deos (DDC-I)
❑SafeRTOS (Wittenstein)
❑EmbOS (SEGGER)
❑ThreadX (Microsoft Express Logic)
❑Integrity (Green Hills Software)
❑µC/OS (Micrium)
❑Keil RTX (ARM)
❑Zephyr (Linux Foundation)
❑LynxOS (Lynx Software Technologies)
12/22/2024 REAL TIME AND EMBEDDED SYSTEMS PREPARED BY GIZACHEW B. MTU DEPARTMENT OF CS 10
Factors for Selecting an RTOS
❑A few factors to be considered while selecting RTOS are:
➢ Safety and Security features :compliance with safety standards and built in security
features to protect against vulnerabilities in connected devices .
➢ System Resource Requirements: Before selecting an RTOS, it is advised to look into all
of its specifications. Like memory allocations, resources required, number of tasks to be
processed, etc., and should select the one which matches our requirements.
➢ Scalability: the ability to RTOS to scale from small, simple applications to larger, more
complex systems.
➢ Development Tools and Support: the availability of development tools, such as IDEs,
debuggers ,and profiling tools which can significantly speed up development.
➢ Real-time performance: Since RTOS is all about real-time application thus performance
becomes a very important criterion in it. Better the performance, the better the system.
12/22/2024 REAL TIME AND EMBEDDED SYSTEMS PREPARED BY GIZACHEW B. MTU DEPARTMENT OF CS 11
Applications of Real Time Operating Systems
❑Real Time OS are used in:
➢ Real time operating system is used in airline reservation systems.
➢ Air traffic control system.
➢ Systems that provide immediate updating.
➢ Used in any system that provides up-to-date and minute information on stock prices.
➢ Defense application systems like RADAR.
➢ Networked Multimedia Systems
➢ Command Control Systems
➢ Internet Telephony
12/22/2024 REAL TIME AND EMBEDDED SYSTEMS PREPARED BY GIZACHEW B. MTU DEPARTMENT OF CS 12
General and specific microprocessors
❑General Purpose Processor
➢ Microprocessors that are designed to be capable of executing a wide range of
tasks. They are used in computers and other devices that require high-
performance processing capabilities.
➢ Common microprocessors such as Intel 8085 to Intel Pentium processors are an
example of general purpose processors.
❑Special Purpose microprocessors
➢ Are microprocessors that are designed to perform a specific tasks, often found
in embedded systems.
➢ Examples include ARM Cortex-M series processors designed for low-power
applications like in automotive systems, industrial control systems, and
consumer electronics.
12/22/2024 REAL TIME AND EMBEDDED SYSTEMS PREPARED BY GIZACHEW B. MTU DEPARTMENT OF CS 13
Interprocess Communication (IPC)
➢ The way of communication between two or more separate, independent
processes to exchange data or information.
➢ There are two fundamental models of interprocess communication : Shared
Memory and Message Passing.
➢ In the Shared-memory model, a region of memory that is shared by
cooperating processes is established.
➢ Processes then exchange information by reading and writing data to the shared
region.
➢ Example: In an automotive application, different modules (like engine control
and braking systems) may use IPC mechanisms to share data about vehicle
speed and braking status.
12/22/2024 REAL TIME AND EMBEDDED SYSTEMS PREPARED BY GIZACHEW B. MTU DEPARTMENT OF CS 17
Classification of Task Scheduling
❑Here are the following types of task
scheduling in a real-time system, such as:
❑Valid Schedule: is a sequence of task
executions that respects the timing constraints
of each task, including deadlines.
❑Feasible Schedule: is a valid schedule
where all tasks meet their deadlines.
❑Proficient Schedule : refers to a schedule
that not only meets deadlines but does so in
an efficient manner, often minimizing idle
CPU time or maximizing throughput
12/22/2024 REAL TIME AND EMBEDDED SYSTEMS PREPARED BY GIZACHEW B. MTU DEPARTMENT OF CS 18
Classification of Task Scheduling Cont’d…
❑Optimal Schedule: is one that achieves the best
possible performance according to some criteria,
such as minimum total execution time, minimum
lateness, or maximum resource utilization.
❑Scheduling Points: refer to specific moments in
time when the scheduler makes decisions about
which task to execute next. These points can
occur at task arrival times, completion times, or
when a task is preempted.
❑Preemptive Schedule: allows a currently
running task to be interrupted (preempted) to
allow a higher-priority task to execute.
12/23/2024 REAL TIME AND EMBEDDED SYSTEMS PREPARED BY GIZACHEW B. MTU DEPARTMENT OF CS 19
Classification of Task Scheduling Cont’d…
❑Utilization: refers to the fraction of CPU
time that is used by the tasks relative to the
total available CPU time.
▪It is often expressed as a percentage and is
calculated as the sum of the execution times
of all tasks divided by the total time
available.
❑Jitter: refers to the variability in the timing
of task execution. In real-time systems,
consistent timing is crucial.
▪Thus, jitter can negatively impact
performance if tasks do not execute at
expected intervals.
12/23/2024 REAL TIME AND EMBEDDED SYSTEMS PREPARED BY GIZACHEW B. MTU DEPARTMENT OF CS 20
Dynamic allocation of tasks
➢ Dynamic Tasks: It is a sequential program that is invoked by the occurrence of
an event. An event may be generated by the processes external to the system or
by processes internal to the system.
▪Dynamically arriving tasks can be categorized on their criticality and knowledge
about their occurrence times.
▪Example: An embedded system in a smart home may dynamically allocate tasks
for heating or cooling based on occupancy detected by sensors.
12/22/2024 REAL TIME AND EMBEDDED SYSTEMS PREPARED BY GIZACHEW B. MTU DEPARTMENT OF CS 21
Scheduling in RTOS
➢ Scheduling is the process of determining which task run amongst different
tasks at any given time.
➢ To schedule the tasks, more information about the tasks should be known such
as number of tasks, resource requirements, execution time and deadlines.
➢ The main focus of a RTOS scheduler is to meet task deadlines, instead of
throughput, latency and response time, etc.
➢ Example: In a drone's flight control system, scheduling ensures that navigation
tasks are prioritized over non-critical tasks like data logging.
12/22/2024 REAL TIME AND EMBEDDED SYSTEMS PREPARED BY GIZACHEW B. MTU DEPARTMENT OF CS 22
Scheduling Algorithms in RTOS
❑Non-Priority based Scheduling
✓ Cyclic executive
✓Shortest Task First
✓Round Robin
❑Priority Scheduling
✓Cooperative Scheduling
✓Preemptive Scheduling
12/22/2024 REAL TIME AND EMBEDDED SYSTEMS PREPARED BY GIZACHEW B. MTU DEPARTMENT OF CS 23
Scheduling Algorithms in RTOS: Cyclic scheduling
➢Tasks are arranged in Cyclic Fashion.
➢Each Task has to wait until the completion of previous task.
12/22/2024 REAL TIME AND EMBEDDED SYSTEMS PREPARED BY GIZACHEW B. MTU DEPARTMENT OF CS 24
Scheduling Algorithms in RTOS:Priority-based scheduling
➢ Priority based scheduling in operating systems is the scheduling of processes
according to the priority assigned to each of the processes.
✓ This priority depends on factors such as time limit, memory requirements
of the process and ratio of average I/O to average CPU burst time.
➢ There are mainly two types of priority scheduling:
➢ Non-preemptive (where another process can only be executed once the current
process is done executing) and
➢ Preemptive (where a higher priority process pauses the current running process
and completes its execution first).
12/22/2024 REAL TIME AND EMBEDDED SYSTEMS PREPARED BY GIZACHEW B. MTU DEPARTMENT OF CS 25
Multi-tasking and Concurrency issue in RTOS
➢ Multitasking is execution of multiple tasks simultaneously
➢ Concurrency issues: Problems arising from multiple tasks accessing shared
resources, leading to Task starvation, priority inversion, deadlocks, and race
conditions.
➢ Example: in a medical device monitoring system, concurrent access to patient
data can lead to inconsistencies if not properly managed.
➢ Cooperative multitasking based on the context switch is not suitable for
RTOSs. Because in cooperative multitasking there is no concept of task priority
and preemtability.
12/22/2024 REAL TIME AND EMBEDDED SYSTEMS PREPARED BY GIZACHEW B. MTU DEPARTMENT OF CS 26
Multi-tasking and Concurrency issue in RTOS Cont…
➢ In a multitasking RTOS task scheduling, switching and execution elements are
key to the effectiveness of the OS in achieving its real-time requirements.
➢ For RTOSs preemptive multitasking is usually used. Preemptive multitasking
uses priority based scheduling.
➢ This means a task can be stopped or suspended in order to allow a task of
higher priority to run.
➢ A task is said to ‘preempt’ another task, when that task is interrupted and the
context switched to a higher priority task.
12/22/2024 REAL TIME AND EMBEDDED SYSTEMS PREPARED BY GIZACHEW B. MTU DEPARTMENT OF CS 27
Multi-tasking and Concurrency issue in RTOS Cont…
➢ RTOS also provides various mechanisms for concurrency and synchronization,
such as mutexes, semaphores, queues, and Critical sections.
➢ RTOS also offers deterministic behavior, which means that the system can
guarantee the execution time and order of tasks or threads, as well as the
response time to external events or interrupts.
12/22/2024 REAL TIME AND EMBEDDED SYSTEMS PREPARED BY GIZACHEW B. MTU DEPARTMENT OF CS 28
Synchronization techniques
➢ Synchronization techniques in Real-Time Operating Systems (RTOS) are crucial for
ensuring that tasks operate correctly and efficiently, especially in environments where
timing and resource sharing are critical.
➢ Below are several synchronization techniques commonly used in RTOS:
❑Mutex (Mutual Exclusion) : is a synchronization primitive that allows only one task
to access a shared resource at any given time. It prevents race conditions by ensuring
mutual exclusion.
▪ Example: In an automotive control system, multiple sensors (like temperature, speed,
and fuel level) may need to write data to a shared display.
▪ Usage : A mutex is used to ensure that when one sensor is updating the display, other
sensors must wait until the update is complete. This prevents overlapping writes that
could corrupt the displayed information.
12/22/2024 REAL TIME AND EMBEDDED SYSTEMS PREPARED BY GIZACHEW B. MTU DEPARTMENT OF CS 29
Synchronization techniques Cont’d…
❑Semaphore : is a signaling mechanism that can be used to control access to a
resource pool. It can be binary (like a mutex) or counting, allowing multiple tasks
to access a limited number of resources.
12/23/2024 REAL TIME AND EMBEDDED SYSTEMS PREPARED BY GIZACHEW B. MTU DEPARTMENT OF CS 30
Synchronization techniques Cont’d…
❑ Condition Variables: allow tasks to wait for certain conditions to be met
before proceeding. They are often used with mutexes for synchronization.
▪ Usage: The heating task waits on a condition variable that is signaled when the
temperature falls below a certain threshold. This prevents unnecessary heating
when conditions are already optimal.
12/23/2024 REAL TIME AND EMBEDDED SYSTEMS PREPARED BY GIZACHEW B. MTU DEPARTMENT OF CS 31
Synchronization techniques Cont’d…
❑Message Queues : allow tasks to communicate and synchronize by sending
messages to each other. Tasks can send or receive messages without needing to
know about each other directly.
▪ Usage: Each component can send messages to a central processing task via a
message queue. The central task processes these messages in order, ensuring
that all components are synchronized and data is handled correctly.
12/23/2024 REAL TIME AND EMBEDDED SYSTEMS PREPARED BY GIZACHEW B. MTU DEPARTMENT OF CS 32
Group Assignment with Presentation(20%)
❑Group 1 and 2 - Chapter-5 ❑Group 3 and 4:
❑Real-time Communication 5.5 Internet of Things (IoT)
5.1 Basic concepts and examples of real 5.6 Sensor and actuators
time communication 5.7 Resource reservation
5.2 Real time communication in LAN 5.8 Traffic shaping and policing
5.3 Bounded access protocol 5.9 Scheduling mechanisms-QoS models
5.4 Real time communication over N.B : Prepare a ppt with a maximum of
internet 25 slides for your presentation. Your
presentation Due date: December
24,2017
12/22/2024 REAL TIME AND EMBEDDED SYSTEMS PREPARED BY GIZACHEW B. MTU DEPARTMENT OF CS 33
Group Project with Presentation(20%)
❑After the end of chapter 4 and 5, we will ❑Group 3: IoT-Based Smart Irrigation
start a lab sessions. Based on that ,you system.
will have a simple Course project. So, be
ready yourself for your project on the ❑Group 4: IoT-Based Home Automation
following project titles:
System
❑Group 1: IoT-Based Air Pollution
Monitoring System ❑N.B:your project demonstration Due date:
January 12,2017
❑Group 2: Real-Time Soil Moisture
Monitoring System.
12/22/2024 REAL TIME AND EMBEDDED SYSTEMS PREPARED BY GIZACHEW B. MTU DEPARTMENT OF CS 34
END OF CHAPTER -THREE
12/22/2024 REAL TIME AND EMBEDDED SYSTEMS PREPARED BY GIZACHEW B. MTU DEPARTMENT OF CS 35