Real-Time OS
(RTOS)

Copyright © 2012 Embedded Systems
Committee
Agenda
•
•
•
•
•
•

Basic Definitions
Introduction to RTOS
Scheduling Algorithms
Reentrancy
Shared Resources
RTOS APIs

Copyright © 2012 Embedded Systems
Committee
Agenda
•
•
•
•
•
•

Basic Definitions
Introduction to RTOS
Scheduling Algorithms
Reentrancy
Shared Resources
RTOS APIs

Copyright © 2012 Embedded Systems
Committee
Basic Definitions
• What are the Real-Time systems?
– “Those systems in which the correctness of system
depends not only on the logical result of the
computation, but also on the time at which the results
are produced”

Copyright © 2012 Embedded Systems
Committee
Basic Definitions
• Specifications of a Real-Time system include
both:
– Logical: Produces correct outputs.
– Temporal: Produces outputs at the right time.

Copyright © 2012 Embedded Systems
Committee
Basic Definitions
• Types of Real-Time requirements are:
– Hard: Failure to meet constraint is fatal.
– Soft: Late completion degrades software quality.

Copyright © 2012 Embedded Systems
Committee
Basic Definitions
• Misconceptions:
– “Real-Time computing is equivalent to fast
computing”
– Truth is:“Real-Time computing is equivalent to
predictable computing”

Copyright © 2012 Embedded Systems
Committee
Basic Definitions
• Misconceptions:
– “Real-Time programming assembly coding”
– Truth is: “It is better to automate (as much as
possible) Real-Time system design, instead of relying
on a clever hand-crafted code”

Copyright © 2012 Embedded Systems
Committee
Basic Definitions
• Misconceptions:
– “Real-Time means performance engineering”
– Truth is: “In Real-Time computing, timeliness is
always more important than performance.

Copyright © 2012 Embedded Systems
Committee
Basic Definitions
• Misconceptions:
– RTOS introduce considerable amount of overhead
on CPU
– Truth is: An RTOS typically only require between 1%
to 4% of a CPU time.

Copyright © 2012 Embedded Systems
Committee
Basic Definitions
Real-Time
Embedded
Systems
Embedded Systems

Real-Time Systems

Copyright © 2012 Embedded Systems
Committee
Agenda
•
•
•
•
•
•

Basic Definitions
Introduction to RTOS
Scheduling Algorithms
Reentrancy
Shared Resources
RTOS APIs

Copyright © 2012 Embedded Systems
Committee
Introduction to RTOS

Copyright © 2012 Embedded Systems
Committee
Introduction to RTOS
• Basic Services provided by OS:
–
–
–
–
–

Task Management.
Intertask Communication & synchronization.
Timers.
Device I/O Supervision.
Dynamic Memory Allocation.

Copyright © 2012 Embedded Systems
Committee
Introduction to RTOS
• What are tasks?
- A task─ an independent process.
- No task can call another task. unlike the normal C function
which can call another function.
void task(void)
{
/*Some Initialization Code*/
for(;;)
{
/*Task Code*/
}
}
Copyright © 2012 Embedded Systems
Committee
Introduction to RTOS
• What is multitasking?

Copyright © 2012 Embedded Systems
Committee
Introduction to RTOS
• What is context?
PC

ROM

RAM
SP

Copyright © 2012 Embedded Systems
Committee

CPU
Registers
Introduction to RTOS
• What is context?
ROM

Task 1CPU
Registers

RAM
Task2
Stack
Task1 Control Block
Task1
Stack
Task2 Control Block
Copyright © 2012 Embedded Systems
Committee

Task 2CPU
Registers
Introduction to RTOS
• What is context?

Copyright © 2012 Embedded Systems
Committee
Introduction to RTOS
• Task Life Cycle:

Copyright © 2012 Embedded Systems
Committee
Introduction to RTOS
• What is the difference between RTOS & GPOS?

Task
Switching
Time

GPOS

RTOS
Number of Tasks That Can Be Scheduled
Copyright © 2012 Embedded Systems
Committee
Introduction to RTOS
• Characteristics of an RTOS?
–
–
–
–
–

Reliability
Predictability
Performance
Compactness
Scalability

