0% found this document useful (0 votes)
6 views

Chapter3 Embedded OS

The document discusses embedded operating systems. It covers their remarkable features, design approaches, use in real-time systems, scheduling algorithms, resource accessing, and embedded Linux. Some key points include embedded systems interacting with the external world, having constraints like power and size, and operating systems for embedded systems needing to be configurable, support real-time operations, and allow direct use of interrupts.

Uploaded by

hai Nguyen
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Chapter3 Embedded OS

The document discusses embedded operating systems. It covers their remarkable features, design approaches, use in real-time systems, scheduling algorithms, resource accessing, and embedded Linux. Some key points include embedded systems interacting with the external world, having constraints like power and size, and operating systems for embedded systems needing to be configurable, support real-time operations, and allow direct use of interrupts.

Uploaded by

hai Nguyen
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 71

Embedded

Operating Systems
Tien Pham Van, Dr. rer. nat.
Hanoi University of Science and Technology
Compiled with reference to other presentations

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Outlines

• Remarkable features
• Designing approaches
• Real-time systems
• Scheduling algorithms
• Resource accessing
• Embedded Linux

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Reminded features
• Part of larger system
– not a “computer with keyboard, display, etc.”
• HW & SW application-specific – not G.P.
– application is known a-priori
– definition and development concurrent
• Interact (sense, manipulate, communicate)
with the external world
• Never terminate (ideally)
• Operation is time constrained: latency,
throughput
• Other constraints: power, size, weight, heat,
reliability
• Increasingly high-performance (DSP) &
networked

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Embedded System as a Computer

Possible Organization of an Embedded System

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Operating System?

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
General vs. Embedded

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
When and what needed?

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Operating System

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Task states

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Multitasking

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Illusion of parallelism

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Programs, threads and Tasks

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
• Task- Process- Threads - YouTube
https://www.youtube.com/watch?v=o7zPffv8T2s

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Different Architectures

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Monolithic vs. Micro-kernel

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Characteristics

Real-time operation
• In many embedded system, the correctness of a computation
depends, in part, on the time at which it is delivered. Often, real-
time constraints are dictated by external I/O and control stability
requirements.
Reactive operation
• Embedded software may execute in response to external events. If
these events do not occur periodically or at predictable intervals,
the embedded software may need to take into account worst-case
conditions and set priorities for execution of routines.

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Characteristics

Configurability
• Because of the large variety of embedded systems, there is a large
variation in the requirements, both qualitative and quantitative,
for embedded OS functionality. Thus, an embedded OS intended
for use on a variety of embedded systems must lend itself to
flexible configurations so that only the functionality needed for a
specific application and hardware suite is provided.
• For example, the linking and loading functions can be used to
select only the necessary OS modules to load. Conditional
compilation can be used.
• However, verification of the end product can be a problem for
designs with a large number of derived tailored operating systems.

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Characteristics

I/O device flexibility


• There is virtually no device that needs to be supported by all
versions of the OS, and the range of I/O devices is large.
• Some effort has been expended in developing special tasks to deal
with relatively slow devices such as disks and network interfaces
instead of integrating their driver into the OS kernel.

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Characteristics

Streamlined protection mechanism


• Embedded systems are typically designed for a limited, well-
defined functionality. Untested programs are rarely added to the
software. After the software has been configured and tested, it
can be assumed to be reliable.
• Thus, apart from security measures, embedded systems have
limited protection mechanisms. For example, I/O instructions
need not be privileged instructions that trap to the OS; tasks can
directly perform their own I/O.
• Similarly, memory protection mechanisms can be minimized .

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Characteristics

Direct use of interrupts


• General purpose OS typically do not permit any user process to
use interrupts directly.
• In embedded systems, there are three legitimate reasons why it
allows an interrupt to directly start or stop tasks (by storing the
task’s start address in the interrupt vector address table), rather
than going through OS interrupt service routines: (1) embedded
systems can be considered to be thoroughly tested, with
infrequent modifications to the OS or application code; (2)
protection is not necessary; and (3) efficient control over a variety
of devices is required.

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
• Embedded Operating System and
Requirement Specifications of Embedded
Systems 16072020 - YouTube
https://www.youtube.com/watch?v=4szPd-XwQ58

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Approaches for OS

• The first approach is to take an existing OS and adapt it for the


embedded application.
• The other approach is to design and implement an OS intended
solely for embedded use.

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
From existing OS

• An existing OS can be used for an embedded system by adding


