All in One
All in One
1
Introduction to Real Time & Embedded Systems
Related Notions
• reactive system: continuous interaction with the environment
(as opposed to information processing)
• embedded system: computer system encapsulated in its
environment (device it controls), combination of computer
hardware and software, dedicated to specific purpose
• safety-critical system: a failure may cause injury, loss of lives,
significant financial loss
Characteristics of a Real-Time Embedded System
• Real time embedded systems must have the following
characteristics;
1. Constant Response:
• A real-time embedded system always responds in the
same manner to a certain situation, it is not allowed to
deviate from its normal designated output. An air-
conditioner is not allowed to throw hot air in summers.
2. Deadline:
• A deadline is crucial to the working of an embedded
system, a missed deadline can cost lives and finances.
Characteristics of a Real-Time Embedded System
3. Accuracy:
• In case of any malfunctioning, the system failure can cause
havoc
• For example, what would happen if the pacemaker can't maintain
the heartbeat, patient would eventually die!
4. Quick Response:
• Is the most important characteristic of all, the real-time
embedded system must be swift enough to respond to the
changing external environment with immediate effect.
Examples of real-time and embedded systems
Missile launcher
Medical equipment
Handheld devices
Avionics
Industrial control systems
Transportation control
Examples of real-time and embedded systems
Central Health System
GPS Systems
Fitness trackers
Medical devices
Automotive systems
Examples of real-time and embedded systems
Transit and fare Collection(air port in Ethiopian context)
ATMs
Factory robots
Model of Real Time System
• The basic model of a real-time system presents the overview
of all the components involved in a real-time system.
• Real-time system includes various hardware and software
embedded in a such a way that the specific tasks can be
performed in the time constraints allowed.
• The accuracy and correctness involved in real-time system
makes the model complex.
• There are various models of real-time system which are more
complex and are hard to understand.
Model of Real Time System
• Basic model of real-time system which has some commonly
used terms for hardware.
Model of Real Time System
• Sensor: Sensor is used for the conversion of some
physical events or characteristics into the electrical
signals.
• These are hardware devices that takes the input from
environment and gives to the system by converting it.
• For example, a thermometer takes the temperature as
physical characteristic and then converts it into electrical
signals for the system.
Model of Real Time System
• Actuator: Actuator is the reverse device of sensor.
• Where sensor converts the physical events into electrical
signals, actuator does the reverse.
• It converts the electrical signals into the physical events or
characteristics.
• It takes the input from the output interface of the system. The
output from the actuator may be in any form of physical
action.
• E.g Some of the commonly used actuator are motors and
heaters.
Model of Real Time System
• Signal Conditioning Unit: When the sensor converts the
physical actions into electrical signals, then computer can’t
used them directly.
• Hence, after the conversion of physical actions into
electrical signals, there is need of conditioning.
• Similarly while giving the output when electrical signals are
sent to the actuator, then also conditioning is required.
Therefore, Signal conditioning is of two types:
• Input Conditioning Unit: It is used for conditioning the
electrical signals coming from sensor.
• Output Conditioning Unit: It is used for conditioning
the electrical signals coming from the system.
Model of Real Time System
• Interface Unit: Interface units are basically used for the
conversion of digital to analog and vice-versa.
• Signals coming from the input conditioning unit are analog
and the system does the operations on digital signals only,
then the interface unit is used to change the analog signals to
digital signals.
• Similarly, while transmitting the signals to output conditioning
unit the interface of signals are changed i.e. from digital to
analog. Interface unit is also of two types:
• Input Interface: It is used for conversion of analog signals to digital.
• Output Interface: It is used for conversion of digital signals to analog.
Types of Real Time Embedded Systems
A real time embedded system,
being made up of real time
operating system, embedded
software and hardware. Real Time
embedded systems have the
following three types.
Types of Real Time Embedded Systems
1. Soft Real Time Embedded Systems
• A soft real-time constraint is a constraint that a
system should meet, but when the deadline is
occasionally missed, it won’t cause any disastrous
result, and the delivered service is still useful to a
certain extent.
• Try to reach deadlines but do not fail if a deadline
is missed.
• However, they may degrade their quality of
service in such an event to improve
responsiveness.
• Examples of soft real-time systems: audio and video
delivery software for entertainment
Types of Real Time Embedded Systems
1. Soft Real Time Embedded Systems
• Characteristics of soft real time embedded systems;
• Timeliness of a task poses a positive impact on the system, but it
is not crucial for the performance of the system.
• Missing a deadline would not degrade the performance of the
whole embedded system.
• Example of Soft Real Time Embedded Systems
• A data acquisition system can tolerate delays and hence its a
soft real time embedded system.
• websites, computer games, cellular networks, online database
and multimedia transmission and reception.
Types of Real Time Embedded Systems
2. Hard Real Time Embedded Systems
• A hard real-time constraint is a constraint that a
system must meet.
• Hard real-time software systems have a set of strict
deadlines, and missing a deadline is considered a
system failure.
• If the deadline is missed, it will either cause the
system failure or result in a zero usefulness of the
delivered service.
• Examples of hard real-time systems: airplane sensor
and autopilot systems, & spacecrafts.
Types of Real Time Embedded Systems
2. Hard Real Time Embedded Systems
• characteristics of hard real time embedded
systems;
• Time is crucial.
• The output must be completely on time, the
prescribed deadline can not be missed in any
case.
e.g You can't submit your exam paper after the time is
over, or can you?
• In case a deadline is missed, it would be
regarded as a system failure.
Types of Real Time Embedded Systems
3. Firm real-time systems
Firm real-time systems treat information delivered/
computations made after a deadline as invalid.
• Like soft real-time systems, they do not fail after a missed
deadline, and they may degrade QoS if a deadline is missed.
• Examples of firm real-time systems: financial forecast systems,
robotic assembly lines.
Modeling timing constraints
Timing constraints is a vital attribute in real-time
systems.
Timing constraints decides the total correctness
of the result in real-time systems.
The correctness of results in real-time system
does not depends only on logical correctness but
also the result should be obtained within the time
constraint.
Several events happening in real time system and
these events are scheduled by schedulers using
timing constraints.
Modeling timing constraints
Timing constraints are broadly classified into two
categories:
1. Performance Constraints
The constraints enforced on the response of the system
is known as Performance Constraints.
It is how quickly and accurately the system is
responding.
2. Behavioral Constraint
The constraints enforced on the stimuli generated by
the environment is known as Behavioral Constraints.
Modeling timing constraints
The both performance and behavioral
constraints are classified into three
categories
I. Delay Constraint
II. Deadline Constraint
III. Duration Constraint
D >= d
Delay Constraint
It defines the minimum time interval between
occurrence of two consecutive events in the real-time
system
If an event occurs before the delay constraint, then it
is called a delay violation.
The time interval between occurrence of two events
should be greater than or equal to delay constraint.
If D is the actual time interval between occurrence of two
events and d is the delay constraint, then
D>=d
Modeling timing constraints
Deadline Constraint
A deadline constraint describes the maximum
time interval between occurrence of two
consecutive events in the real-time system.
i.e. the latest time by which two consecutive
events in the real-time system.
If an event occurs after the deadline constraint,
then the result of event is considered incorrect.
The time interval between occurrence of two
events should be less than or equal to deadline
constraint.
If D is the actual time interval between occurrence of
two events and d is the deadline constraint, then
D<=d
Modeling timing constraints
Duration Constraint
• Duration constraint defines the full-length of time an
event to occur in real-time system.
• The minimum and maximum time period of an event.
• So, it is further classified into two types:
Minimum Duration Constraint:
after the initiation of an event, it can not stop before
a certain minimum duration.
Maximum Duration Constraint:
after the starting of an event, it must end before a
certain maximum duration elapses.
Computer organization concepts and memory
Organization of a computer system defines the
way system is structured so that all those
catalogued tools can be used.
Organization of a computer system is the internal
parts of a computer
The basic components of Computer organization
are mother board, RAM, catch, ALU, CU, memory,
and memory organization.
Design process
Definition: A system designed with the embedding
of hardware and software together for a specific
function with a larger area is embedded system
design.
In embedded system design, a microcontroller plays
a vital role.
Micro-controller is based on Harvard architecture, it
is an important component of an embedded
system.
External processor, internal memory and i/o
components are interfaced with the microcontroller.
It occupies less area, less power consumption..
Design process
Design process
Steps in the Embedded System Design Process
Abstraction: In this stage the problem related to the system is
abstracted.
Hardware – Software Architecture: Proper knowledge of
hardware and software to be known before starting any design
process.
Extra Functional Properties: Extra functions to be implemented
are to be understood completely from the main design.
System Related Family of Design: When designing a system,
one should refer to a previous system-related family of design.
Modular Design: Separate module designs must be made so
that they can be used later on when required.
Design process
Steps in the Embedded System Design Process
Mapping: Based on software mapping is done. For example,
data flow and program flow are mapped into one.
User Interface Design: In user interface design it depends on
user requirements, environment analysis and function of the
system. For example, on a mobile phone if we want to reduce
the power consumption of mobile phones we take care of other
parameters, so that power consumption can be reduced.
Refinement: Every component and module must be refined
appropriately so that the software team can understand.
Architectural description language is used to describe the
software design.
Design process
Steps in the Embedded System Design
Process
Real-Time Embedded System
1
Chapter 2
2
Embedded System Architecture
data or address.
All registers are 32 bits
In user mode 16 data
registers & 2 status registers are
available.
Registers
Data registers: r0 to r15
• Three registers r13, r14, and r15 perform
special functions
• r13: stack pointer
• r14: link register (where return address is input
whenever a subroutine is called)
ARM state
All instructions are 32 bit wide
The microcontroller:
Reads the data in the register
Operates on the data in the register
Stores the results back in the register
12 bits 4 bits
GPRs
Op. Code Rd 0
Examples:
INC R16
CLR R22 d
31
Addressing Modes: Register Direct-Single Register
Addressing Modes: Direct-Two Registers
o Instructions can operate on any of the 32 registers
• One of theses register is the source register Rs and one is the destination register Rd
31
Addressing Modes: Register Direct-Two Registers
Addressing Modes: Register Direct-Two Registers
Addressing Modes: Register Direct-Two Registers
Addressing Modes: Register Direct-Two Registers
Addressing Modes: I/O Indirect
I/O Memory
15 5 0 0
Op. Code Rr/Rd A
A
Addressing Modes: I/O Indirect
Addressing Modes: I/O Indirect
Addressing Modes: I/O Indirect
Addressing Modes: I/O Indirect
Addressing Modes: I/O Indirect
Addressing Modes: Immediate
• SUBI Rd,K
d
– SUBI R23,5 ;R23 = R23 – 5
31
• ANDI Rd,K
– ANDI R21,0x15
Addressing Modes: Immediate
Addressing Modes: Immediate
Addressing Modes: Data direct
31 20 19 16 Data Space
Op. Code Rr/Rd 0
o LDS Rd, address Data Address
• LDS R19, 0x313 15 0
o STS address, Rs
• STS 0x95, R19
Note: RAMEND has been used to
represent the highest location in
RAMEND
data space.
Addressing Modes: Data Indirect
Data Space
15 0 0
X, Y, OR Z - REGISTER
9/28/2024 1
Definition
A Real-Time Operating System (RTOS) is an operating system
designed to handle real-time applications that require timely,
deterministic responses to events.
It ensures tasks are executed within a specified deadline, making
it ideal for systems that depend on precise timing, such as
embedded systems, robotics, avionics, and industrial control
systems.
These systems often operate in constrained environments (limited
CPU, memory, power) and are used in industries such as automotive,
aerospace, medical devices, telecommunications, and industrial
control.
9/28/2024 2
Real-time operating system:
OS is the software that sits between the hardware and software applications
running on the computer
USER
OS is a resource allocator and manager.
Hardware resources could be processor, memory, APPLICATION PROGRAM
HARDWARE
9/28/2024 3
Real-time operating system:
All the GPOS such as Linux, windows have execute multi-tasks at the same time
and but it lacks in synchronization of the data.
It is known that Kernel is core component of OS that control over all of the
hardware devices.
However, GPOS are not suitable for real-time embedded systems which required
by real time applications in embedded system.
Here of, real time applications in embedded system requires real time, priority and
time based operating system which is called RTOS.
9/28/2024 4
Rear Time Operating system (RTOS)
RTOS supports the construction of applications that must meet real-time constraints
RTOS is a priority based operating system designed to serve real time applications.
It requires fewer resources in-order to provide accuracy of the task.
It produce accurate output within no time (within deadline) and occupies less memory.
It provides mechanisms and services to carry out real-time task scheduling,
9/28/2024 5
Rear Time Operating system (RTOS)
It provides resource management, and intertask communication.
RTOS are designed for critical systems or critical tasks for devices like
microcontrollers that are timing-specific devices.
6
Rear Time Operating system (RTOS)
A real-time kernel is software component that manages time and resources of a
microprocessor or microcontroller
It provides essential services such as task scheduling and interrupt handling to
applications.
There are three key requirements of RTOS design
1. Timing behavior of the OS must be predictable or it should be think over about
time.
2. Must manage timing and scheduling for task processing
3. The OS must be fast to meet its deadline
7
Types of RTOS (Real Time Operating System)
It is classified into three types. They are:
1.Soft Real Time Operating System
2.Hard Real Time Operating System
3.Firm Real Time Operating System
9/28/2024 8
Types of RTOS (Real Time Operating System)
1. Soft Real Time Operating System
Response time of the system is important but not critical to the operation
Deadline is specified but the system can accept short amount of delay
But if missed deadline the performance is degraded.
Example: Online transaction system, TV live broadcasts a delay can be
acceptable etc.
9/28/2024 9
2. Hard Real Time Operating System
Deadline and time duration to execute tasks are specified.
If not respond within the time line specified it will result disastrous consequences.
This OS must be meet its deadline
Example: Medical critical care systems and Aircraft systems etc.
3. Firm Real Time Operating System
Deadline is specified but missing deadline does not cause a big impact
If the result is obtained after the deadline then result will be considered incorrect
Example: Multimedia applications,
9/28/2024 10
Characteristics of RTOS:
Small footprint: compared to general OSes, RTOS lightweight.
It occupy a very small amount of memory.
Consume fewer resources.
High performance: RTOSes are typically fast and responsive OS.
Determinism: repeating inputs end in the same output.
Safety and security: safety and security are typically the highest priority for RTOS
Priority-based scheduling. Follows high priority task first execution that followed by lower-
priority jobs.
Timing information. RTOS are responsible for timing and providing application in deadline
9/28/2024 11
Characteristics of RTOS:
Minimal Latency: RTOS has low interrupt and thread switching latency, allowing fast
responses to external events.
Preemptive Multitasking: Tasks can be interrupted (preempted) to allow higher-priority tasks
to run.
Concurrency Management: Supports multiple tasks running concurrently, with mechanisms
like semaphores, mutexes, and message queues to manage shared resources and avoid race
conditions.
9/28/2024 12
Structure of RTOS
Basic Structure is similar to regular OS but in addition, it provides mechanisms to
allow real time scheduling of tasks.
OS is nothing but a collection of system calls or functions while real time is time
at which task should executes
9/28/2024 13
Structure of RTOS
User space
Kernel space
Hardware space
Architecture of RTOS
9/28/2024 14
RTOS Support for Applications
Task Prioritization: Applications can assign priorities to tasks to ensure the most critical tasks
meet deadlines.
Deterministic Execution: Guarantees time-sensitive tasks will execute within a known time frame.
Efficient Resource Management: Manages CPU time, memory, and hardware resources to
ensure reliable application behavior.
Modular Design: Applications can be developed as separate tasks or modules that communicate
via the RTOS.
Real-Time Clock & Timers: Applications can rely on accurate timekeeping for scheduled or
periodic operations.
Fault Tolerance: Supports systems that need to continue operating even in the case of component
failures.
9/28/2024 15
Inter process communication
The communication between process while they are running is called interprocess
communication (IPC).
It allows processes to communicate with each other and synchronize their actions.
It helps to know that some event has occurred or the transferring of data from
one process to another.
Inter communication can be method of cooperation between those task.
9/28/2024 16
Inter process communication
The two methods of inter process communication
1. Shared memory
Assume that process P1 Producer produces some items and the process P2
consumes that item.
The two processes share a common space or memory location known as a
buffer where the item produced by the Producer is stored and from which the
Consumer consumes the item if needed.
2. Message Passing:
Processes communicate with each other without using any kind of shared memory.
Assume that two process p1 and p2, want to communicate with each other when they are
running as follows:
1. Establish a communication link b/n the two process: (if a link already exists, no need to
establish it)
2. Start exchanging messages using basic primitives: the two primitives send (message,
destination) or receive (message, host)
17
Some reasons for process cooperation (inter process communication)
Information sharing − for sharing resources among multiple users
Computation speeds up − to run tasks faster by break it into subtasks
Modularity − dividing the system functions into separate processes or threads.
Convenience − it helps to work on many tasks at the same time.
9/28/2024 18
What is Task?
A task is a unit of work scheduled for execution on the CPU.
It is a building block of real-time application software supported by an
RTOS.
There are three types of tasks:
I. Periodic tasks. Periodic tasks are repeated once a period, for example,
with in 200 milliseconds.
II. Aperiodic tasks. Aperiodic tasks are one-shot tasks. They are event-
driven.
Aperiodic tasks have no hard deadlines
III. Sporadic tasks. Sporadic tasks are also event-driven. The arrival times
of sporadic task instances are not known a prior, but there is
requirement on the minimum inter arrival time.
sporadic tasks have hard deadlines
9/28/2024 19
Real Time task scheduling
Task management and scheduling are core functions of any RTOS kernel.
Scheduler part of kernel and is responsible for allocating and scheduling tasks to
ensure that deadlines are meet.
If two or more tasks have equal priority, the choice of task is based on FCFS.
9/28/2024 20
Task scheduling
1. Preemptive scheduling:
Used when a process switches from running state to ready state or from
waiting state to ready state.
Process can be interrupt in between running Algorithms design based on the
following methods:
Round Robin: Each process is assigned a fixed switches
switches
Priority (preemptive version) Ready state
Task1
9/28/2024 21
Task scheduling
2. Non-preemptive:
It is scheduling method that does not interrupt a process in the middle of
execution.
It process switches from running state to waiting state.
Running state Waiting state
Examples of this scheduling algorithms: Task1 switches Task1
9/28/2024 25
1. Priority-based scheduling in dynamic priorities.
9/28/2024 26
1. Priority-based scheduling in dynamic priorities.
9/28/2024 28
2. Cyclic scheduling in dynamic priorities.
Cyclic scheduling is simple method than table-driven scheduling (which is not
suitable for embedded system)
Each task is allowed to run to completion before it handover to the next.
A task cannot be discontinued or interrupted as it runs.
It is precomputed schedule that is repeated again and again
Each task in the task set is repeat identically in each cycle.
9/28/2024 29
Multi-tasking and Concurrency issue
Multitasking
It is capability of an OS that supports multiple independent programs running on
the same computer or machine and it achieved through time-sharing
Concurrency
It means several activities are executed simultaneously.
It is the execution of a set of multiple instruction sequences at the same time.
This occurs when there are several process threads running in parallel.
Concurrency 30
Handling resource sharing
In many applications real time task need to share resources among themselves.
However, some task cannot immediately handover (transfer or release) it to
another task Task1 resource Task2
1
But also there are mechanisms that employed by system which is not real time
system for sharing resources among multiples set of tasks such as semaphore,
Mutex, locks and monitors (you learn this in GPOS)
However, these mechanisms are not adequate for resource sharing in real time
applications b/c they raise problem called priority inversion issue.
31
What is priority inversion
It is a problem that occur in real time applications when working with a
preemptive priority scheduling algorithm
Priority Inversion is a phenomenon in scheduling where a higher-priority task is blocked or
delayed because a lower-priority task holds a resource (e.g., a mutex or a lock) needed by the
higher-priority task. Priority inversion typically occurs in a system using priority-based
preemptive scheduling with shared resources.
Here’s a common scenario:
1. Task A: Low-priority task holding a shared resource (e.g., a lock or semaphore).
2. Task B: Medium-priority task running and not requiring the resource.
3. 9/28/2024
Task C: High-priority task waiting for the resource that Task A holds. 32
Cont….
In this case:
Task C cannot proceed because Task A holds the resource it needs.
The system prioritizes Task B over Task A, even though Task C is more
important, because Task B has higher priority than Task A.
As a result, Task C (high priority) is indirectly blocked by Task B
(medium priority), which does not even need the shared resource. This
is called inversion because a low-priority task (A) indirectly blocks a
higher-priority task (C).
9/28/2024 33
Types of Priority inversion
1. Direct Inversion :
It occurs when a higher priority task waits for a lower priority task which holding a
critical resource
Example:
Suppose there are two tasks T1 and T2 where T2 is having higher priority than T1.
And T2 needs resource which holds by T1 but T2 will have to wait until T1
executes and releases the critical resource CR.
2. Inheritance-Related Inversion :
It is also occur when lower priority task is holding a critical resource and a higher
priority task is waiting for this critical resource
And it makes priority of the lower priority task is set to the equal priority with
higher priority task using the inheritance techniques
34
Resource sharing protocols
1. Priority Inheritance protocol (PIP):
It designed for sharing resources among tasks or to solve priority inversion issue
during sharing of resources among tasks.
This means PIP protocol is used whenever lower priority task holding the
resource while high priority task wait for such resources.
If a low-priority task holds a resource and a high-priority task requests it,
the low-priority task temporarily inherits the high-priority task's priority.
However, PIP cannot prevent deadlock issue
35
Resource sharing protocols
2. Highest Locker protocol (HLP):
PLP is an extended of PIP and it overcome some shortcoming of PIP.
It critical resources is assigned to higher priority value (called ceiling)
Whenever a task gains a resources, its priority becomes equal to the ceiling
priority value. R1
cv=2
However, it has its own limitation T1
p=2
T3
T2
3. Priority Ceiling Protocol (PCP):
Priority Ceiling: the highest priority of all tasks that might lock the resource.
PCP extends the ideas of PIP and HLP to solve the problems of unbounded
priority inversion, chain blocking and deadlocks, while at the same time
36
minimizing in heritance related inversion.
Fault- tolerance
Fault tolerance refers to the ability of a system (computer, network, cloud cluster,
etc.) to continue operating without interruption when one or more of its
components fail.
components fail.
It is the ability to continue operating even if there is some hardware or software
failure.
It is important to consider designing of fault tolerant system for real time system
because consequences of violating timing constraints in hard real-rime systems
very dangerous
Fault tolerance approaches can be classified into two types:
Proactive approaches predict errors, faults and failures and replace the
suspected components
Reactive approaches reduce the effect of faults by taking necessary actions. 37
Fault- tolerance vs High availability
High availability refers to a system’s ability to avoid loss of service by minimizing
downtime.
It’s expressed in terms of a system’s uptime, as a percentage of total running time.
It is five nines uptime(99.999% or less than 6 minutes downtime per year)
38
Synchronization techniques
It the way tasks that share the same memory space are managed OS
Whenever two tasks want to intercommunication they must be synchronized
for a message transfer
It insures that multiple process access shared resources without affecting other
tasks
It prevents the possibility of inconsistency of data due to concurrent access.
So, it helps to avoid risk of deadlock and other synchronization problems.
9/28/2024 39
Synchronization techniques
Generally process categorized into two in the case of synchronization
Independent process
Cooperation process
Synchronization ensures that the correct execution order among cooperating tasks
Synchronization is the cooperative act among two or more threads or tasks in
relationship to each other
9/28/2024 41
2. Distributed clock synchronization
Instead of single server time sharing to all nodes, each nodes in share their time
with other.
The nodes adjust their time by using their local time and, then nodes adjust their
time by taking the average of the differences in time with other nodes.
So, there is a need for proper allocation of resources and help coordinate
between the several processes.
Examples of Distributed algorithms are:
Global Averaging Algorithm,
Localized Averaging Algorithm,
NTP (Network time protocol), etc.
42
Real-time applications
Mobile applications.
Air traffic control systems.
Online transaction system.
Online calling.
Medical Critical Care systems.
Ticket reservation systems.
Aircraft and defense systems (e.g. RADAR)
Command control systems.
Price quotation systems.
9/28/2024 43
Chapter-4
Embedded Systems Design Issues
Introduction
• Embedded Systems Design Issues refer to the challenges and
considerations that must be addressed when developing an
embedded system.
• These issues arise due to the unique characteristics of
embedded systems, such as real-time performance, hardware
constraints, and application-specific requirements.
Memory Management
• Memory Management in Embedded Systems Design is a
critical aspect because embedded systems often have
limited memory resources (RAM and ROM) due to cost,
size, and power constraints.
• Effective memory management ensures that an embedded
system runs efficiently without exhausting its available
memory, which can lead to system failures or degraded
performance.
Minimize memory usage by optimizing code and data storage.
Use lightweight data structures and efficient memory allocation
algorithms
Memory Management on RTOS
• The memory management of RTOS is a little bit different from
GPOS
• RTOS Memory Management: Determinism(allocation, deallocation, and paging
must be predictable and fast to meet real-time constraints), Low Latency, and
Resource-Constrained.
• GPOS Memory Management: Throughput and Fairness, Complex Memory
Features, and Scalability
• The memory allocation time increases depending on the size of the
block of memory.
• Needs to be allocated and the state of allocated memory
block(initialized memory block consumes more allocation time
than uninitialized memory block)
• The primary focus of RTOS is deterministic behavior and
predictable timing
Cont….
• RTOS commonly uses “block” based memory allocation
technique, instead of dynamic memory allocation technique used
by GPOS.
• RTOS uses blocks of fixed size of dynamic memory and the block
is allocated for a task on a need basis.
• The blocks are stored in a “free buffer Queue”
• Most of the RTOS kernels allow tasks to access any of the memory
blocks without any memory protection to achieve predictable
timing and avoid the timing overheads
• RTOS kernels assume that the whole design is proven correct and
protection is unnecessary.
Cont…
• In “block” based memory allocation, a block of fixed
memory is always allocated for tasks on need basis
and it is taken as a unit.
• So, there will not be any memory fragmentation
• Consumes fixed amount of time for memory
allocation
Hardware Development
• Hardware development for embedded systems involves
selecting and designing the right components to ensure the
system performs efficiently under the required operational
constraints.
• Several critical issues must be addressed when designing
embedded hardware, including the selection of
• Microcontrollers,
• Power Management,
• Interfacing with Peripherals, and
• Environmental Considerations.
Design Requirements
Embedded system must satisfy the following:
Real time operation/ reactive to external event
Conform to size and weight limits.
Budget, power and cooling consumptions
Satisfy safety and reliability requirements
Meet tight cost targets
Real Time/Reactive Operation
Real Time Operation VS Reactive Operation
• Real-time systems are designed to respond to inputs or events within a
strictly defined time limit.
• The correctness of a computation depends, in part, on the time at which it
is delivered.
• The system design must also take into account worst case performance.
• Predicting the worst case may be difficult on complicated architectures.
• For example, Signal Processing and Mission Critical example systems
have a significant requirement for real time operation.
Real Time/Reactive Operation
Reactive Operation
Reactive systems, on the other hand, are systems that
continuously respond to changes in their environment, but they are
not necessarily required to meet strict time constraints.
Reactive computation means that the software executes in
response to external events.
These events may be periodic, in which case scheduling of
events to guarantee performance may be possible.
On the other hand, many events may be aperiodic, in which
case the maximum event arrival rate must be estimated in order
to accommodate worst case situations.
Small Size and Low Weight
Embedded computers are physically located within
artifacts.
Weight is considered as a major factor for
transportation and portable systems.
Safe and Reliable
In mission-critical applications such as aircraft flight
control, severe personal injury or equipment damage
could result from a failure of the embedded computer.
Such systems, have employed multiply-redundant computers or
distributed consensus protocols in order to ensure continued
operation after an equipment failure.
Harsh environment
Many embedded systems do not operate in a
controlled environment.
Excessive heat is often a problem, especially in
applications involving combustion (e.g., many
transportation applications).
Additional problems can be caused for embedded
computing by a need for protection from vibration, shock,
lightning, power supply fluctuations, water, corrosion, fire,
and general physical abuse.
Cost Sensitivity
Cost is one of the issue when developing a system.
A little change in cost affects the manufacturing quantity of
the system
Software Development
Software development for embedded systems involves
unique challenges and design considerations due to
hardware constraints, real-time requirements, and the need
for efficient resource management.
Embedded systems software must be highly optimized,
reliable, and capable of interfacing directly with the
underlying hardware.
Cont….
The following are some key software development
challenges and design issues in embedded systems:
1. Real-Time Constraints
2. Memory Management
3. Power Efficiency
4. Concurrency and Synchronization
5. Communication with Peripherals
6. Software Debugging and Testing
7. Error Handling and Fault Tolerance
8. Code Portability and Reusability
9. Firmware Updates and Security
10. Development Tools and IDEs
Real-Time Constraints
Many embedded systems must operate under real-time
constraints, where the system must respond to events within
a defined time period.
Missing these deadlines can lead to system failures or undesired
behavior.
Design Considerations: Real-Time Operating Systems (RTOS),
Deterministic Behavior, Priority Scheduling and Interrupt Handling
Memory Management
Embedded systems often have limited memory resources,
both in terms of RAM and non-volatile storage like Flash or
EEPROM.
Efficient memory management is essential to avoid overflow,
memory fragmentation, and system crashes.
Design Considerations:
Static Memory Allocation: Prefer static memory allocation over dynamic
memory allocation to avoid issues like memory fragmentation and
unpredictable allocation times.
Memory Pooling: Use memory pools to allocate fixed-size blocks of
memory, reducing fragmentation and ensuring consistent memory access
times.
Power Efficiency
Power consumption is a critical issue, particularly for
battery-powered devices.
Software must be designed to minimize the system’s energy
use by efficiently managing resources.
Design Considerations:Low-Power Modes, Peripheral
Management, Efficient Code
Low-Power Modes: Utilize low-power modes (e.g., sleep or deep sleep)
available on microcontrollers when the system is idle. Ensure that the software
can transition in and out of these modes efficiently.
Peripheral Management: Disable unused peripherals or clock sources to
reduce power consumption. The software should manage peripheral power
states dynamically.
Efficient Code: Optimize code to minimize CPU cycles, which directly affects
power consumption. Avoid busy-wait loops or polling mechanisms that
consume unnecessary CPU time.
Concurrency and Synchronization
Many embedded systems handle concurrent tasks, whether via
multiple threads, interrupts, or processes.
Synchronization between these tasks must be managed carefully to avoid race
conditions, deadlocks, and priority inversion.
Design Considerations:
Mutexes and Semaphores,
Interrupt Prioritization,
Deadlock Avoidance and
Priority Inversion Handling(Implement priority inheritance mechanisms
to prevent priority inversion).
Chapter Five
Real-time Communication (RTC)
1
Basic concepts real time
communication/RTC/
RTC is any mode or types of telecommunications for
exchanging information
Its exchange of information instantly or with negligible
latency. Or
RTC is real-time is synonymous with live communication.
RTC always has a direct path between the source and the
destination.
2
Basic concepts and examples of
real time communication
RTC can take place in half-duplex or full-duplex modes
RTC generally refers to peer-to-peer (P2P) communications,
not broadcast or multicast.
3
Some examples of real time
communication (RTC)
4
Real time communication in LAN
6
Using Ethernet in Real time communication
8
Protocols used in Real-Time Communication
in LAN
1. Global Priority Protocol
The Messages are assigned a separate priority value.
Based on this value, the protocol will transmit the data to the
specific destination.
p=1 P=2 P=3 P=4 R2
R1
Example router1 need
to send data to router2
based on priority value
9
Protocols used in Real-Time Communication
in LAN
10
Protocols used in Real-Time Communication
in LAN
12
The goals of real-time communication
(RTC) in LAN
Low jitter--minimizing terror(jam)
Low latency—minimizing delay
Ability to integrate--non-real-time and real-time services
Adaptability of dynamically changing network and
traffic conditions
High effective bandwidth utilization.
Low overhead in header bits per packet or cell.
Low processing overheads per packet within the network
13
What is quality of service (QoS)
QoS is a set of technologies that to provide a guarantee to
run high-priority applications under limited network capacity.
The main objectives of QoS are to reduce packet loss,
latency and jitter on a network.
QoS controls and manages network resources by setting
priorities for specific types of data on the network
14
Methods to improve QoS
Generally to improve QoS methods or techniques are:
Resource reservation
Traffic shaping
Traffic policing
Scheduling mechanism
Admission control
15
Resource reservation
16
Resource reservation protocol (RSVP)
For improving QoS resource reservation is used for
reserving resource
It dynamically adapts to the change in route for the
efficient message transfer.
It is actually not a routing protocol.
RSVP operates at the Transport layer of the OSI model
Receiver node in the real time system initiates the protocol
RSVP is simplex(the receiver node just receives the packet
and does not wont to send data)
It is widely used in multimedia applications such as video
conferencing, streaming, and online gaming.
17
Resource reservation protocol (RSVP)
For improving QoS resource reservation is used for
reserving resource
It dynamically adapts to the change in route for the
efficient message transfer.
It is actually not a routing protocol.
RSVP operates at the Transport layer of the OSI model
Receiver node in the real time system initiates the protocol
RSVP is simplex(the receiver node just receives the packet
and does not wont to send data)
It is widely used in multimedia applications such as video
conferencing, streaming, and online gaming.
18
Resource reservation protocol (RSVP)
Advantages Disadvantages
19
Traffic shaping and policing in Real
time communication
In order to efficiently use of limited network resources, the
traffic sent by users must be limited.
To implement this, Traffic shaping and traffic policing are
used for limited resources
Before implementing traffic policing and traffic shaping
assess whether the traffic exceeds the rate limit.
Traffic shaping and
Traffic policing
20
Traffic shaping
Traffic shaping is a QoS technique configure to enable
higher-priority traffic to flow.
It makes traffic conform to a certain rate by giving the
packets some delay.
Traffic shaping, buffers packets with rates that are greater
than the traffic shaping rate and sends the buffered packets at
an event rate.
Traffic shaping also known as packet shaping,
Traffic shaping is a congestion management method that
regulates data transfer by delaying the flow of less important
or less desired packets.
21
Traffic shaping
Generally it is bandwidth management that delays the flow
of some types of packets in order to ensure higher priority
applications use network performance.
It used to control outbound (outgoing) traffic only
22
Traffic policing
23
Scheduling mechanisms
There are several of the most important link scheduling
1. First-In-First-Out (FIFO)
The FIFO scheduling discipline (also known as First-Come-
First-Served - FCFS) selects packets for link transmission.
2. Round Robin scheduling
Under this algorithm packets are again sorted into classes
such as class1, class2 (such as real time, non real time,
interactive, file transfer etc. ) as with priority queuing.
24
Scheduling mechanisms
2. Round Robin scheduling
However, rather than there being a strict priority of service
among classes, a round robin scheduler alternates service
among the classes.
In short, round robin scheduling, a class 1 packet is
transmitted, followed by a class 2 packet, followed by a class
1 packet, followed by a class 2 packet, etc.
25
Read this example for round robin scheduling
mechanism
Assume that packets 1, 2 and 4 belong to class 1, and packets 3 and 5
belong to class 2.
1 2 4 Class 1 3 5 Class 2
1 2 4 Class 1 3 5 Class 2
After the transmission of packet 3, the scheduler looks for a
class-1 packet and transmits packet 2.
After the transmission of packet 2, packet 4 is the only
queued packet and then it transmitted immediately after
packet 2.
if Packets 2, 3 and 5 arrive during the transmission of
packet 1 and thus queue for transmission how scheduler
will transmit all packets (think it and answer for your
self)? 27
Admission control
It is a mechanism used by router or switch to accept or reject
flow of traffic based on predefined parameters called flow
specification
Therefore before accepting flow for processing, router
checks specification to see its capacity such as bandwidth,
buffer size, CPU speed.
Admission control is a significant process from the point of
view of ensuring of QoS.
The main function of admission control is to estimate
capacity for the incoming traffic. 28