SlideShare a Scribd company logo
1 of 44
Download to read offline
Pharos
Real-Time Operating System for Critical Systems
Introduction
Summary
◼ Real-time systems & motivation
◼ Pharos
❑ Time Protection
❑ Memory Protection
❑ Intra-partition communication/synchronization
❑ Inter-partition communication/synchronization
❑ CPUs supported
◼ Future plans
Real-time systems criticality
◼ Real-time systems can be classified
according to their criticality. Some examples:
❑ Highly critical
◼ Attitude control on an airplane
❑ Medium critical
◼ Emergency light
❑ Low critical
◼ Infotainment on an automobile
❑ Non critical
◼ Web-site
Real-time systems criticality
◼ The exact level of criticality is defined
according to the standard followed.
◼ For example:
❑ Aviation: DO178C classifies from DAL-A (highest
criticality) to DAL-E (lowest criticality)
Critical and non-critical systems
◼ Both critical and non-critical can sometimes
co-exist on the same system
◼ Usually placed on different CPUs/Boards
◼ Highly critical systems are typically well-
behaved and “simple” (~10K LOCs)
◼ Non-critical systems are typically a “mess”
and complex (>1M LOCs)
◼ They sometimes share the same resources
RTOS vs OS
◼ Low critical systems use extensively an
Operating System (e.g. Linux, Windows)
◼ Highly critical systems many times also use a
a Real-Time Operating System (RTOS) which
has some special conditions
RTOS Main features
◼ There are many different definitions of what a
RTOS is supposed to do
◼ “Main” features are:
❑ Fixed-priority preemptive scheduler
◼ CPU is running always the highest priority ready thread
❑ Fast critical sections
◼ interrupts disabled for “short” amount of time)
❑ Deterministic
◼ each call takes a known maximum amount of time (e.g.
semaphore obtain)
RTOS Other features
◼ “Secondary” features
❑ Health monitoring
◼ Check if deadlines were missed and allow the
application to deal with them
❑ “Good” API
◼ Semaphores with priority inheritance/ceiling algorithms
◼ Message queues
◼ Events
◼ Interrupt processing
❑ Support a wide variety of CPUs
RTOS Partitioning
◼ Even other features are useful, such as dividing the
application into partitions
◼ Partitioning features
❑ Memory protection
◼ Don’t allow a part of the application (e.g. driver for CAN) mess
with the memory area of another part of the application (e.g.
TCP/IP stack) or the RTOS kernel itself
❑ Time protection
◼ Each partition or thread could have an amount of time to
execute in, no matter what the rest of the systems does
❑ Inter-partition communication/synchronization
◼ Allow a partitions to communicate with each other
◼ If not bounded, an erroneous partition could overload another
partition with unwanted communication
RTOS Scheduling
◼ Objective
❑ Give equation to make sure all deadlines are met
Examples:
◼ RMS (CPU% < 70%)
◼ EDF (CPU% < 100%)
◼ Response time analysis (Ra < Da)
◼ Equation depends (heavily) on the scheduler used
◼ Examples
❑ Rate monotonic scheduler
❑ Earliest Deadline First
❑ Fixed priority
❑ Preemptive vs non-preemptive
Threads
◼ Threads are typically classified as:
❑ Periodic
◼ Period (Ti)
◼ Deadline (Di)
◼ Job worst case execution time (ci)
◼ First release instant (ri)
❑ Sporadic
◼ Minimum Inter-arrival Time (MITi)
◼ Deadline (Di)
◼ Job worst case execution time (ci)
❑ Aperiodic
Periodic thread
t
Deadine
Deadline
Period
Deadline
Start Job Deadine
Thread executing in several instances of
time (depending on when other threads are
executing)
Second time the thread is executing. This
time the thread is faster (maybe some
calculations are done faster)
t
Sporadic thread
t
1st job start
1st
Deadline
2nd job Start
MIT
Activate sporadic thread
(before MIT has elapsed)
MIT
3rd job Start
MIT
Activations of the sporadic thread (e.g. Interrupt
occurred and relased a semaphore)
2nd
Deadline
MIT from 1st job already elapsed, so the thread is
activated right away (and the deadline as well)
Have to wait for the MIT from the 2nd job to elapse
before activating the thread
Aperiodic thread
◼ Aperiodic threads can execute whatever they
like, there is no definition for maximum
execution time, period, whatever
◼ For this reason they are normally not
considered in real-time systems
Thread Priority
◼ Fixed
❑ Priority does not change with time (with perhaps some
exceptions, like the semaphore ceiling)
❑ Easier to implement
❑ “Easy” for programmer to define the priority
◼ Dynamic
❑ priority changes with time
❑ Harder to implement
❑ How to define the priority? Based on deadline, laxity, etc
◼ If deadline, not all threads can have a deadline (for example,
aperiodic threads by definition don’t have a deadline)
Preemptiveness
◼ Preemptive
❑ If a higher priority thread becomes ready, the RTOS
switches the CPU to that thread
=> the highest priority ready thread is always executing
❑ Mutual exclusion must be ensured by the programmer
◼ Non-preemptive
❑ The thread must explicitly relinquish the CPU to change to
another thread
=> the highest priority read thread may not be always
executing
❑ Mutual exclusion does not need to be programmed using
semaphores
Rate Monotonic Scheduler – RMS
◼ One of many possible algorithms for fixed-priority
◼ The RMS only defines the priority of the threads based on their
period: the lower the period, the higher the priority
❑ Therefore the original version of RMS only considers periodic
threads
❑ Extensions were made for sporadic threads, where the period is
replaced by the MIT
◼ In an application with only periodic threads, is the optimum
scheduler
❑ in the sense that if it there is any algorithm to define the priorities
with all threads being schedulable, then the RMS will also give a
schedulable set of threads
◼ Simplified schedulability equation (with preemption)
❑ %CPU < 69%
Fixed priority schedulers
◼ Repeat: the RMS only defines the priority of
the threads based on their period
◼ You can define the priority of yours threads
as you wish, but the RMS schedulability
equation will NOT be applicable
◼ Instead you could use the Response-Time
Analysis (RTA) schedulability equations
Response-Time Analysis – RTA
◼ Calculate the Response Time (Ri) of each
thread and see if it is lower than the Deadline
(Di):
◼ Use iterations to solve the equation:
Earliest Deadline First – EDF
◼ All threads need to have a deadline
◼ The thread with the nearest deadline will be
using the CPU
◼ How to define a deadline for threads that
typical don’t have one? Examples: video,
TCP/IP comm
◼ Schedulability equation is easy (with
preemption):
❑ %CPU < 100%
RTOS Scheduler – EDF vs RMS
◼ Myth: EDF is “better” than Rate Monotonic
(RMS)
❑ The origin for this myth is that the most used
schedulability equation for the EDF and RMS
❑ EDF: CPU% < 100%
❑ RMS: CPU% < 70%
❑ But there are other schedulability analysis that
can (or not, depending on the system) allow the
CPU% to increase to 100% using the RMS
Real time systems – summary
◼ Now we have a good understanding of real-
time systems
❑ Criticality
❑ Schedulability
❑ Types of threads (periodic/sporadic/aperiodic)
Real-time systems mixing criticality –
ARINC 653
◼ In some systems it is possible to mix critical
and non-critical systems in the same CPU.
◼ Example:
❑ ARINC 653
◼ In ARINC 653, each partition has a pre-
defined time slot and its threads can only
execute on that slot
ARINC 653 example
ARINC 653 questions
◼ Some questions arise with this fixed partition
scheduling:
❑ Q: How to respond to an external event quickly?
❑ A: Polling
❑ Q: Doesn’t that waste a lot of time?
❑ A: Yes, it does
❑ Q: What happens if a partition does not have anything to
do, that is, it is idle?
❑ A: Its time slot is wasted
Pharos
◼ Pharos is a RTOS that tries to solve these
questions while maintaining the very good
mixed-criticality feature of ARINC 653
◼ But how to ensure time protection and still
give a good responsive system (and not
waste time doing idle tasks)?
Pharos – time protection (1)
◼ Pharos supports natively the three types of
threads:
❑ Periodic
❑ Sporadic
❑ Aperiodic
Pharos – time protection (2)
◼ Pharos allows the application to configure periodic
threads with:
❑ Period
❑ Worst case execution time (WCET)
❑ Release instant
❑ Deadline
◼ If a periodic thread attempts to use more execution
time than the configured WCET, Pharos will stop it
and raise an error to the application
◼ This ensures that periodic threads CANNOT
execute longer than they are supposed to
Pharos – time protection (3)
◼ Pharos allows the application to configure sporadic
threads with:
❑ MIT
❑ Worst case execution time (WCET)
❑ Deadline
◼ If a sporadic thread attempts to use more execution
time than the configured WCET, Pharos will stop it
and raise an error to the application
◼ This ensures that sporadic threads CANNOT
execute longer than they are supposed to
Pharos – time protection (4)
WCET monitoring
t
Start Job Deadline
monitoring
Deadline
w1 w2 w3
WCET < w1 + w2 + w3
WCET monitoring
Pharos – time protection (5)
◼ By ensuring that neither periodic nor sporadic
threads can execute for more time than they
are supposed to, the architect has the means
to mix different level criticality systems
◼ The architect still needs to make sure that the
system is schedulable, in particular to the
higher criticality partitions (would also need to
do this in ARINC case as well)
Pharos – time protection (6)
◼ An application could have:
❑ High priority non-critical periodic/sporadic threads
❑ And in the same CPU have
❑ Low priority highly-critical
periodic/sporadic/aperiodic threads
❑ And still guarantee that no matter what, the highly
critical threads will ALWAYS have time to execute
❑ Of course, supposing that the period/MIT and
WCET of the non-critical threads obeys some pre-
calculated criteria
Pharos – memory protection (1)
◼ Pharos supports the concept of partitions where
each partition is composed by a set of:
❑ Threads
❑ Semaphores
❑ Message queues
❑ Etc
◼ Each partition has its own memory area, defined at
compilation time
◼ Pharos ensures through the CPU MMU/MPU that a
partition cannot access memory areas where it is
not configured to do so
Pharos – memory protection (2)
◼ Each partition can:
❑ Access the code area to
execute the source code
❑ Access its own partition
memory area
❑ Access the shared data
area
❑ Optionally access other
memory areas (you can
configure the application
which memory areas
Code
Partition 1 data
Partition 2 data
Partition 3 data
Shared data area
Pharos Kernel data
initialized data
(data section)
zero-initialized data
(bss section)
non-initialized data
(new uss section)
0x00000000
Flash
}RAM
I/O
}SPI area
I2C area
Blueetooth area
CAN area
Ethernet area
}
Each partition has access to
its own data area and
optionally (configurable) to I/O
memory areas..
.
Pharos – memory protection (3)
◼ How to do the source code?
PARTITION_0_SECTION uint32_t variableInPartition0Data = 4;
PARTITION_0_SECTION_USS uint32_t variableInPartition0Uss;
PARTITION_0_SECTION_BSS uint32_t variableInPartition0Bss;
PARTITION_1_SECTION uint32_t variableInPartition1Data = 3;
SHARED_SECTION uint32_t variableInSharedSectionData = 432;
Intra-partition API
◼ Within each partition, threads use:
❑ Semaphores
◼ Mutex
◼ Ceiling semaphore
◼ Counting semaphore
❑ Light-weight Message Queues
◼ A extremely fast message queue that does a zero-copy transfer within the same partition
❑ Events
◼ 32 bit events sent to a thread to unblock it
❑ Timers
◼ Software timers that execute a handler at specified instants in time
❑ Critical sections
◼ Specified functions that are executed in user space with interrupts disabled (useful for drivers)
❑ Clock
❑ Health monitoring
◼ Discover when a deadline was missed, an execution time overrun, an invalid memory access
was performed, etc
❑ Interrupt management
◼ Configure interrupt handlers, interrupt priority, wake-up CPU, etc
❑ I/O memory area
◼ Configure which memory areas the partition has access to
Inter-partition
communication/synchronization
◼ Partition can communicate with each other trough:
❑ Heavy weight message queues
◼ A 2-copy message queue to transfer information from one partition to
another
❑ Resource
◼ A pre-defined function executes on the partition owner of the resource
protected by a ceiling semaphore ensuring mutual exclusion
❑ Channel queue
◼ A extremely fast message queue (zero-copy) to transfer information from
one partition to another using the MMU/MPU to give/remove permissions
from one partition to another
❑ Inter-partition calls
◼ You can call directly a function on another partition with a different stack,
on the memory context of the called partition but in the time context of
the calling thread
❑ I/O memory area / shared memory
◼ You can use a configurable memory area to shared memory between
partitions
Inter-partition protection (1)
◼ Imagine a low critical partition starts sending
messages to a high critical partition message queue
❑ This could cause the high critical partition to overload and
stop performing its task
◼ Pharos must protect this from occurring
Inter-partition protection (2)
◼ Pharos protects each inter-partition communication
device (e.g. Message queue, channel, IPC, etc) by
allowing the application to define a “filter” function
for it
◼ Before accessing the communication device, Pharos
will invoke the filter which will allow (or not) the
communication to take place
◼ The filter function is executed with a separate stack,
in the memory context of the called partition but still
in the time context of the caller thread
Precautions
◼ Some precautions are required when implementing
your application:
❑ Aperiodic threads
◼ Pharos cannot protect the execution time of these threads.
You have to make sure they don’t interfere in an unforeseen
way with the rest of the system (perhaps lower the priority of
these threads)
❑ Interrupt handlers & Timer handlers
◼ They are executed in the context of an interrupt and hence in
“kernel” mode. You have to define statically the handlers to be
executed
❑ Critical sections
◼ They are executed with interrupts disabled, so make them as
fast as possible to not damage the schedulability too much
CPUs supported
◼ Currently (version 1.3.0) Pharos supports:
❑ ARM 926EJ-S (in Qemu)
❑ ARM Cortex-R5 (in
http://www.ti.com/tool/LAUNCHXL2-570LC43)
❑ ARM Cortex-M4 (in http://www.ti.com/tool/EK-
TM4C129EXL)
◼ Next version (1.4.0) will (hopefully) be using
❑ ARM Cortex-A53
Future plans
◼ We don’t have a pre-defined rigid roadmap
◼ We have some ideas where we want to take
Pharos to, but no guarantees we can take it
there
◼ At this moment, Pharos is maintained solely
as a hobby by a couple of enthusiastic
software developers
◼ If you have inputs/ideas/whatever we would
love to know/discuss them with you
What else?
◼ Check the User Manual for a complete description of
the features offered by Pharos
◼ Many things were not discussed here. Examples:
❑ How to configure interrupts? (spoiler: each CPU has its
own configuration method to maximize the options
available on the CPU)
❑ How to configure partition memory areas? (spoiler: based
on the MMU/MPU or with direct access)
❑ How to create drivers? (spoiler: drivers are normal
partitions where you define the I/O memory areas needed,
critical sections and interrupt handlers)
More information
◼ Checkout the site:
❑ https://sourceforge.net/projects/rtospharos/
◼ It has a:
❑ User Manual (check in files)
❑ Wiki (some initial steps when learning Pharos)
❑ Discussion (make your questions here)
❑ Ticket system
❑ SVN source code
◼ Or you can address us directly through
❑ rtos.pharos@outlook.com

More Related Content

What's hot

Windows process-scheduling
Windows process-schedulingWindows process-scheduling
Windows process-schedulingTalha Shaikh
 
Windows process scheduling presentation
Windows process scheduling presentationWindows process scheduling presentation
Windows process scheduling presentationTalha Shaikh
 
CPU scheduling ppt file
CPU scheduling ppt fileCPU scheduling ppt file
CPU scheduling ppt fileDwight Sabio
 
OS Process and Thread Concepts
OS Process and Thread ConceptsOS Process and Thread Concepts
OS Process and Thread Conceptssgpraju
 
CPU scheduling algorithms in OS
CPU scheduling algorithms in OSCPU scheduling algorithms in OS
CPU scheduling algorithms in OSharini0810
 
6 cpu scheduling
6 cpu scheduling6 cpu scheduling
6 cpu schedulingBaliThorat1
 
Process scheduling : operating system ( Btech cse )
Process scheduling : operating system ( Btech cse )Process scheduling : operating system ( Btech cse )
Process scheduling : operating system ( Btech cse )HimanshuSharma1389
 
5 process synchronization
5 process synchronization5 process synchronization
5 process synchronizationBaliThorat1
 
CPU Scheduling Algorithms
CPU Scheduling AlgorithmsCPU Scheduling Algorithms
CPU Scheduling AlgorithmsTayba Farooqui
 
Operating Systems 1 (8/12) - Concurrency
Operating Systems 1 (8/12) - ConcurrencyOperating Systems 1 (8/12) - Concurrency
Operating Systems 1 (8/12) - ConcurrencyPeter Tröger
 
File system and Deadlocks
File system and DeadlocksFile system and Deadlocks
File system and DeadlocksRohit Jain
 
Supporting Time-Sensitive Applications on a Commodity OS
Supporting Time-Sensitive Applications on a Commodity OSSupporting Time-Sensitive Applications on a Commodity OS
Supporting Time-Sensitive Applications on a Commodity OSNamHyuk Ahn
 
Ways to reduce misses
Ways to reduce missesWays to reduce misses
Ways to reduce missesnellins
 
cpu scheduling by shivam singh
cpu scheduling by shivam singhcpu scheduling by shivam singh
cpu scheduling by shivam singhshivam71291
 

What's hot (20)

Windows process-scheduling
Windows process-schedulingWindows process-scheduling
Windows process-scheduling
 
Windows process scheduling presentation
Windows process scheduling presentationWindows process scheduling presentation
Windows process scheduling presentation
 
CPU scheduling ppt file
CPU scheduling ppt fileCPU scheduling ppt file
CPU scheduling ppt file
 
Chapter6
Chapter6Chapter6
Chapter6
 
OS Process and Thread Concepts
OS Process and Thread ConceptsOS Process and Thread Concepts
OS Process and Thread Concepts
 
CPU scheduling algorithms in OS
CPU scheduling algorithms in OSCPU scheduling algorithms in OS
CPU scheduling algorithms in OS
 
6 cpu scheduling
6 cpu scheduling6 cpu scheduling
6 cpu scheduling
 
Process scheduling : operating system ( Btech cse )
Process scheduling : operating system ( Btech cse )Process scheduling : operating system ( Btech cse )
Process scheduling : operating system ( Btech cse )
 
Real time systems 1 and 2
Real time systems 1 and 2Real time systems 1 and 2
Real time systems 1 and 2
 
5 process synchronization
5 process synchronization5 process synchronization
5 process synchronization
 
CPU Scheduling Algorithms
CPU Scheduling AlgorithmsCPU Scheduling Algorithms
CPU Scheduling Algorithms
 
The Windows Scheduler
The Windows SchedulerThe Windows Scheduler
The Windows Scheduler
 
Operating Systems 1 (8/12) - Concurrency
Operating Systems 1 (8/12) - ConcurrencyOperating Systems 1 (8/12) - Concurrency
Operating Systems 1 (8/12) - Concurrency
 
Rtos part2
Rtos part2Rtos part2
Rtos part2
 
Realtime
RealtimeRealtime
Realtime
 
4 threads
4 threads4 threads
4 threads
 
File system and Deadlocks
File system and DeadlocksFile system and Deadlocks
File system and Deadlocks
 
Supporting Time-Sensitive Applications on a Commodity OS
Supporting Time-Sensitive Applications on a Commodity OSSupporting Time-Sensitive Applications on a Commodity OS
Supporting Time-Sensitive Applications on a Commodity OS
 
Ways to reduce misses
Ways to reduce missesWays to reduce misses
Ways to reduce misses
 
cpu scheduling by shivam singh
cpu scheduling by shivam singhcpu scheduling by shivam singh
cpu scheduling by shivam singh
 

Similar to Pharos

Similar to Pharos (20)

Real time operating systems
Real time operating systemsReal time operating systems
Real time operating systems
 
FreeRTOS basics (Real time Operating System)
FreeRTOS basics (Real time Operating System)FreeRTOS basics (Real time Operating System)
FreeRTOS basics (Real time Operating System)
 
RTOS
RTOSRTOS
RTOS
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
 
Real time operating system
Real time operating systemReal time operating system
Real time operating system
 
types_of_operating_systems_sk_akram.pptx
types_of_operating_systems_sk_akram.pptxtypes_of_operating_systems_sk_akram.pptx
types_of_operating_systems_sk_akram.pptx
 
Rt kernel-prn
Rt kernel-prnRt kernel-prn
Rt kernel-prn
 
Rtos Concepts
Rtos ConceptsRtos Concepts
Rtos Concepts
 
Lec 9-os-review
Lec 9-os-reviewLec 9-os-review
Lec 9-os-review
 
Introduction to Real Time Java
Introduction to Real Time JavaIntroduction to Real Time Java
Introduction to Real Time Java
 
Real-Time Systems Intro.pptx
Real-Time Systems Intro.pptxReal-Time Systems Intro.pptx
Real-Time Systems Intro.pptx
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
Amazon builder Library notes
Amazon builder Library notesAmazon builder Library notes
Amazon builder Library notes
 
Rtos ss
Rtos ssRtos ss
Rtos ss
 
Rtos by shibu
Rtos by shibuRtos by shibu
Rtos by shibu
 
rtosbyshibu-131026100746-phpapp01.pdf
rtosbyshibu-131026100746-phpapp01.pdfrtosbyshibu-131026100746-phpapp01.pdf
rtosbyshibu-131026100746-phpapp01.pdf
 
cpu scheduling.pdf
cpu scheduling.pdfcpu scheduling.pdf
cpu scheduling.pdf
 
CS6401 Operating Systems
CS6401 Operating SystemsCS6401 Operating Systems
CS6401 Operating Systems
 
Lab3F22.pdf
Lab3F22.pdfLab3F22.pdf
Lab3F22.pdf
 
Let’s Fix Logging Once and for All
Let’s Fix Logging Once and for AllLet’s Fix Logging Once and for All
Let’s Fix Logging Once and for All
 

Recently uploaded

Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 

Recently uploaded (20)

Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 

Pharos

  • 1. Pharos Real-Time Operating System for Critical Systems Introduction
  • 2. Summary ◼ Real-time systems & motivation ◼ Pharos ❑ Time Protection ❑ Memory Protection ❑ Intra-partition communication/synchronization ❑ Inter-partition communication/synchronization ❑ CPUs supported ◼ Future plans
  • 3. Real-time systems criticality ◼ Real-time systems can be classified according to their criticality. Some examples: ❑ Highly critical ◼ Attitude control on an airplane ❑ Medium critical ◼ Emergency light ❑ Low critical ◼ Infotainment on an automobile ❑ Non critical ◼ Web-site
  • 4. Real-time systems criticality ◼ The exact level of criticality is defined according to the standard followed. ◼ For example: ❑ Aviation: DO178C classifies from DAL-A (highest criticality) to DAL-E (lowest criticality)
  • 5. Critical and non-critical systems ◼ Both critical and non-critical can sometimes co-exist on the same system ◼ Usually placed on different CPUs/Boards ◼ Highly critical systems are typically well- behaved and “simple” (~10K LOCs) ◼ Non-critical systems are typically a “mess” and complex (>1M LOCs) ◼ They sometimes share the same resources
  • 6. RTOS vs OS ◼ Low critical systems use extensively an Operating System (e.g. Linux, Windows) ◼ Highly critical systems many times also use a a Real-Time Operating System (RTOS) which has some special conditions
  • 7. RTOS Main features ◼ There are many different definitions of what a RTOS is supposed to do ◼ “Main” features are: ❑ Fixed-priority preemptive scheduler ◼ CPU is running always the highest priority ready thread ❑ Fast critical sections ◼ interrupts disabled for “short” amount of time) ❑ Deterministic ◼ each call takes a known maximum amount of time (e.g. semaphore obtain)
  • 8. RTOS Other features ◼ “Secondary” features ❑ Health monitoring ◼ Check if deadlines were missed and allow the application to deal with them ❑ “Good” API ◼ Semaphores with priority inheritance/ceiling algorithms ◼ Message queues ◼ Events ◼ Interrupt processing ❑ Support a wide variety of CPUs
  • 9. RTOS Partitioning ◼ Even other features are useful, such as dividing the application into partitions ◼ Partitioning features ❑ Memory protection ◼ Don’t allow a part of the application (e.g. driver for CAN) mess with the memory area of another part of the application (e.g. TCP/IP stack) or the RTOS kernel itself ❑ Time protection ◼ Each partition or thread could have an amount of time to execute in, no matter what the rest of the systems does ❑ Inter-partition communication/synchronization ◼ Allow a partitions to communicate with each other ◼ If not bounded, an erroneous partition could overload another partition with unwanted communication
  • 10. RTOS Scheduling ◼ Objective ❑ Give equation to make sure all deadlines are met Examples: ◼ RMS (CPU% < 70%) ◼ EDF (CPU% < 100%) ◼ Response time analysis (Ra < Da) ◼ Equation depends (heavily) on the scheduler used ◼ Examples ❑ Rate monotonic scheduler ❑ Earliest Deadline First ❑ Fixed priority ❑ Preemptive vs non-preemptive
  • 11. Threads ◼ Threads are typically classified as: ❑ Periodic ◼ Period (Ti) ◼ Deadline (Di) ◼ Job worst case execution time (ci) ◼ First release instant (ri) ❑ Sporadic ◼ Minimum Inter-arrival Time (MITi) ◼ Deadline (Di) ◼ Job worst case execution time (ci) ❑ Aperiodic
  • 12. Periodic thread t Deadine Deadline Period Deadline Start Job Deadine Thread executing in several instances of time (depending on when other threads are executing) Second time the thread is executing. This time the thread is faster (maybe some calculations are done faster) t
  • 13. Sporadic thread t 1st job start 1st Deadline 2nd job Start MIT Activate sporadic thread (before MIT has elapsed) MIT 3rd job Start MIT Activations of the sporadic thread (e.g. Interrupt occurred and relased a semaphore) 2nd Deadline MIT from 1st job already elapsed, so the thread is activated right away (and the deadline as well) Have to wait for the MIT from the 2nd job to elapse before activating the thread
  • 14. Aperiodic thread ◼ Aperiodic threads can execute whatever they like, there is no definition for maximum execution time, period, whatever ◼ For this reason they are normally not considered in real-time systems
  • 15. Thread Priority ◼ Fixed ❑ Priority does not change with time (with perhaps some exceptions, like the semaphore ceiling) ❑ Easier to implement ❑ “Easy” for programmer to define the priority ◼ Dynamic ❑ priority changes with time ❑ Harder to implement ❑ How to define the priority? Based on deadline, laxity, etc ◼ If deadline, not all threads can have a deadline (for example, aperiodic threads by definition don’t have a deadline)
  • 16. Preemptiveness ◼ Preemptive ❑ If a higher priority thread becomes ready, the RTOS switches the CPU to that thread => the highest priority ready thread is always executing ❑ Mutual exclusion must be ensured by the programmer ◼ Non-preemptive ❑ The thread must explicitly relinquish the CPU to change to another thread => the highest priority read thread may not be always executing ❑ Mutual exclusion does not need to be programmed using semaphores
  • 17. Rate Monotonic Scheduler – RMS ◼ One of many possible algorithms for fixed-priority ◼ The RMS only defines the priority of the threads based on their period: the lower the period, the higher the priority ❑ Therefore the original version of RMS only considers periodic threads ❑ Extensions were made for sporadic threads, where the period is replaced by the MIT ◼ In an application with only periodic threads, is the optimum scheduler ❑ in the sense that if it there is any algorithm to define the priorities with all threads being schedulable, then the RMS will also give a schedulable set of threads ◼ Simplified schedulability equation (with preemption) ❑ %CPU < 69%
  • 18. Fixed priority schedulers ◼ Repeat: the RMS only defines the priority of the threads based on their period ◼ You can define the priority of yours threads as you wish, but the RMS schedulability equation will NOT be applicable ◼ Instead you could use the Response-Time Analysis (RTA) schedulability equations
  • 19. Response-Time Analysis – RTA ◼ Calculate the Response Time (Ri) of each thread and see if it is lower than the Deadline (Di): ◼ Use iterations to solve the equation:
  • 20. Earliest Deadline First – EDF ◼ All threads need to have a deadline ◼ The thread with the nearest deadline will be using the CPU ◼ How to define a deadline for threads that typical don’t have one? Examples: video, TCP/IP comm ◼ Schedulability equation is easy (with preemption): ❑ %CPU < 100%
  • 21. RTOS Scheduler – EDF vs RMS ◼ Myth: EDF is “better” than Rate Monotonic (RMS) ❑ The origin for this myth is that the most used schedulability equation for the EDF and RMS ❑ EDF: CPU% < 100% ❑ RMS: CPU% < 70% ❑ But there are other schedulability analysis that can (or not, depending on the system) allow the CPU% to increase to 100% using the RMS
  • 22. Real time systems – summary ◼ Now we have a good understanding of real- time systems ❑ Criticality ❑ Schedulability ❑ Types of threads (periodic/sporadic/aperiodic)
  • 23. Real-time systems mixing criticality – ARINC 653 ◼ In some systems it is possible to mix critical and non-critical systems in the same CPU. ◼ Example: ❑ ARINC 653 ◼ In ARINC 653, each partition has a pre- defined time slot and its threads can only execute on that slot
  • 25. ARINC 653 questions ◼ Some questions arise with this fixed partition scheduling: ❑ Q: How to respond to an external event quickly? ❑ A: Polling ❑ Q: Doesn’t that waste a lot of time? ❑ A: Yes, it does ❑ Q: What happens if a partition does not have anything to do, that is, it is idle? ❑ A: Its time slot is wasted
  • 26. Pharos ◼ Pharos is a RTOS that tries to solve these questions while maintaining the very good mixed-criticality feature of ARINC 653 ◼ But how to ensure time protection and still give a good responsive system (and not waste time doing idle tasks)?
  • 27. Pharos – time protection (1) ◼ Pharos supports natively the three types of threads: ❑ Periodic ❑ Sporadic ❑ Aperiodic
  • 28. Pharos – time protection (2) ◼ Pharos allows the application to configure periodic threads with: ❑ Period ❑ Worst case execution time (WCET) ❑ Release instant ❑ Deadline ◼ If a periodic thread attempts to use more execution time than the configured WCET, Pharos will stop it and raise an error to the application ◼ This ensures that periodic threads CANNOT execute longer than they are supposed to
  • 29. Pharos – time protection (3) ◼ Pharos allows the application to configure sporadic threads with: ❑ MIT ❑ Worst case execution time (WCET) ❑ Deadline ◼ If a sporadic thread attempts to use more execution time than the configured WCET, Pharos will stop it and raise an error to the application ◼ This ensures that sporadic threads CANNOT execute longer than they are supposed to
  • 30. Pharos – time protection (4) WCET monitoring t Start Job Deadline monitoring Deadline w1 w2 w3 WCET < w1 + w2 + w3 WCET monitoring
  • 31. Pharos – time protection (5) ◼ By ensuring that neither periodic nor sporadic threads can execute for more time than they are supposed to, the architect has the means to mix different level criticality systems ◼ The architect still needs to make sure that the system is schedulable, in particular to the higher criticality partitions (would also need to do this in ARINC case as well)
  • 32. Pharos – time protection (6) ◼ An application could have: ❑ High priority non-critical periodic/sporadic threads ❑ And in the same CPU have ❑ Low priority highly-critical periodic/sporadic/aperiodic threads ❑ And still guarantee that no matter what, the highly critical threads will ALWAYS have time to execute ❑ Of course, supposing that the period/MIT and WCET of the non-critical threads obeys some pre- calculated criteria
  • 33. Pharos – memory protection (1) ◼ Pharos supports the concept of partitions where each partition is composed by a set of: ❑ Threads ❑ Semaphores ❑ Message queues ❑ Etc ◼ Each partition has its own memory area, defined at compilation time ◼ Pharos ensures through the CPU MMU/MPU that a partition cannot access memory areas where it is not configured to do so
  • 34. Pharos – memory protection (2) ◼ Each partition can: ❑ Access the code area to execute the source code ❑ Access its own partition memory area ❑ Access the shared data area ❑ Optionally access other memory areas (you can configure the application which memory areas Code Partition 1 data Partition 2 data Partition 3 data Shared data area Pharos Kernel data initialized data (data section) zero-initialized data (bss section) non-initialized data (new uss section) 0x00000000 Flash }RAM I/O }SPI area I2C area Blueetooth area CAN area Ethernet area } Each partition has access to its own data area and optionally (configurable) to I/O memory areas.. .
  • 35. Pharos – memory protection (3) ◼ How to do the source code? PARTITION_0_SECTION uint32_t variableInPartition0Data = 4; PARTITION_0_SECTION_USS uint32_t variableInPartition0Uss; PARTITION_0_SECTION_BSS uint32_t variableInPartition0Bss; PARTITION_1_SECTION uint32_t variableInPartition1Data = 3; SHARED_SECTION uint32_t variableInSharedSectionData = 432;
  • 36. Intra-partition API ◼ Within each partition, threads use: ❑ Semaphores ◼ Mutex ◼ Ceiling semaphore ◼ Counting semaphore ❑ Light-weight Message Queues ◼ A extremely fast message queue that does a zero-copy transfer within the same partition ❑ Events ◼ 32 bit events sent to a thread to unblock it ❑ Timers ◼ Software timers that execute a handler at specified instants in time ❑ Critical sections ◼ Specified functions that are executed in user space with interrupts disabled (useful for drivers) ❑ Clock ❑ Health monitoring ◼ Discover when a deadline was missed, an execution time overrun, an invalid memory access was performed, etc ❑ Interrupt management ◼ Configure interrupt handlers, interrupt priority, wake-up CPU, etc ❑ I/O memory area ◼ Configure which memory areas the partition has access to
  • 37. Inter-partition communication/synchronization ◼ Partition can communicate with each other trough: ❑ Heavy weight message queues ◼ A 2-copy message queue to transfer information from one partition to another ❑ Resource ◼ A pre-defined function executes on the partition owner of the resource protected by a ceiling semaphore ensuring mutual exclusion ❑ Channel queue ◼ A extremely fast message queue (zero-copy) to transfer information from one partition to another using the MMU/MPU to give/remove permissions from one partition to another ❑ Inter-partition calls ◼ You can call directly a function on another partition with a different stack, on the memory context of the called partition but in the time context of the calling thread ❑ I/O memory area / shared memory ◼ You can use a configurable memory area to shared memory between partitions
  • 38. Inter-partition protection (1) ◼ Imagine a low critical partition starts sending messages to a high critical partition message queue ❑ This could cause the high critical partition to overload and stop performing its task ◼ Pharos must protect this from occurring
  • 39. Inter-partition protection (2) ◼ Pharos protects each inter-partition communication device (e.g. Message queue, channel, IPC, etc) by allowing the application to define a “filter” function for it ◼ Before accessing the communication device, Pharos will invoke the filter which will allow (or not) the communication to take place ◼ The filter function is executed with a separate stack, in the memory context of the called partition but still in the time context of the caller thread
  • 40. Precautions ◼ Some precautions are required when implementing your application: ❑ Aperiodic threads ◼ Pharos cannot protect the execution time of these threads. You have to make sure they don’t interfere in an unforeseen way with the rest of the system (perhaps lower the priority of these threads) ❑ Interrupt handlers & Timer handlers ◼ They are executed in the context of an interrupt and hence in “kernel” mode. You have to define statically the handlers to be executed ❑ Critical sections ◼ They are executed with interrupts disabled, so make them as fast as possible to not damage the schedulability too much
  • 41. CPUs supported ◼ Currently (version 1.3.0) Pharos supports: ❑ ARM 926EJ-S (in Qemu) ❑ ARM Cortex-R5 (in http://www.ti.com/tool/LAUNCHXL2-570LC43) ❑ ARM Cortex-M4 (in http://www.ti.com/tool/EK- TM4C129EXL) ◼ Next version (1.4.0) will (hopefully) be using ❑ ARM Cortex-A53
  • 42. Future plans ◼ We don’t have a pre-defined rigid roadmap ◼ We have some ideas where we want to take Pharos to, but no guarantees we can take it there ◼ At this moment, Pharos is maintained solely as a hobby by a couple of enthusiastic software developers ◼ If you have inputs/ideas/whatever we would love to know/discuss them with you
  • 43. What else? ◼ Check the User Manual for a complete description of the features offered by Pharos ◼ Many things were not discussed here. Examples: ❑ How to configure interrupts? (spoiler: each CPU has its own configuration method to maximize the options available on the CPU) ❑ How to configure partition memory areas? (spoiler: based on the MMU/MPU or with direct access) ❑ How to create drivers? (spoiler: drivers are normal partitions where you define the I/O memory areas needed, critical sections and interrupt handlers)
  • 44. More information ◼ Checkout the site: ❑ https://sourceforge.net/projects/rtospharos/ ◼ It has a: ❑ User Manual (check in files) ❑ Wiki (some initial steps when learning Pharos) ❑ Discussion (make your questions here) ❑ Ticket system ❑ SVN source code ◼ Or you can address us directly through ❑ rtos.pharos@outlook.com