SlideShare una empresa de Scribd logo
1 de 41
Real Time Systems



© 2010 Anil Kumar Pugalia <email@sarika-pugs.com>
               All Rights Reserved.
What to Expect?
W's of Real Time & RTOS?
Design Methodologies of RTOS
Linux → Real Time Linux
  Various Latencies & Schedulers
  The “Real Time Patch” Path
  Real Time Applications
  Real Time Kernel Debugging
Peek into a Co-Kernel
         © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   2
                        All Rights Reserved.
Real Time Definition
Correctness depends on
 Functional Accuracy, and
 Timings of the Result produced
Examples
 MPEG Decoder in your DVD player
 Call Response in your Mobile Phone




        © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   3
                       All Rights Reserved.
Real Time Types
Hard Real Time
  Guaranteed to meet the response reqs
  Examples: Defense Systems, Vehicle Control Systems,
  Satellite Systems
Soft Real Time
  Once in a while may not meet the response reqs
  Examples: Multimedia Devices, VoIP, CE devices
An intermediate one: Firm Real Time
Check: What is our Desktop?


           © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   4
                          All Rights Reserved.
Is Real Time needed?
Deadline of Applications
  Reduces Quality or Unacceptable
External Device Interactions with Apps
  Handling of Messages – Time-bound or not
Application Task Priority
  Could it be needed higher than OS services
Expressing delays & timeouts
  Is it needed to be fine-grained, say in usecs
         © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   5
                        All Rights Reserved.
Real Time OS
RTOS Phylum
  Non Real-time
  Soft Real-time
  Hard Real-time

Conflicting Requirements
  Real Time vs Rich Features of GPOS


         © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   6
                        All Rights Reserved.
Expected Features of an RTOS
RTOS Requirements
  Strictly Enforced Task Priorities
  Fine-grained Preemption
  External Event Handling in Bounded time frame
Which entails
  Predictable Low Interrupt Latency
  Predictable Low Scheduler Latency
  Priority Inheritance
But wanted with Rich Features of
  Multi Tasking / Processing
  Interprocess Communication & Synchronization
             © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   7
                            All Rights Reserved.
RTOS Design Methodologies
Expand an RTOS
Make a GPOS Real Time capable
 Linux → Real Time Linux (Separate Session)
The Co-Kernel Approach
 RT Apps in User Space
   Open Source Xenomai (Separate Session)
   Open Source RTAI
 RT Apps in Kernel Space
   RTLinux from Windriver
        © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   8
                       All Rights Reserved.
Expand an RTOS
Difficult to ensure Determinism
  As all core capabilities must be fully preemptive

Drivers for Hardware becomes very complex

Existing Software cannot be used without changes

High Maintenance Costs for Developers and Customers

So, let's understand the other one w.r.t. Linux




               © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   9
                              All Rights Reserved.
Linux → Real Time Linux




© 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   10
               All Rights Reserved.
Why Linux is non Real Time?
High Interrupt Latency
High Scheduler Latency
OS services with indeterministic timing behaviour
  IPC, Memory Allocation, ...
Linux is in general undeterministic in its response
  Virtual Memory, System Calls, …
Later two are more of a better Coding Principles
However, the first two are major Design Changes
Let's take a closer look




               © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   11
                              All Rights Reserved.
Real Time related Concepts
Latency
  Interrupt
  Scheduling
Both are related to
  Preemption
  And Critical Sections




          © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   12
                         All Rights Reserved.
Latency Visualization

Interrupt      ISR Runs         ISR Signals      RT Process
Event                           RT Process       Runs




                                Time
   t0               t1                 t2                t3

        Interrupt        Interrupt          Scheduling
        Latency          Scheduling         Latency



               Interrupt to Process Latency

            © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   13
                           All Rights Reserved.
Latency Details
Why Interrupt Latency?
Attributes of ISR
Real Time Process
  Typically, high priority
  Otherwise, anyway it is a problem
All 3 could potentially pose problems
  For Hard Real Time


         © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   14
                        All Rights Reserved.
Possible Solutions
Key Requirement
  Schedule RT Process, within a given time
Possible Helpers
  Remove / Reduce interrupt-disabled code
  (critical sections)
  Write ISRs really really minimal in execution
  time
  Real Time Apps with the highest priority
    May be higher than interrupts, softirqs, etc

         © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   15
                        All Rights Reserved.
Preemption Visualization

                        Time

                                                        User Space




                                                        System Call
                                                        Interface




                                                        Kernel Space
  Process A
  Process B


    © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>                  16
                   All Rights Reserved.
Preemption Details
Higher Preemption makes it more Real
Time feasible
Higher Priority (RT Tasks) could be
scheduled in a more predictable time
Sources of Preemption Latency
  Critical Section Processing
  Interrupt Context Processing



         © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   17
                        All Rights Reserved.
Preemption & Critical Sections
Higher Preemption at the cost of reducing Critical Sections
  Isolate & Minimize the critical sections
  Protect them by disabling preemption
    spin_lock / spin_unlock; preempt_disable / preempt_enable
Preemption Models for reducing Critical Sections
  Preempt only safe locations
    Entry & Exit of system calls, Return from interrupt processing, …
    Put explicit “allow preempt” code at these places
    Overall not an excellent approach
  Preempt everywhere except only the Critical Sections
    lock-breaking mechanism
    Getting achieved by instrumenting kernel for latency measurements
    And by fixing the longest latency code paths


                © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>       18
                               All Rights Reserved.