Copyright © 2012 Embedded Systems
Committee
Agenda
•
•
•
•
•
•

Basic Definitions
Introduction to RTOS
Scheduling Algorithms
Reentrancy
Shared Resources
RTOS APIs

Copyright © 2012 Embedded Systems
Committee
Scheduling Algorithms
• What is a scheduler?
– It is part of the kernel which decides which task can
run when.
– There are many algorithms for scheduling & they can
be categorized into two main categories.

Copyright © 2012 Embedded Systems
Committee
Scheduling Algorithms
• Non-preemptive (Suppose it is priority based):
Task1

Time

Copyright © 2012 Embedded Systems
Committee
Scheduling Algorithms
• Non-preemptive:
Task1

Time
ISR

Copyright © 2012 Embedded Systems
Committee
Scheduling Algorithms
• Non-preemptive:
Task1

Time
ISR
Task2
is
Ready

Copyright © 2012 Embedded Systems
Committee
Scheduling Algorithms
• Non-preemptive:
Task1

Time
ISR
Task2
is
Ready

Task1

Copyright © 2012 Embedded Systems
Committee
Scheduling Algorithms
• Non-preemptive:
Task1

Time
ISR
Task2
is
Ready

Task1
Although task2 is higher in priority than
task1, task 1 gets to finish before task2
gets to start.
Copyright © 2012 Embedded Systems
Committee

Task2
Scheduling Algorithms
• Preemptive (Suppose it is priority based):
Task1

Time

Copyright © 2012 Embedded Systems
Committee
Scheduling Algorithms
• Preemptive:
Task1

Time
ISR

Copyright © 2012 Embedded Systems
Committee
Scheduling Algorithms
• Preemptive:
Task1

Time
ISR

Copyright © 2012 Embedded Systems
Committee
Scheduling Algorithms
• Preemptive:
Task1

Time
ISR
Task2

Copyright © 2012 Embedded Systems
Committee
Scheduling Algorithms
• Preemptive:
Task1

Time
ISR
Task2

Task1

Copyright © 2012 Embedded Systems
Committee
Agenda
•
•
•
•
•
•

Basic Definitions
Introduction to RTOS
Scheduling Algorithms
Reentrancy
Shared Resources
RTOS APIs

Copyright © 2012 Embedded Systems
Committee
Reentrancy
C
char x;
void foo1(void)
{
x++;
}

Task1
/*Some Code*/
foo1();
/*Some Code*/

Assembly
char x;
foo1:
mov R1,x;
add R1,1;
mov x,R1;

Task2
/*Some Code*/
foo1();
/*Some Code*/

Copyright © 2012 Embedded Systems
Committee
Reentrancy
x=1
Task 1: R1=0

Task 2: R1=0

Copyright © 2012 Embedded Systems
Committee
Reentrancy
x=1
Task 1: R1=1

Task 2: R1=0

mov R1,x;

Copyright © 2012 Embedded Systems
Committee
Reentrancy
x=1
Task 1: R1=2

Task 2: R1=0

mov R1,x;
add R1,1;

Copyright © 2012 Embedded Systems
Committee
Reentrancy
x=2
Task 1: R1=2

Task 2: R1=0

mov R1,x;
add R1,1;
mov x,R1;

Copyright © 2012 Embedded Systems
Committee
Reentrancy
x=2
Task 1: R1=2

Task 2: R1=0

mov R1,x;
add R1,1;
mov x,R1;

Context Switching
Task2 is ready
Copyright © 2012 Embedded Systems
Committee
Reentrancy
x=2
Task 1: R1=2

Task 2: R1=2

mov R1,x;
add R1,1;
mov x,R1;

mov R1,x;

Copyright © 2012 Embedded Systems
Committee
Reentrancy
x=2
Task 1: R1=2

Task 2: R1=3

mov R1,x;
add R1,1;
mov x,R1;

mov R1,x;
add R1,1;

Copyright © 2012 Embedded Systems
Committee
Reentrancy
x=3
Task 1: R1=2

Task 2: R1=3

mov R1,x;
add R1,1;
mov x,R1;

mov R1,x;
add R1,1;
mov x,R1;