real-time capability, streamlining operations, and adding
necessary functionality.
• This approach most commonly today makes use of Linux.
• Such OS are generally slower and less predictable than a special-
purpose embedded OS.
• Once advantage of this approach is that the embedded OS derived
from the general-purpose OS is based on a set of familiar
interfaces, which facilitates portability.
• The main disadvantage of using a general-purpose OS is that it is
not optimized for real-time and embedded applications.

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Purpose-built OS

• A significant number of OS have been designed from the ground


up for embedded applications.
• Examples: TinyOS, QNX, eCos, FreeRTOS, VxWork…
• Real-time requirements are key features that motivate a different
set of design decisions, particularly in the area of task scheduling.

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Embedded OSs in IoT era

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Real-Time Applications Spectrum

Hard Real-Time VxWorks, Lynx, QNX, ...


Operating Intime, HyperKernel, RTX
System
Windows CE

Windows NT

General-Purpose
Operating
Soft System

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Embedded (Commercial) Kernels
Stripped down and optimized versions of timesharing OS
• Intended to be fast
– a fast context switch
– external interrupts recognized quickly
– the ability to lock code and data in memory
– special sequential files that can accumulate data at a fast rate
• To deal with timing requirements
– a real-time clock with special alarms and timeouts
– bounded execution time for most primitives
– real-time queuing disciplines such as earliest deadline first,
– primitives to delay/suspend/resume execution
– priority-driven best-effort scheduling or a table-driven mechanism.
• Communication and synchronization via mailboxes, events,
signals, and semaphores.
Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Real-Time Extensions to
General Purpose Operating Systems
E.g., extending LINUX to RT-LINUX, NT to RT-NT
• Advantage:
– based on a set of familiar interfaces (standards) that speed
development and facilitate portability.
• Disadvantages
– Too many basic and inappropriate underlying assumptions still
exist.

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Real-time execution

RTOS Concepts overview | TI.com Video


https://training.ti.com/rtos-concepts-overview

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Real-time tasks

•Apriodic tasks (non-critical)


•Periodic tasks (critical)

•Sporadic tasks (critical)

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Scheduling algorithms (1)

• Different kinds of real-time schedulers:

On-line/off-line scheduler: the scheduling is


computed before or at execution time?

Static/dynamic priority scheduler: priorities may


change at execution time?

Preemptive or non preemptive scheduler: can we


stop a task during its execution ?
1. Preemptive schedulers are more efficient than non
preemptive schedulers (e.g. missed deadlines).
2. Non preemptive schedulers ease the sharing of
resources.
3. Overhead due to context switches.
Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Scheduling algorithms

• Clock Driven
– Table-driven
– Cyclic
• Event Driven
– Rate Monotonic Analysis (RMA)
– Earliest Deadline First (EDF)
• Hybrid
– Round-robin

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Usual real-time schedulers

1. Fixed priority scheduler: Rate Monotonic priority


assignment (sometimes called Rate Monotonic
Scheduling RM, RMS).
2. Dynamic priority scheduler: Earliest Deadline First
(or EDF).

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Fixed priority scheduling (1)

• How does it work:

1. "Rate monotonic" task priority assignment: the


highest priority tasks have the smallest periods.
Priorities are assigned off-line (e.g. at design time,
before execution).
2. Fixed priority scheduling: at any time, run the ready
task which has the highest priority level.

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Fixed priority scheduling (2)

• Rate Monotonic assignment and preemptive scheduling:


Hyper-period
Assuming VxWorks priority levels (high=0 ; low=255)
T1 : C1=6, P1=10, Prio1=0

T2 : C2=9, P2=30, Prio2=1

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Fixed priority scheduling (3)
•Rate Monotonic assignment and non preemptive
scheduling:
Assuming VxWorks priority levels (high=0 ; low=255)
T1 : C1=6, P1=10, Prio1=0 peemptive va nonpeemptive anh

huong fen kha nang dung han


T2 : C2=9, P2=30, Prio2=1

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Fixed priority scheduling (4)

• Feasibility/Schedulability tests:
1. Run simulations on hyperperiod = [0, LCM (Pi)]. Sufficient and
necessary (exact result). Any priority assignment and
preemptive/non preemptive scheduling.

2. Processor utilization factor test:

Ci 1
U= Σn ≤ n(2n − 1)
i =1 Pi
Rate Monotonic assignment and preemptive scheduling. Sufficient
but not necessary. Does not compute an exact result.

3. Task worst case response time, noted r i = delay between task


release time and task end time. Can compute an exact result. Any
priority assignment and preemptive scheduling.
Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Fixed priority scheduling (5)

• Compute ri, the task worst case response time:


Assumptions: preemptive scheduling, synchronous periodic tasks.
task i response time = task i capacity + delay the task i has to wait
due to higher priority task j. Or:

thoi gian dap ung

or:

hp(i) is the set of tasks which have a higher priority than task i. x
returns the smallest integer not smaller than x.

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Fixed priority scheduling (6)

1. Check if all deadline can be met with RM?


2. Calculate response time of all the three tasks

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Fixed priority scheduling (7)

•How to schedule both periodic and aperiodic tasks, both


critical and non critical functions:

1. If aperiodic tasks are not urgent: give them a low


priority level.
2. If aperiodic tasks are urgent: use aperiodic tasks
servers.

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Fixed priority scheduling (8)
•Aperiodic tasks server: periodic task devoted to the scheduling of
aperiodic tasks.
T1 : C1=4 ; P1=20 (grey) Black=idle
T2 : C2=12 ; P2=30 (white)
S : CS=4 ; PS=10;
A is released at t=4 ; CA=3
B is released at t=9 ; CB=4

A B

AAAB BBB

4 10 12 20 23 27 30

Polling server: run aperiodic task arrived before server activation.


Does not use processor if no aperiodic task is present. Capacity is
lost if no aperiodic task is present. Server stops aperiodic execution
when its capacity is exhausted.
Many other servers: sporadic server, priority exchange server, ...
Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Earliest Deadline First (1)

• Assumptions and properties:

Dynamic priority scheduler = suitable fordynamic


real-time systems.
Is able to schedule both aperiodic and periodic tasks.
thuat toan toi
uu Optimal scheduler: can reach 100 % of the cpu usage.

But difficult to implement into a real-time operating


system.

Becomes unpredictable if the processor is over-loaded


not suitable for hard-critical real-time systems.

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Earliest Deadline First (2)

• How does it work:

1. Compute task priorities (called "dynamic


deadlines") D i (t) :the priority/dynamic deadline of
task i at time t:
Aperiodic task : D i (t) = D i + S i .
Periodic task: D i (t) = k + D i , where k is the task
release time before t.

2. Select the task: at any time, run the ready task which
has the shortest dynamic deadline.

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Earliest Deadline First (3)

•Preemptive case: (T1/blue, T2/yellow, C1=6; P1=10;


C2=9; P2=30)
t D1 (t) D2 (t)
0..9 k + D 1 = 0 + 10 = 10 k + D 2 = 0 + 30 = 30
10..19 k + D 1 = 10 + 10 = 20 30
20..29 k + D 1 = 20 + 10 = 30 30

uu tien do dang

so sanh deadline cua t1 vs t2


voi nhau de bat dau 1 chu ki
uu tien tac vu deadline t1

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Earliest Deadline First (4)

• Non-preemptive case: khong uu tien

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Earliest Deadline First (5)

• Feasibility tests/schedulability tests:

1. Run simulations on hyperperiod = [0, LCM (Pi)].


Sufficient and necessary (exact result).

2. Processor utilization factor test (e.g. preemptive


case):

Ci
U= Σn ≤1
Pi
i=1

Sufficient and necessary. Difficult to use in real life


applications. Compute an exact result.
3. Task response time: a bit more complex to compute
(dynamic scheduler) !
Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
EDF vs RM: summary

• Aperiodic task = non critical task.


• Periodic task = critical task.

FP/RM EDF
Applications critical, static dynamic, less critical
RTOS easy more difficult
implementation
Tasks Periodic only Aperiodic and periodic
Efficiency upto 69 % upto 100 %
Predictability high less than FP/RM if U > 1

•Warning: the real picture is more complicated: aperiodic


tasks scheduling with FP/RM, U=1 with FP/RM, ...

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Multiprocessor/distributed (2)

1. Global scheduling: choose a task, and assign it to one of the idle


processors (otherwise, preempt one of the running task). On-line
processor assignment. With migration.
2. Partitioning: choose a processor for all tasks, and then run local
scheduler on each processor. No migration. May apply end-to-end
worst case response time analysis. Off-line processor assignment.

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Task dependencies

• Usual dependencies:

1. Shared resources.
2. Precedences between tasks.

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Shared resource support (1)
•In real-time scheduling theory, a shared resource is
modeled by a semaphore:
Task i Task j

P(sem) P(sem)
access_shared_resou access_shared_resou

rce(k) V(sem) rce(k) V(sem)


P(s) V(s)
{ {
s.cpt=s.cpt−1; s.cpt=s.cpt+1;
if (s.cpt<0) if (s.cpt>=0)
{ {
add_task_to_the_queue(s.fil remove_task_from_the_queue(s
e); task_is_blocked(); .file) task_is_released();
} }
} }

Semaphore = counter + a FIFO queue.


A semaphore may be used to model a critical section.
We use special semaphores in real-time scheduling systems.
Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Deadlock

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Shared resource support (1)

• Priority Inheritance Protocol or PIP: A task which blocks a high


priority task due to a critical section, sees its priority to be increased
to the priority level of the blocked task.

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Shared resource support (2)

• PIP can not be used with more than one shared


resource due to deadlock.
• PCP (Priority Ceiling Protocol) is used instead. chiem quyen uu tien cao nhat

• Implemented in most of real-time operating systems


(e.g. VxWorks).
• Several implementations of PCP exists: OCPP, ICPP, ...

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Verification of a real-time system

•How to perform verification of timing constraints of a


real-time system (example):
1. Define/model hardware architecture and execution environment:
capacity of the memory, processor, operating system features (and
then the scheduler).
2. Implement functions (source code).
3. Design software architecture and software deployment on the
hardware. Lead to a design of the software as a set of tasks, with
their parameters and constraints.
4. Verify schedulability.

5. If task set is not feasible, go back to 1, 2 or 3.

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Scheduling analysis tools (1)

• Scheduling analysis tools must provide:


A way to model the system architecture to be analyzed.
Analysis tools based on:

1. Algebraic/analytical tools: run feasibility tests.


2. Model-checking: compute all reachable states of the system
and analyze this set of states.
3. Scheduling simulations: compute scheduling time-lines and
analyze them (partial checking).

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Scheduling analysis tools (3)

• Examples of both commercial and open-source tools:

MAST (University of Cantabria, http://mast.unican.es/).


Rapid-RMA (Tri-Pacific Software Inc,
https://www.embeddedtechnology.com/doc/rapidrma
-0001).

Times (University of Uppsala,


http://www.timestool.com/) Cheddar (University of Brest
and Ellidiss Technologies,
http://beru.univ-brest.fr/cheddar/).
...

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Case study: Embedded Linux

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Linux OS architecture

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Embedded Linux

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
C library

• Provides basic functionality for file I/O,


process synchronization and communication,
string handling, arithmetic operations, and
memory management

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
C library
• Embedded systems need small sizes of Glibc
variants

• uClibc –a microcontroller C library that is


small in size for use in embedded system
(MMU-less)
• musl – small and a good choice in systems
with a limited amount of RAM and storage
Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
BusyBox

• All utilities for start-up, control and


monitoring, user/developer operations,
configuration must be small, simplified and
limited
• BusyBox provides a number of simplified
essential Unix utilities in a single executable
file. BusyBox reduces the overhead
introduced by the executable file format and
allows code to be shared between multiple
applications without requiring a library
Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Cross-compile

• Anatomy of Cross-Compilation Toolchains -


YouTube
https://www.youtube.com/watch?v=Pbt330zuNPc

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Boot loader

handles basic hardware


initialization and loads the
operating system from
bootable devices like the
hard drive or an SD card or
flash memory in an
embedded Linux system

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Real Time Linux approaches

1. Modify the current Linux kernel to handle RT constraints


– Used by KURT

2. Make the standard Linux kernel run as a task of the real-time


kernel
– Used by RT-Linux, RTAI

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Modifying Linux kernel

• Advantages
– Most problems, such as interrupt handling, already
solved
– Less initial labor
• Disadvantages
– No guaranteed performance
– RT tasks don’t always have precedence over non-RT tasks.

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
67
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Running Linux as a process of a second RT kernel
•Advantages
Can make hard real time guarantees
Easy to implement a new scheduler
•Disadvantages
Initial port difficult, must know a lot about underlying hardware
Running a small real-time executive is not a substitute for a full-fledged RTOS

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
68
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Source code implementation

• Real Time is Coming to Linux; What Does that


Mean to You? - Steven Rostedt, VMware -
YouTube
https://www.youtube.com/watch?v=BxJm-Ujipcg

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Further investigation

• RTwiki (kernel.org) or realtime:start [Wiki]


(linuxfoundation.org)
https://rt.wiki.kernel.org/index.php/Main_Page
https://wiki.linuxfoundation.org/realtime/start

Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596
Future developments

• Computing power gets larger: clock, register size,


ROM/RAM, etc
• Higher parallelism: more cores/processors/co-
processors, more threads
• Less energy consumption
• Various communication interconnection
• More intelligent: inputting, processing data and
identifying operation contexts
• Higher distribution and decentralization
• Smaller size/footprint: TinyOS, NanoOS, etc
• More flexible and customizable
Embedded Networking Research Group School of Elec. and Telecom - Hanoi University of Science and Technology
71
Email: [email protected] C9-411, Dai Co Viet str. 1, HBT, Hanoi Tel: +84-243-8693596

You might also like