SMP World & Critical Sections
Uniprocessor case needs Protection from
  Interrupt Processing
  Exception Processing
Multiprocessor with additional
  Multiple Kernel Threads
Posed a bigger need than Real Time for
reduced Critical Sections
Real Time has gained benefits from SMP
development, as well
         © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   19
                        All Rights Reserved.
Real Time Kernel Patch
Critical Section Control is a major step
We have achieved good Soft Real Time Performance
  Since 2.6.12, in single-digit milliseconds
  On reasonably fast x86 processor
But without solving the Interrupt Latency
  Hard Real Time is not possible
Recent Developments have majorly focused on this aspect
A major Real Time Kernel Patch evolved
  Maintained by Ingo Molnar
  Available @ http://people.redhat.com/~mingo/realtime-preempt
  Could be downloaded using say, ketchup -G 2.6.22.1-rt9
  And takes care of many more issues
              © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   20
                             All Rights Reserved.
W's & How's of RT Kernel Patch?
 Lot's of Questions
   What all does it contain?
   How to configure it?
   What should be used & when?
   And many more
 Before answering these, let's understand
   Schedulers in main-stream Kernel
   Preemption Support in main-stream Kernel

          © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   21
                         All Rights Reserved.
Linux Schedulers
Provides multi-tasking capabilities by
  Time Slicing
  Preemption
  Based on various task priorities
  Specified by its scheduling policies
Understands the following execution instances
  Kernel Thread
  User Process
  User Thread
Linux Basic Scheduling
  Normal (SCHED_OTHER) – Fairness Scheduling
Other Advanced Scheduling supported
  Round Robin (SCHED_RR)
  FIFO (SCHED_FIFO)
All Schedulers are O(1)
                   © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   22
                                  All Rights Reserved.
Linux Kernel Preemption Levels
None (PREEMPT_NONE)
 No forced preemption
 Overall throughput, on average, is good
Voluntary (PREEMPT_VOLUNTARY)
 First stage of latency reduction
 Explicit preemption points are placed at strategic locations
Standard (PREEMPT_DESKTOP)
 Preemption enabled everywhere except within critical sections
 Good for soft real-time applications, like audio, multimedia, …
Kernel Parameter: preempt



             © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>     23
                            All Rights Reserved.
Preemption Level from RT Patch
 Complete (PREEMPT_RT)
  Spin locks replaced with preembtable
  mutexes
  Preemption enabled everywhere except
  where protected by preempt_disable()
  Smoothes out variation in latency
  Allows a low & predictable latency for time-
  critical real-time applications


         © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   24
                        All Rights Reserved.
Additional Real Time Features
ISRs as Kernel Tasks
  CONFIG_PREEMPT_HARDIRQ
  Schedulable & Preemptible
  Priority Assignment as Required
  Control Window: /proc/sys/kernel/hardirq_preemption
  Kernel Parameter: hardirq-preempt
Preemptable Softirqs
  CONFIG_PREEMPT_SOFTIRQ
  All ran in the context of ksoftirqd → Now as individual threads
  A proper Linux task configured for real time
  Control Window: /proc/sys/kernel/softirq_preemption
  Kernel Parameter: softirq-preempt
Certain Read-Copy-Update (RCU) sections preemptible
  CONFIG_PREEMPT_RCU
  RCU is synchronization primitive for frequently read data

                  © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   25
                                 All Rights Reserved.
Creating a Real Time Process
#include <sched.h>
#define MY_RT_PRIO 1
int main(...) {
    int old_policy;
    struct sched_param params = { .sched_priority = MY_RT_PRIO };
    ...
    old_policy = sched_getscheduler(0);
    if (sched_setscheduler(0, SCHED_RR, &params) == -1)
          handle_error();
    …
}
                      © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   26
                                     All Rights Reserved.
RT Application: Do's & Don'ts
Have very few Real Time Processes
Keep the RT Applications Short & Efficient
Do not do heavy duty operations
  Like Memory Allocation, etc
  If essential, move to Initialization Sections
Check for the working of the needed OS
services
  Especially, if any RT Application has priority higher
  than that OS Service
Test for the Desired Results
           © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   27
                          All Rights Reserved.
Debugging Real Time Kernel
Soft Lockup
  CONFIG_DETECT_SOFTLOCKUP
Unsafe Preemption Use Logging
  CONFIG_DEBUG_PREEMPT
Deadlock Conditions Detection & Reporting
  CONFIG_DEBUG_DEADLOCK
  Deadlocks due to semaphores & spinlocks
Runtime Control of Locking Mode
  CONFIG_DEBUG_RT_LOCKING_MODE
  Mutex back to Spinlock
          © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   28
                         All Rights Reserved.
Tracing Real Time Kernel
Latency Tracing
  CONFIG_LATENCY_TRACE
  For data associated with last maximum preemption
  latency
  Kernel Window: /proc/latency_trace
Function Call Tracing
  Inserts hooks to every function via gcc
  Gives function level details through
  Kernel Window: /proc/latency_trace
Soon getting outdated by Ftrace
          © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   29
                         All Rights Reserved.
Further Tracing RT Kernel
High Priority Process Wakeup
  CONFIG_WAKEUP_TIMING
    CONFIG_WAKEUP_LATENCY_HIST