Copyright © 2012 Embedded Systems
Committee
Reentrancy (Another Scenario)
x=1
Task 1: R1=0

Task 2: R1=0

Copyright © 2012 Embedded Systems
Committee
Reentrancy
x=1
Task 1: R1=1

Task 2: R1=1

mov R1,x;

Copyright © 2012 Embedded Systems
Committee
Reentrancy
x=1
Task 1: R1=1

Task 2: R1=1

mov R1,x;

Context Switching
Task2 is ready
Copyright © 2012 Embedded Systems
Committee
Reentrancy
x=1
Task 1: R1=1

Task 2: R1=1

mov R1,x;

mov R1,x;

Copyright © 2012 Embedded Systems
Committee
Reentrancy
x=1
Task 1: R1=1

Task 2: R1=2

mov R1,x;

mov R1,x;
add R1,1;

Copyright © 2012 Embedded Systems
Committee
Reentrancy
x=2
Task 1: R1=1

Task 2: R1=2

mov R1,x;

mov R1,x;
add R1,1;
mov x,R1

Copyright © 2012 Embedded Systems
Committee
Reentrancy
x=2
Task 1: R1=1

Task 2: R1=2

mov R1,x;

mov R1,x;
add R1,1;
mov x,R1;

Context Switching
Task2 is back to waiting

Copyright © 2012 Embedded Systems
Committee
Reentrancy
x=2
Task 1: R1=2

Task 2: R1=2

mov R1,x;
add R1,1;

mov R1,x;
add R1,1;
mov x,R1;

Copyright © 2012 Embedded Systems
Committee
Reentrancy
x=2
Task 1: R1=2

Task 2: R1=2

mov R1,x;
add R1,1;
mov x,R1;

mov R1,x;
add R1,1;
mov x,R1;

Copyright © 2012 Embedded Systems
Committee
Reentrancy
• When to doubt your function reentrancy?
– When your function accesses a global variable while
this variable is accessed in:
• ISR
• Another task
• Hardware module.

Copyright © 2012 Embedded Systems
Committee
Reentrancy
• How to make a non-reentrant function reentrant?
– Either using critical section or any task
synchronization services provided by the OS.

Copyright © 2012 Embedded Systems
Committee
Reentrancy
• Critical Section:
– Context Switching always happens after an interrupt.
– If I disabled interrupts during the time I don’t want
the schedule nor any ISR interrupts the running task
then this part of code is reentrant.
char x;
void foo1(void)
{
DI;
x++;
EI;
}
Copyright © 2012 Embedded Systems
Committee
Agenda
•
•
•
•
•
•

Basic Definitions
Introduction to RTOS
Scheduling Algorithms
Reentrancy
Shared Resources
RTOS APIs

Copyright © 2012 Embedded Systems
Committee
Shared Resources
• Tasks always race each other for resources.
• Resources could be many thing like HW
modules, memory & even CPU time.
• We have to control the tasks resources access to
avoid data corruption or basically any
undesirable behavior.
• Semaphores are just one methods of controlling
resources access.
Copyright © 2012 Embedded Systems
Committee
Shared Resources
• Semaphore vs. mutex

Copyright © 2012 Embedded Systems
Committee
Intertask Communication
• global variable
RAM
Task 1
write X

X

Task 2
read X
Copyright © 2012 Embedded Systems
Committee
Intertask Communication
• Mailboxes
- Any task can send a message to a mailbox and any task can receive a message
from a mailbox

Copyright © 2012 Embedded Systems
Committee
Intertask Communication
• Message Queues

Copyright © 2012 Embedded Systems
Committee
Agenda
•
•
•
•
•
•

Basic Definitions
Introduction to RTOS
Scheduling Algorithms
Reentrancy
Shared Resources
RTOS APIs

Copyright © 2012 Embedded Systems
Committee
RTOS APIs “uCOS-III”
•
•
•
•
•
•
•
•
•