Or, Interrupt Off Timing
  CONFIG_CRITICAL_IRQSOFF_TIMING
    CONFIG_INTERRUPT_OFF_HIST
Kernel Windows
  /proc/sys/kernel/preempt_max_latency
  /proc/latency_hist/interrupt_off_latency/CPU0 (0-10000us)
Time spent with Preemption disabled (in critical sections)
  CONFIG_CRITICAL_PREEMPT_TIMING
    CONFIG_PREEMPT_OFF_HIST
             © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   30
                            All Rights Reserved.
Real Time Linux
                  Myths & Realities
With all these understood
  Is Linux really Hard Real Time?
  Can it be used in all Real Time Embedded activities?
  Can it be used in a Nuclear Reactor?
Answers
  Can be used in most Real Time Embedded Applications, such as Robotics
  But cannot be “one-size-fits-it-all” approach to Real Time
  Is still a patch and hence not that extensibly tested
  Not all Device Drivers have yet been verified as Real Time safe
    More & more users (such as multimedia users), using the patch would verify more
    drivers, as they are the users noticing longer latency delays caused by these devices
  But even if they are, it is after all a GPOS
    Harder to verify a lack of bugs
    Could have potential bugs (from real time perspective)



                   © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>                        31
                                  All Rights Reserved.
Co-Kernel Approach




© 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   32
               All Rights Reserved.
W's of Co-Kernel Approach
Do not convert the GPOS into an RTOS
Place a small Real Time Kernel besides it
  On the same Hardware
This would be the Co-Kernel
  Taking care of all Real Time needs
Non-RT tasks are done by the GPOS
So,

         © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   33
                        All Rights Reserved.
What is a Co-Kernel?



   Co-Kernel is a Subsystem

Integrated with the main Kernel

 Handling the Real Time part



    © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   34
                   All Rights Reserved.
Types of Co-Kernel Approaches
Two Prevalent Approaches
  Support running of RT Apps in User Space
  RT Apps to be embodied into Kernel Space
Our Focus of Discussion is the First One
  With Xenomai in consideration




        © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   35
                       All Rights Reserved.
Benefits of Xenomai
Co-Kernel or Core running under Kernel, licensed under GPL 2
Kernel Support
  Both 2.4 & 2.6 for with & without MMU systems
Provides generic building blocks to implement RT APIs (skins)
RT API Support for
  VxWorks, pSOS+, VRTX, uITRON, POSIX 1003.1b
User Space i/f libraries: LGPL 2.1
Architecture Support
  PowerPC*, Blackfin, ARM, x86*
Excellent Resources
  Documentation, Technical Articles, …
Website: http://www.xenomai.org
              © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   36
                             All Rights Reserved.
Xenomai Architecture
   User Space       User Space        User Space     User Space
   Application      Application       Application    Application




                  Linux syscall interface

VxWorks          pSOS        VRTX            POSIX
                                                             ...      Kernel-based
  Skin           Skin        Skin             Skin                    Applications




                   Abstract RTOS Core


                         SAL / HAL
                                                                   Portability
                                                                   Layers
                             I-Pipe


          © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>                          37
                         All Rights Reserved.
Xenomai Components
Interrupt Pipeline
Hardware & System Abstraction Layers
Xenomai Core & Nucleus
Xenomai Skins




        © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   38
                       All Rights Reserved.
How Xenomai Works?
Real Time Shadow
New Sets of System Calls
Sharing Kernel Features
  By Domain Migration
Real Time Driver Model Mediation




        © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   39
                       All Rights Reserved.
What all have we learnt?
W's of Real Time & RTOS?
Design Methodologies of RTOS
Linux → Real Time Linux
  Various Latencies & Schedulers
  The “Real Time Patch” Path
  Real Time Applications
  Real Time Kernel Debugging
Peek into a Co-Kernel
         © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   40
                        All Rights Reserved.
Any Queries?




© 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   41
               All Rights Reserved.

Más contenido relacionado

La actualidad más candente

Design of embedded systems
Design of embedded systemsDesign of embedded systems
Design of embedded systemsPradeep Kumar TS
 
HCI - Chapter 2
HCI - Chapter 2HCI - Chapter 2
HCI - Chapter 2Alan Dix
 
Real-Time Embedded System Design
Real-Time Embedded System DesignReal-Time Embedded System Design
Real-Time Embedded System DesignJuliaAndrews11
 
Real Time Systems &amp; RTOS
Real Time Systems &amp; RTOSReal Time Systems &amp; RTOS
Real Time Systems &amp; RTOSVishwa Mohan
 
HCI 3e - Ch 5: Interaction design basics
HCI 3e - Ch 5:  Interaction design basicsHCI 3e - Ch 5:  Interaction design basics
HCI 3e - Ch 5: Interaction design basicsAlan Dix
 
Real Time Systems
Real Time SystemsReal Time Systems
Real Time Systemsleo3004
 
HCI 3e - Ch 6: HCI in the software process
HCI 3e - Ch 6:  HCI in the software processHCI 3e - Ch 6:  HCI in the software process
HCI 3e - Ch 6: HCI in the software processAlan Dix
 
Real Time OS For Embedded Systems
Real Time OS For Embedded SystemsReal Time OS For Embedded Systems
Real Time OS For Embedded SystemsHimanshu Ghetia
 
Linux kernel Architecture and Properties
Linux kernel Architecture and PropertiesLinux kernel Architecture and Properties
Linux kernel Architecture and PropertiesSaadi Rahman
 
Real Time Systems
Real Time SystemsReal Time Systems
Real Time SystemsDeepak John
 
Basic functions & types of RTOS ES
Basic functions & types of  RTOS ESBasic functions & types of  RTOS ES
Basic functions & types of RTOS ESJOLLUSUDARSHANREDDY
 
HCI 3e - Ch 2: The computer
HCI 3e - Ch 2:  The computerHCI 3e - Ch 2:  The computer
HCI 3e - Ch 2: The computerAlan Dix
 
HCI 3e - Ch 4: Paradigms
HCI 3e - Ch 4:  ParadigmsHCI 3e - Ch 4:  Paradigms
HCI 3e - Ch 4: ParadigmsAlan Dix
 
HCI 3e - Ch 1: The human
HCI 3e - Ch 1:  The humanHCI 3e - Ch 1:  The human
HCI 3e - Ch 1: The humanAlan Dix
 
HCI 3e - Ch 11: User support
HCI 3e - Ch 11:  User supportHCI 3e - Ch 11:  User support
HCI 3e - Ch 11: User supportAlan Dix
 

La actualidad más candente (20)

Design of embedded systems
Design of embedded systemsDesign of embedded systems
Design of embedded systems
 
HCI - Chapter 2
HCI - Chapter 2HCI - Chapter 2
HCI - Chapter 2
 
Real-Time Embedded System Design
Real-Time Embedded System DesignReal-Time Embedded System Design
Real-Time Embedded System Design
 
Real Time Systems &amp; RTOS
Real Time Systems &amp; RTOSReal Time Systems &amp; RTOS
Real Time Systems &amp; RTOS
 
Vx works RTOS
Vx works RTOSVx works RTOS
Vx works RTOS
 
HCI 3e - Ch 5: Interaction design basics
HCI 3e - Ch 5:  Interaction design basicsHCI 3e - Ch 5:  Interaction design basics
HCI 3e - Ch 5: Interaction design basics
 
Real Time Systems
Real Time SystemsReal Time Systems
Real Time Systems
 
HCI 3e - Ch 6: HCI in the software process
HCI 3e - Ch 6:  HCI in the software processHCI 3e - Ch 6:  HCI in the software process
HCI 3e - Ch 6: HCI in the software process
 
Real Time OS For Embedded Systems
Real Time OS For Embedded SystemsReal Time OS For Embedded Systems
Real Time OS For Embedded Systems
 
Real-Time Operating Systems
Real-Time Operating SystemsReal-Time Operating Systems
Real-Time Operating Systems
 
Linux kernel Architecture and Properties
Linux kernel Architecture and PropertiesLinux kernel Architecture and Properties
Linux kernel Architecture and Properties
 
Real Time Systems
Real Time SystemsReal Time Systems
Real Time Systems
 
CS6401 OPERATING SYSTEMS Unit 2
CS6401 OPERATING SYSTEMS Unit 2CS6401 OPERATING SYSTEMS Unit 2
CS6401 OPERATING SYSTEMS Unit 2
 
Real Time Operating System
Real Time Operating SystemReal Time Operating System
Real Time Operating System
 
Basic functions & types of RTOS ES
Basic functions & types of  RTOS ESBasic functions & types of  RTOS ES
Basic functions & types of RTOS ES
 
HCI 3e - Ch 2: The computer
HCI 3e - Ch 2:  The computerHCI 3e - Ch 2:  The computer
HCI 3e - Ch 2: The computer
 
HCI 3e - Ch 4: Paradigms
HCI 3e - Ch 4:  ParadigmsHCI 3e - Ch 4:  Paradigms
HCI 3e - Ch 4: Paradigms
 
HCI 3e - Ch 1: The human
HCI 3e - Ch 1:  The humanHCI 3e - Ch 1:  The human
HCI 3e - Ch 1: The human
 
08 Operating System Support
08  Operating  System  Support08  Operating  System  Support
08 Operating System Support
 
HCI 3e - Ch 11: User support
HCI 3e - Ch 11:  User supportHCI 3e - Ch 11:  User support
HCI 3e - Ch 11: User support
 

Destacado

REAL TIME OPERATING SYSTEM PART 1
REAL TIME OPERATING SYSTEM PART 1REAL TIME OPERATING SYSTEM PART 1
REAL TIME OPERATING SYSTEM PART 1Embeddedcraft Craft
 
Embedded System Tools ppt
Embedded System Tools  pptEmbedded System Tools  ppt
Embedded System Tools pptHalai Hansika
 
Unit 4 Real Time Operating System
Unit 4 Real Time Operating SystemUnit 4 Real Time Operating System
Unit 4 Real Time Operating SystemDr. Pankaj Zope
 
Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating SystemTech_MX
 

Destacado (6)

E.s unit 4 and 5
E.s unit 4 and 5E.s unit 4 and 5
E.s unit 4 and 5
 
E.s unit 6
E.s unit 6E.s unit 6
E.s unit 6
 
REAL TIME OPERATING SYSTEM PART 1
REAL TIME OPERATING SYSTEM PART 1REAL TIME OPERATING SYSTEM PART 1
REAL TIME OPERATING SYSTEM PART 1
 
Embedded System Tools ppt
Embedded System Tools  pptEmbedded System Tools  ppt
Embedded System Tools ppt
 