OSTaskCreate (Task ptr, arg, prio, stack size)
OSSemCreate (Sem ptr, counter)
OSSemPost (Sem ptr)
OSSemPend (Sem ptr,Timeout)
OSTmrCreate (Tmr ptr, period, callback)
OSTmrStart, OSTmrStop (Tmr ptr)
OSMemCreate (mem ptr, block size, n blocks)
OSMemPut (mem ptr, blk ptr)
OSMemGet (mem ptr)
Copyright © 2012 Embedded Systems
Committee
References
• uC/OS-II, Jean Labrosse
• Operating Systems: Design & Implementation,
Andrew Tanenbaum
• Embedded.com

Copyright © 2012 Embedded Systems
Committee
Website: www.escommittee.net
Contact Us: info@escommittee.net

FB: Embedded Systems Committee

Copyright © 2012 Embedded Systems
Committee

More Related Content

PDF
File systems for Embedded Linux
PPTX
Can bus
PPT
Real-Time Operating Systems
PPT
Assembly language programming_fundamentals 8086
PDF
RTOS - Real Time Operating Systems
PDF
Linux Systems: Getting started with setting up an Embedded platform
PDF
Architecture of TPU, GPU and CPU
File systems for Embedded Linux
Can bus
Real-Time Operating Systems
Assembly language programming_fundamentals 8086
RTOS - Real Time Operating Systems
Linux Systems: Getting started with setting up an Embedded platform
Architecture of TPU, GPU and CPU

What's hot (20)

ODP
Control Area Network
PDF
CPU Verification
PDF
LAS16-105: Walkthrough of the EAS kernel adaptation to the Android Common Kernel
PPTX
Embedded development life cycle
PPTX
Kernels and its types
PPTX
Cache memory
PPTX
Classification of embedded systems
PDF
LCA14: LCA14-306: CPUidle & CPUfreq integration with scheduler
PPTX
Context switching
PPT
Controller area network (CAN bus) ppt
PDF
BKK16-208 EAS
PPTX
Cache memory ppt
PPTX
CAN Bus
PPTX
Asynchronous data transfer
PPTX
Problem reduction AND OR GRAPH & AO* algorithm.ppt
PPT
PPTX
Ca npp t
PDF
LCE12: How to measure SoC power
PPTX
ARM Exception and interrupts
PPTX
VTU 18CPS13/23 CPPS module-1 PPT
Control Area Network
CPU Verification
LAS16-105: Walkthrough of the EAS kernel adaptation to the Android Common Kernel
Embedded development life cycle
Kernels and its types
Cache memory
Classification of embedded systems
LCA14: LCA14-306: CPUidle & CPUfreq integration with scheduler
Context switching
Controller area network (CAN bus) ppt
BKK16-208 EAS
Cache memory ppt
CAN Bus
Asynchronous data transfer
Problem reduction AND OR GRAPH & AO* algorithm.ppt
Ca npp t
LCE12: How to measure SoC power
ARM Exception and interrupts
VTU 18CPS13/23 CPPS module-1 PPT
Ad

Viewers also liked (20)

PPTX
Real Time OS For Embedded Systems
PPT
RTOS Basic Concepts
PDF
Regulamento concursoleituraconcelho ourem_aeco
PDF
สังคม
PDF
Atlas corporate profile
PDF
อังกฤษ
DOC
แบบโครงร่างโครงงานคอมพิวเตอร์
PDF
ประวัติส่วนตัว
PPTX
Bigalytics
PPTX
Kbox 101 1000 slide
PPTX
Mô tả dự án
PPT
Sp soft profile (15-may-2012)
PPTX
Mô tả dự án
PPTX
Pr i ncess!!!
PPTX
Mo ta du an
PPTX
Unlocking funding opportunities final
PDF
คณิต
DOCX
Project Report
PPTX
Obeijodapalavrinha2miacouto
PDF
ไทย
Real Time OS For Embedded Systems
RTOS Basic Concepts
Regulamento concursoleituraconcelho ourem_aeco
สังคม
Atlas corporate profile
อังกฤษ
แบบโครงร่างโครงงานคอมพิวเตอร์
ประวัติส่วนตัว
Bigalytics
Kbox 101 1000 slide
Mô tả dự án
Sp soft profile (15-may-2012)
Mô tả dự án
Pr i ncess!!!
Mo ta du an
Unlocking funding opportunities final
คณิต
Project Report
Obeijodapalavrinha2miacouto
ไทย
Ad