Unit 4 Real Time Operating System
Unit 4 Real Time Operating SystemUnit 4 Real Time Operating System
Unit 4 Real Time Operating System
 
Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating System
 

Similar a Real Time Systems

Testing real-time Linux. What to test and how
Testing real-time Linux. What to test and how Testing real-time Linux. What to test and how
Testing real-time Linux. What to test and how Chirag Jog
 
Four Ways to Improve Linux Performance IEEE Webinar, R2.0
Four Ways to Improve Linux Performance IEEE Webinar, R2.0Four Ways to Improve Linux Performance IEEE Webinar, R2.0
Four Ways to Improve Linux Performance IEEE Webinar, R2.0Michael Christofferson
 
Bertrand Delsart Java R T S
Bertrand Delsart Java R T SBertrand Delsart Java R T S
Bertrand Delsart Java R T Sdeimos
 
OpenStack Summit Tokyo - Know-how of Challlenging Deploy/Operation NTT DOCOMO...
OpenStack Summit Tokyo - Know-how of Challlenging Deploy/Operation NTT DOCOMO...OpenStack Summit Tokyo - Know-how of Challlenging Deploy/Operation NTT DOCOMO...
OpenStack Summit Tokyo - Know-how of Challlenging Deploy/Operation NTT DOCOMO...Masaaki Nakagawa
 
Analysis of Embedded Linux Literature Review Report
Analysis of Embedded Linux Literature Review ReportAnalysis of Embedded Linux Literature Review Report
Analysis of Embedded Linux Literature Review ReportSitakanta Mishra
 
Real Time Operating system (RTOS) - Embedded systems
Real Time Operating system (RTOS) - Embedded systemsReal Time Operating system (RTOS) - Embedded systems
Real Time Operating system (RTOS) - Embedded systemsHariharan Ganesan
 
Chapter 19 - Real Time Systems
Chapter 19 - Real Time SystemsChapter 19 - Real Time Systems
Chapter 19 - Real Time SystemsWayne Jones Jnr
 
RDMA programming design and case studies – for better performance distributed...
RDMA programming design and case studies – for better performance distributed...RDMA programming design and case studies – for better performance distributed...
RDMA programming design and case studies – for better performance distributed...NTT Software Innovation Center
 
Enea Enabling Real-Time in Linux Whitepaper
Enea Enabling Real-Time in Linux WhitepaperEnea Enabling Real-Time in Linux Whitepaper
Enea Enabling Real-Time in Linux WhitepaperEnea Software AB
 
Using Embedded Linux for Infrastructure Systems
Using Embedded Linux for Infrastructure SystemsUsing Embedded Linux for Infrastructure Systems
Using Embedded Linux for Infrastructure SystemsYoshitake Kobayashi
 
PART-1 : Mastering RTOS FreeRTOS and STM32Fx with Debugging
PART-1 : Mastering RTOS FreeRTOS and STM32Fx with DebuggingPART-1 : Mastering RTOS FreeRTOS and STM32Fx with Debugging
PART-1 : Mastering RTOS FreeRTOS and STM32Fx with DebuggingFastBit Embedded Brain Academy
 
Introduction to DDS
Introduction to DDSIntroduction to DDS
Introduction to DDSRick Warren
 

Similar a Real Time Systems (20)

Processes
ProcessesProcesses
Processes
 
Testing real-time Linux. What to test and how
Testing real-time Linux. What to test and how Testing real-time Linux. What to test and how
Testing real-time Linux. What to test and how
 
RTOS
RTOSRTOS
RTOS
 
Four Ways to Improve Linux Performance IEEE Webinar, R2.0
Four Ways to Improve Linux Performance IEEE Webinar, R2.0Four Ways to Improve Linux Performance IEEE Webinar, R2.0
Four Ways to Improve Linux Performance IEEE Webinar, R2.0
 
Rtos 2
Rtos 2Rtos 2
Rtos 2
 
Bertrand Delsart Java R T S
Bertrand Delsart Java R T SBertrand Delsart Java R T S
Bertrand Delsart Java R T S
 
OpenStack Summit Tokyo - Know-how of Challlenging Deploy/Operation NTT DOCOMO...
OpenStack Summit Tokyo - Know-how of Challlenging Deploy/Operation NTT DOCOMO...OpenStack Summit Tokyo - Know-how of Challlenging Deploy/Operation NTT DOCOMO...
OpenStack Summit Tokyo - Know-how of Challlenging Deploy/Operation NTT DOCOMO...
 
Analysis of Embedded Linux Literature Review Report
Analysis of Embedded Linux Literature Review ReportAnalysis of Embedded Linux Literature Review Report
Analysis of Embedded Linux Literature Review Report
 
Real Time Operating system (RTOS) - Embedded systems
Real Time Operating system (RTOS) - Embedded systemsReal Time Operating system (RTOS) - Embedded systems
Real Time Operating system (RTOS) - Embedded systems
 
RTDroid_Presentation
RTDroid_PresentationRTDroid_Presentation
RTDroid_Presentation
 
FreeRTOS introduction
FreeRTOS introductionFreeRTOS introduction
FreeRTOS introduction
 
Threads
ThreadsThreads
Threads
 
Chapter 19 - Real Time Systems
Chapter 19 - Real Time SystemsChapter 19 - Real Time Systems
Chapter 19 - Real Time Systems
 
RDMA programming design and case studies – for better performance distributed...
RDMA programming design and case studies – for better performance distributed...RDMA programming design and case studies – for better performance distributed...
RDMA programming design and case studies – for better performance distributed...
 
Enea Enabling Real-Time in Linux Whitepaper
Enea Enabling Real-Time in Linux WhitepaperEnea Enabling Real-Time in Linux Whitepaper
Enea Enabling Real-Time in Linux Whitepaper
 
PPT.pdf
PPT.pdfPPT.pdf
PPT.pdf
 
Using Embedded Linux for Infrastructure Systems
Using Embedded Linux for Infrastructure SystemsUsing Embedded Linux for Infrastructure Systems
Using Embedded Linux for Infrastructure Systems
 
Embedded Software Design
Embedded Software DesignEmbedded Software Design
Embedded Software Design
 
PART-1 : Mastering RTOS FreeRTOS and STM32Fx with Debugging
PART-1 : Mastering RTOS FreeRTOS and STM32Fx with DebuggingPART-1 : Mastering RTOS FreeRTOS and STM32Fx with Debugging
PART-1 : Mastering RTOS FreeRTOS and STM32Fx with Debugging
 
Introduction to DDS
Introduction to DDSIntroduction to DDS
Introduction to DDS
 

Más de Anil Kumar Pugalia (20)

File System Modules
File System ModulesFile System Modules
File System Modules
 
Kernel Debugging & Profiling
Kernel Debugging & ProfilingKernel Debugging & Profiling
Kernel Debugging & Profiling
 
Processes
ProcessesProcesses
Processes
 
System Calls
System CallsSystem Calls
System Calls
 
Introduction to Linux
Introduction to LinuxIntroduction to Linux
Introduction to Linux
 
Embedded C
Embedded CEmbedded C
Embedded C
 
Playing with R L C Circuits
Playing with R L C CircuitsPlaying with R L C Circuits
Playing with R L C Circuits
 
Audio Drivers
Audio DriversAudio Drivers
Audio Drivers
 
Video Drivers
Video DriversVideo Drivers
Video Drivers
 
Mobile Hacking using Linux Drivers
Mobile Hacking using Linux DriversMobile Hacking using Linux Drivers
Mobile Hacking using Linux Drivers
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
 
References
ReferencesReferences
References
 
Functional Programming with LISP
Functional Programming with LISPFunctional Programming with LISP
Functional Programming with LISP
 
Power of vi
Power of viPower of vi
Power of vi
 
gcc and friends
gcc and friendsgcc and friends
gcc and friends
 
"make" system
"make" system"make" system
"make" system
 
Hardware Design for Software Hackers
Hardware Design for Software HackersHardware Design for Software Hackers
Hardware Design for Software Hackers
 
RPM Building
RPM BuildingRPM Building
RPM Building
 
Linux User Space Debugging & Profiling
Linux User Space Debugging & ProfilingLinux User Space Debugging & Profiling
Linux User Space Debugging & Profiling
 
Linux Network Management
Linux Network ManagementLinux Network Management
Linux Network Management
 