Similar to Rtos (20)

PDF
Intro To RTOS by Silicon labs covering fundamentals
PDF
RTOS implementation
PDF
PPT
1230 Rtf Final
PPTX
REAL TIME OPERATING SYSTEM
PPTX
Embedded os
PPT
Real-Time Operating Systems Real-Time Operating Systems RTOS .ppt
PPTX
UNIT II PPT.pptx
PPT
21-Classification of Real time system-12-02-2025.ppt
PDF
Autosar Basics hand book_v1
PPTX
OVERVIEW OF RTOS
PPT
Rtos Concepts
PPTX
Real time Operating System
PPTX
Real Time Operating Systems, Dynamic Precision: Exploring the Realm of Real-...
PPTX
ERTOS_Spectrum_Unit01_PresentationP.pptx
PPTX
Rtos concepts
PPTX
PPT
presentation on real time operating system(RTOS's)
PPTX
Embtjhofigkjgzyuibchvjkheddejfjhgjhjgkmd system-3.pptx
PDF
Real time operating system
Intro To RTOS by Silicon labs covering fundamentals
RTOS implementation
1230 Rtf Final
REAL TIME OPERATING SYSTEM
Embedded os
Real-Time Operating Systems Real-Time Operating Systems RTOS .ppt
UNIT II PPT.pptx
21-Classification of Real time system-12-02-2025.ppt
Autosar Basics hand book_v1
OVERVIEW OF RTOS
Rtos Concepts
Real time Operating System
Real Time Operating Systems, Dynamic Precision: Exploring the Realm of Real-...
ERTOS_Spectrum_Unit01_PresentationP.pptx
Rtos concepts
presentation on real time operating system(RTOS's)
Embtjhofigkjgzyuibchvjkheddejfjhgjhjgkmd system-3.pptx
Real time operating system

More from محمدعبد الحى (16)

PDF
Iso26262 component reuse_webinar
PDF
Interfacing using ِAtmega16/32
PDF
Embedded Systems in Automotive
PDF
MATLAB Programming
PDF
CPU Architecture
PDF
8 bit microcontroller
PDF
Matlab workshop
PDF
Micro controller
Iso26262 component reuse_webinar
Interfacing using ِAtmega16/32
Embedded Systems in Automotive
MATLAB Programming
CPU Architecture
8 bit microcontroller
Matlab workshop
Micro controller

Recently uploaded (20)

PPTX
Microsoft Excel 365/2024 Beginner's training
PDF
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PDF
UiPath Agentic Automation session 1: RPA to Agents
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PPTX
Chapter 5: Probability Theory and Statistics
PPTX
Custom Battery Pack Design Considerations for Performance and Safety
PDF
Two-dimensional Klein-Gordon and Sine-Gordon numerical solutions based on dee...
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
Architecture types and enterprise applications.pdf
PPT
What is a Computer? Input Devices /output devices
PDF
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
PDF
A review of recent deep learning applications in wood surface defect identifi...
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
Developing a website for English-speaking practice to English as a foreign la...
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
Abstractive summarization using multilingual text-to-text transfer transforme...
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PPTX
The various Industrial Revolutions .pptx
Microsoft Excel 365/2024 Beginner's training
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
NewMind AI Weekly Chronicles – August ’25 Week III
UiPath Agentic Automation session 1: RPA to Agents
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
Chapter 5: Probability Theory and Statistics
Custom Battery Pack Design Considerations for Performance and Safety
Two-dimensional Klein-Gordon and Sine-Gordon numerical solutions based on dee...
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Architecture types and enterprise applications.pdf
What is a Computer? Input Devices /output devices
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
A review of recent deep learning applications in wood surface defect identifi...
1 - Historical Antecedents, Social Consideration.pdf
Developing a website for English-speaking practice to English as a foreign la...
Final SEM Unit 1 for mit wpu at pune .pptx
Hindi spoken digit analysis for native and non-native speakers
Abstractive summarization using multilingual text-to-text transfer transforme...
Taming the Chaos: How to Turn Unstructured Data into Decisions
The various Industrial Revolutions .pptx

Rtos