Último

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Último (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Real Time Systems

  • 1. Real Time Systems © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> All Rights Reserved.
  • 2. What to Expect? W's of Real Time & RTOS? Design Methodologies of RTOS Linux → Real Time Linux Various Latencies & Schedulers The “Real Time Patch” Path Real Time Applications Real Time Kernel Debugging Peek into a Co-Kernel © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 2 All Rights Reserved.
  • 3. Real Time Definition Correctness depends on Functional Accuracy, and Timings of the Result produced Examples MPEG Decoder in your DVD player Call Response in your Mobile Phone © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 3 All Rights Reserved.
  • 4. Real Time Types Hard Real Time Guaranteed to meet the response reqs Examples: Defense Systems, Vehicle Control Systems, Satellite Systems Soft Real Time Once in a while may not meet the response reqs Examples: Multimedia Devices, VoIP, CE devices An intermediate one: Firm Real Time Check: What is our Desktop? © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 4 All Rights Reserved.
  • 5. Is Real Time needed? Deadline of Applications Reduces Quality or Unacceptable External Device Interactions with Apps Handling of Messages – Time-bound or not Application Task Priority Could it be needed higher than OS services Expressing delays & timeouts Is it needed to be fine-grained, say in usecs © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 5 All Rights Reserved.
  • 6. Real Time OS RTOS Phylum Non Real-time Soft Real-time Hard Real-time Conflicting Requirements Real Time vs Rich Features of GPOS © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 6 All Rights Reserved.
  • 7. Expected Features of an RTOS RTOS Requirements Strictly Enforced Task Priorities Fine-grained Preemption External Event Handling in Bounded time frame Which entails Predictable Low Interrupt Latency Predictable Low Scheduler Latency Priority Inheritance But wanted with Rich Features of Multi Tasking / Processing Interprocess Communication & Synchronization © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 7 All Rights Reserved.
  • 8. RTOS Design Methodologies Expand an RTOS Make a GPOS Real Time capable Linux → Real Time Linux (Separate Session) The Co-Kernel Approach RT Apps in User Space Open Source Xenomai (Separate Session) Open Source RTAI RT Apps in Kernel Space RTLinux from Windriver © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 8 All Rights Reserved.
  • 9. Expand an RTOS Difficult to ensure Determinism As all core capabilities must be fully preemptive Drivers for Hardware becomes very complex Existing Software cannot be used without changes High Maintenance Costs for Developers and Customers So, let's understand the other one w.r.t. Linux © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 9 All Rights Reserved.
  • 10. Linux → Real Time Linux © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 10 All Rights Reserved.
  • 11. Why Linux is non Real Time? High Interrupt Latency High Scheduler Latency OS services with indeterministic timing behaviour IPC, Memory Allocation, ... Linux is in general undeterministic in its response Virtual Memory, System Calls, … Later two are more of a better Coding Principles However, the first two are major Design Changes Let's take a closer look © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 11 All Rights Reserved.
  • 12. Real Time related Concepts Latency Interrupt Scheduling Both are related to Preemption And Critical Sections © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 12 All Rights Reserved.
  • 13. Latency Visualization Interrupt ISR Runs ISR Signals RT Process Event RT Process Runs Time t0 t1 t2 t3 Interrupt Interrupt Scheduling Latency Scheduling Latency Interrupt to Process Latency © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 13 All Rights Reserved.
  • 14. Latency Details Why Interrupt Latency? Attributes of ISR Real Time Process Typically, high priority Otherwise, anyway it is a problem All 3 could potentially pose problems For Hard Real Time © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 14 All Rights Reserved.
  • 15. Possible Solutions Key Requirement Schedule RT Process, within a given time Possible Helpers Remove / Reduce interrupt-disabled code (critical sections) Write ISRs really really minimal in execution time Real Time Apps with the highest priority May be higher than interrupts, softirqs, etc © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 15 All Rights Reserved.
  • 16. Preemption Visualization Time User Space System Call Interface Kernel Space Process A Process B © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 16 All Rights Reserved.
  • 17. Preemption Details Higher Preemption makes it more Real Time feasible Higher Priority (RT Tasks) could be scheduled in a more predictable time Sources of Preemption Latency Critical Section Processing Interrupt Context Processing © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 17 All Rights Reserved.
  • 18. Preemption & Critical Sections Higher Preemption at the cost of reducing Critical Sections Isolate & Minimize the critical sections Protect them by disabling preemption spin_lock / spin_unlock; preempt_disable / preempt_enable Preemption Models for reducing Critical Sections Preempt only safe locations Entry & Exit of system calls, Return from interrupt processing, … Put explicit “allow preempt” code at these places Overall not an excellent approach Preempt everywhere except only the Critical Sections lock-breaking mechanism Getting achieved by instrumenting kernel for latency measurements And by fixing the longest latency code paths © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 18 All Rights Reserved.
  • 19. SMP World & Critical Sections Uniprocessor case needs Protection from Interrupt Processing Exception Processing Multiprocessor with additional Multiple Kernel Threads Posed a bigger need than Real Time for reduced Critical Sections Real Time has gained benefits from SMP development, as well © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 19 All Rights Reserved.
  • 20. Real Time Kernel Patch Critical Section Control is a major step We have achieved good Soft Real Time Performance Since 2.6.12, in single-digit milliseconds On reasonably fast x86 processor But without solving the Interrupt Latency Hard Real Time is not possible Recent Developments have majorly focused on this aspect A major Real Time Kernel Patch evolved Maintained by Ingo Molnar Available @ http://people.redhat.com/~mingo/realtime-preempt Could be downloaded using say, ketchup -G 2.6.22.1-rt9 And takes care of many more issues © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 20 All Rights Reserved.
  • 21. W's & How's of RT Kernel Patch? Lot's of Questions What all does it contain? How to configure it? What should be used & when? And many more Before answering these, let's understand Schedulers in main-stream Kernel Preemption Support in main-stream Kernel © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 21 All Rights Reserved.
  • 22. Linux Schedulers Provides multi-tasking capabilities by Time Slicing Preemption Based on various task priorities Specified by its scheduling policies Understands the following execution instances Kernel Thread User Process User Thread Linux Basic Scheduling Normal (SCHED_OTHER) – Fairness Scheduling Other Advanced Scheduling supported Round Robin (SCHED_RR) FIFO (SCHED_FIFO) All Schedulers are O(1) © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 22 All Rights Reserved.
  • 23. Linux Kernel Preemption Levels None (PREEMPT_NONE) No forced preemption Overall throughput, on average, is good Voluntary (PREEMPT_VOLUNTARY) First stage of latency reduction Explicit preemption points are placed at strategic locations Standard (PREEMPT_DESKTOP) Preemption enabled everywhere except within critical sections Good for soft real-time applications, like audio, multimedia, … Kernel Parameter: preempt © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 23 All Rights Reserved.
  • 24. Preemption Level from RT Patch Complete (PREEMPT_RT) Spin locks replaced with preembtable mutexes Preemption enabled everywhere except where protected by preempt_disable() Smoothes out variation in latency Allows a low & predictable latency for time- critical real-time applications © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 24 All Rights Reserved.
  • 25. Additional Real Time Features ISRs as Kernel Tasks CONFIG_PREEMPT_HARDIRQ Schedulable & Preemptible Priority Assignment as Required Control Window: /proc/sys/kernel/hardirq_preemption Kernel Parameter: hardirq-preempt Preemptable Softirqs CONFIG_PREEMPT_SOFTIRQ All ran in the context of ksoftirqd → Now as individual threads A proper Linux task configured for real time Control Window: /proc/sys/kernel/softirq_preemption Kernel Parameter: softirq-preempt Certain Read-Copy-Update (RCU) sections preemptible CONFIG_PREEMPT_RCU RCU is synchronization primitive for frequently read data © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 25 All Rights Reserved.
  • 26. Creating a Real Time Process #include <sched.h> #define MY_RT_PRIO 1 int main(...) { int old_policy; struct sched_param params = { .sched_priority = MY_RT_PRIO }; ... old_policy = sched_getscheduler(0); if (sched_setscheduler(0, SCHED_RR, &params) == -1) handle_error(); … } © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 26 All Rights Reserved.
  • 27. RT Application: Do's & Don'ts Have very few Real Time Processes Keep the RT Applications Short & Efficient Do not do heavy duty operations Like Memory Allocation, etc If essential, move to Initialization Sections Check for the working of the needed OS services Especially, if any RT Application has priority higher than that OS Service Test for the Desired Results © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 27 All Rights Reserved.
  • 28. Debugging Real Time Kernel Soft Lockup CONFIG_DETECT_SOFTLOCKUP Unsafe Preemption Use Logging CONFIG_DEBUG_PREEMPT Deadlock Conditions Detection & Reporting CONFIG_DEBUG_DEADLOCK Deadlocks due to semaphores & spinlocks Runtime Control of Locking Mode CONFIG_DEBUG_RT_LOCKING_MODE Mutex back to Spinlock © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 28 All Rights Reserved.
  • 29. Tracing Real Time Kernel Latency Tracing CONFIG_LATENCY_TRACE For data associated with last maximum preemption latency Kernel Window: /proc/latency_trace Function Call Tracing Inserts hooks to every function via gcc Gives function level details through Kernel Window: /proc/latency_trace Soon getting outdated by Ftrace © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 29 All Rights Reserved.
  • 30. Further Tracing RT Kernel High Priority Process Wakeup CONFIG_WAKEUP_TIMING CONFIG_WAKEUP_LATENCY_HIST Or, Interrupt Off Timing CONFIG_CRITICAL_IRQSOFF_TIMING CONFIG_INTERRUPT_OFF_HIST Kernel Windows /proc/sys/kernel/preempt_max_latency /proc/latency_hist/interrupt_off_latency/CPU0 (0-10000us) Time spent with Preemption disabled (in critical sections) CONFIG_CRITICAL_PREEMPT_TIMING CONFIG_PREEMPT_OFF_HIST © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 30 All Rights Reserved.
  • 31. Real Time Linux Myths & Realities With all these understood Is Linux really Hard Real Time? Can it be used in all Real Time Embedded activities? Can it be used in a Nuclear Reactor? Answers Can be used in most Real Time Embedded Applications, such as Robotics But cannot be “one-size-fits-it-all” approach to Real Time Is still a patch and hence not that extensibly tested Not all Device Drivers have yet been verified as Real Time safe More & more users (such as multimedia users), using the patch would verify more drivers, as they are the users noticing longer latency delays caused by these devices But even if they are, it is after all a GPOS Harder to verify a lack of bugs Could have potential bugs (from real time perspective) © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 31 All Rights Reserved.
  • 32. Co-Kernel Approach © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 32 All Rights Reserved.
  • 33. W's of Co-Kernel Approach Do not convert the GPOS into an RTOS Place a small Real Time Kernel besides it On the same Hardware This would be the Co-Kernel Taking care of all Real Time needs Non-RT tasks are done by the GPOS So, © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 33 All Rights Reserved.
  • 34. What is a Co-Kernel? Co-Kernel is a Subsystem Integrated with the main Kernel Handling the Real Time part © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 34 All Rights Reserved.
  • 35. Types of Co-Kernel Approaches Two Prevalent Approaches Support running of RT Apps in User Space RT Apps to be embodied into Kernel Space Our Focus of Discussion is the First One With Xenomai in consideration © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 35 All Rights Reserved.
  • 36. Benefits of Xenomai Co-Kernel or Core running under Kernel, licensed under GPL 2 Kernel Support Both 2.4 & 2.6 for with & without MMU systems Provides generic building blocks to implement RT APIs (skins) RT API Support for VxWorks, pSOS+, VRTX, uITRON, POSIX 1003.1b User Space i/f libraries: LGPL 2.1 Architecture Support PowerPC*, Blackfin, ARM, x86* Excellent Resources Documentation, Technical Articles, … Website: http://www.xenomai.org © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 36 All Rights Reserved.
  • 37. Xenomai Architecture User Space User Space User Space User Space Application Application Application Application Linux syscall interface VxWorks pSOS VRTX POSIX ... Kernel-based Skin Skin Skin Skin Applications Abstract RTOS Core SAL / HAL Portability Layers I-Pipe © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 37 All Rights Reserved.
  • 38. Xenomai Components Interrupt Pipeline Hardware & System Abstraction Layers Xenomai Core & Nucleus Xenomai Skins © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 38 All Rights Reserved.
  • 39. How Xenomai Works? Real Time Shadow New Sets of System Calls Sharing Kernel Features By Domain Migration Real Time Driver Model Mediation © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 39 All Rights Reserved.
  • 40. What all have we learnt? W's of Real Time & RTOS? Design Methodologies of RTOS Linux → Real Time Linux Various Latencies & Schedulers The “Real Time Patch” Path Real Time Applications Real Time Kernel Debugging Peek into a Co-Kernel © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 40 All Rights Reserved.
  • 41. Any Queries? © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 41 All Rights Reserved.