SlideShare une entreprise Scribd logo
1  sur  36
By. Prof.Ruchi Sharma
                   BVCOE
                NEW DELHI




02/16/13                           1
Fire alarm system: an example


                           Central server

                           TCP/IP over radio


                           Controllers: ARM based

                           Low bandwidth radio links

                           Sensors: microcontroller based

02/16/13                                                    2
Fire Alarm System
 Problem
      Hundreds of sensors, each fitted with Low Range
           Wireless
              Sensor information to be logged in a server & appropriate action
               initiated
 Possible Solution
      Collaborative Action
        Routing
                Dynamic – Sensors/controllers may go down
                Auto Configurable – No/easy human intervention.
                Less Collision/Link Clogging
                Less no of intermediate nodes
                   Fast Response Time
                Secure


02/16/13                                                                          3
Processors         MIPS

      Microcontrollers   ~20
      ARM7                     100-133
      ARM9                     180-250
      Strong ARM         206
      Intel Xscale             400
      Mips4Kcore               400
      X86
02/16/13                                 4
Real Time System
 A system is said to be Real Time if it is required to
  complete it’s work & deliver it’s services on time.
 Example – Flight Control System
      All tasks in that system must execute on time.
 Non Example – PC system




02/16/13                                                  5
Hard and Soft Real Time Systems
 Hard Real Time System
      Failure to meet deadlines is fatal
      example : Flight Control System
 Soft Real Time System
      Late completion of jobs is undesirable but not fatal.
      System performance degrades as more & more jobs
       miss deadlines
      Online Databases
 Qualitative Definition.


02/16/13                                                       6
Hard and Soft Real Time Systems
                        (Operational Definition)
 Hard Real Time System
      Validation by provably correct procedures or extensive
           simulation that the system always meets the timings
           constraints
 Soft Real Time System
      Demonstration of jobs meeting some statistical
           constraints suffices.
 Example – Multimedia System
      25 frames per second on an average


02/16/13                                                         7
Role of an OS in Real Time Systems
 Standalone Applications
      Often no OS involved
      Micro controller based Embedded Systems
 Some Real Time Applications are huge & complex
      Multiple threads
      Complicated Synchronization Requirements
      Filesystem / Network / Windowing support
      OS primitives reduce the software design time



02/16/13                                               8
Features of RTOS’s
 Scheduling.


 Resource Allocation.


 Interrupt Handling.


 Other issues like kernel size.



02/16/13                           9
Scheduling in RTOS
 More information about the tasks are known
      No of tasks
      Resource Requirements
      Release Time
      Execution time
      Deadlines
 Being a more deterministic system better
    scheduling algorithms can be devised.


02/16/13                                       10
Scheduling Algorithms in RTOS
 Clock Driven Scheduling


 Weighted Round Robin Scheduling


 Priority Scheduling
    (Greedy / List / Event Driven)




02/16/13                             11
Scheduling Algorithms in RTOS (contd)
 Clock Driven
      All parameters about jobs (release time/ execution
       time/deadline) known in advance.
      Schedule can be computed offline or at some regular
       time instances.
      Minimal runtime overhead.
      Not suitable for many applications.




02/16/13                                                     12
Scheduling Algorithms in RTOS (contd)
 Weighted Round Robin
      Jobs scheduled in FIFO manner
      Time quantum given to jobs is proportional to it’s
       weight
      Example use : High speed switching network
              QOS guarantee.
      Not suitable for precedence constrained jobs.
              Job A can run only after Job B. No point in giving time quantum
               to Job B before Job A.



02/16/13                                                                         13
Scheduling Algorithms in RTOS (contd)
 Priority Scheduling
    (Greedy/List/Event Driven)
      Processor never left idle when there are ready tasks
      Processor allocated to processes according to priorities
      Priorities
            static - at design time
            Dynamic - at runtime




02/16/13                                                          14
Priority Scheduling
 Earliest Deadline First (EDF)
      Process with earliest deadline given highest priority
 Least Slack Time First (LSF)
      slack = relative deadline – execution left
 Rate Monotonic Scheduling (RMS)
      For periodic tasks
      Tasks priority inversely proportional to it’s period




02/16/13                                                       15
Resource Allocation in RTOS
  Resource Allocation
      The issues with scheduling applicable here.
      Resources can be allocated in
            Weighted Round Robin
            Priority Based

 Some resources are non preemptible
      Example : semaphores
 Priority Inversion if priority scheduling is used


02/16/13                                              16
02/16/13   17
Solutions to Priority Inversion
 Non Blocking Critical Section
      Higher priority Thread may get blocked by unrelated
           low priority thread
 Priority Ceiling
      Each resource has an assigned priority
      Priority of thread is the highest of all priorities of the
           resources it’s holding
 Priority Inheritance
      The thread holding a resource inherits the priority of
           the thread blocked on that resource

02/16/13                                                            18
Other RTOS issues
 Interrupt Latency should be very small
      Kernel has to respond to real time events
      Interrupts should be disabled for minimum possible
           time
 For embedded applications Kernel Size should be
    small
      Should fit in ROM
 Sophisticated features can be removed
      No Virtual Memory
      No Protection

02/16/13                                                    19
Linux for Real Time Applications
 Scheduling
      Priority Driven Approach
              Optimize average case response time
      Interactive Processes Given Highest Priority
              Aim to reduce response times of processes
      Real Time Processes
            Processes with high priority
            No notion of deadlines

 Resource Allocation
      No support for handling priority inversion


02/16/13                                                   20
Interrupt Handling in Linux
 Interrupts are disabled in ISR/critical sections of the
  kernel
 No worst case bound on interrupt latency avaliable
      eg: Disk Drivers may disable interrupt for few hundred
           milliseconds
 Not suitable for Real Time Applications
  Interrupts may be missed




02/16/13                                                        21
Other Problems with Linux
 Processes are non preemtible in Kernel Mode
      System calls like fork take a lot of time
      High priority thread might wait for a low priority
           thread to complete it’s system call
 Processes are heavy weight
      Context switch takes several hundred microseconds




02/16/13                                                    22
Why Linux
 Coexistence of Real Time Applications with non Real
    Time Ones
      Example http server
 Device Driver Base
 Stability




02/16/13                                                23
RTLinux
 Real Time Kernel at the lowest level
 Linux Kernel is a low priority thread
   Executed only when no real time tasks
 Interrupts trapped by the Real Time Kernel and
    passed onto Linux Kernel
      Software emulation to hardware interrupts
            Interrupts are queued by RTLinux
            Software emulation to disable_interrupt()




02/16/13                                                 24
RTLinux (contd)
 Real Time Tasks
  Statically allocate memory
  No address space protection
 Non Real Time Tasks are developed in Linux
 Communication
  Queues
  Shared memory




02/16/13                                       25
02/16/13   26
rtker – Our RTOS
 Motivation
      Our own OS
              Full grasp over source code – Easily modifiable, portable
 Features
      Modular Design
              Isolation of Architecture/CPU dependent and independent code
               – Easy to Port
      Pluggable Scheduler
      Two level Interrupt Handling
      Small footprint
      Oskit’s Device Driver Framework

02/16/13                                                                   27
Pluggable Scheduler
 Scheduler - part of the Application
 Kernel interacts with the scheduler through an API
 Application developer needs to implement the
    scheduler API
      Can optimize on Data Structures & Algorithms for
           implementing the scheduler




02/16/13                                                  28
rtker – Block Diagram




02/16/13                29
Two Level Interrupt Handling
 Two level Interrupt Handling
      Top Half Interrupt Handler
            Called Immediately – Kernel never disables interrupts
            Cannot invoke thread library functions - Race Conditions

      Bottom Half Interrupt Handler
            Invoked when kernel not in Critical Section
            Can invoke thread library functions

 Very Low Response time (as compared to Linux)



02/16/13                                                                30
Two Level Interrupt Handling




02/16/13                       31
02/16/13   32
Other Features
 Footprint
      Small footprint (~50kb)
 Oskit’s Device Driver Framework
      Allows direct porting of existing drivers from Linux.
      Example – Ethernet Driver of Linux




02/16/13                                                       33
Other RTOS’s
 LynxOS
      Microkernel Architecture
              Kernel provides scheduling/interrupt handling
      Additional features through Kernel Plug Ins(KPIs)
        TCP/IP stack , Filesystem

        KPI’s are multithreaded

      Memory Protection/ Demand Paging Optional
      Development and Deployment on the same host
              OS support for compilers/debuggers



02/16/13                                                       34
Other RTOS’s (contd)
 VxWorks
      Monolithic Architecture
      Real Time Posix compliant
      Cross development System
 pSOS
      Object Oriented OS




02/16/13                           35
• Interfacing
              Serial/parallel ports, USB, I2C, PCMCIA, IDE
           • Communication
              Serial, Ethernet, Low bandwidth radio, IrDA,
              802.11b based devices
           • User Interface
              LCD, Keyboard, Touch sensors, Sound, Digital
              pads, Webcams
           • Sensors
              A variety of sensors using fire, temperature,
              pressure, water level, seismic, sound, vision
02/16/13                                                      36

Contenu connexe

Tendances

Real Time Kernels
Real Time KernelsReal Time Kernels
Real Time Kernels
Arnav Soni
 
Real Time Operating Systems
Real Time Operating SystemsReal Time Operating Systems
Real Time Operating Systems
Rohit Joshi
 
Rtos princples adn case study
Rtos princples adn case studyRtos princples adn case study
Rtos princples adn case study
vanamali_vanu
 

Tendances (20)

RTOS
RTOSRTOS
RTOS
 
Chapter 19 - Real Time Systems
Chapter 19 - Real Time SystemsChapter 19 - Real Time Systems
Chapter 19 - Real Time Systems
 
RTOS implementation
RTOS implementationRTOS implementation
RTOS implementation
 
Basic functions & types of RTOS ES
Basic functions & types of  RTOS ESBasic functions & types of  RTOS ES
Basic functions & types of RTOS ES
 
Real Time Kernels
Real Time KernelsReal Time Kernels
Real Time Kernels
 
Real Time Operating Systems
Real Time Operating SystemsReal Time Operating Systems
Real Time Operating Systems
 
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
 
Real Time Operating Systems
Real Time Operating SystemsReal Time Operating Systems
Real Time Operating Systems
 
RTOS Basic Concepts
RTOS Basic ConceptsRTOS Basic Concepts
RTOS Basic Concepts
 
Os rtos.ppt
Os rtos.pptOs rtos.ppt
Os rtos.ppt
 
Real Time Operating System
Real Time Operating SystemReal Time Operating System
Real Time Operating System
 
presentation on real time operating system(RTOS's)
presentation on real time operating system(RTOS's)presentation on real time operating system(RTOS's)
presentation on real time operating system(RTOS's)
 
Mastering Real-time Linux
Mastering Real-time LinuxMastering Real-time Linux
Mastering Real-time Linux
 
Rtos part2
Rtos part2Rtos part2
Rtos part2
 
Rtos princples adn case study
Rtos princples adn case studyRtos princples adn case study
Rtos princples adn case study
 
Real time operating systems (rtos) concepts 1
Real time operating systems (rtos) concepts 1Real time operating systems (rtos) concepts 1
Real time operating systems (rtos) concepts 1
 
Real time Linux
Real time LinuxReal time Linux
Real time Linux
 
Real Time Operating Systems for Embedded Systems
Real Time Operating Systems for Embedded SystemsReal Time Operating Systems for Embedded Systems
Real Time Operating Systems for Embedded Systems
 
RTOS CASE STUDY OF CODING FOR SENDING APPLIC...
                                RTOS  CASE STUDY OF CODING FOR SENDING APPLIC...                                RTOS  CASE STUDY OF CODING FOR SENDING APPLIC...
RTOS CASE STUDY OF CODING FOR SENDING APPLIC...
 
RT linux
RT linuxRT linux
RT linux
 

Similaire à Rtos

Real Time OS For Embedded Systems
Real Time OS For Embedded SystemsReal Time OS For Embedded Systems
Real Time OS For Embedded Systems
Himanshu Ghetia
 
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
Michael Christofferson
 

Similaire à Rtos (20)

ghhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhjjjjjjjjjjjjjjj
ghhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhjjjjjjjjjjjjjjjghhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhjjjjjjjjjjjjjjj
ghhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhjjjjjjjjjjjjjjj
 
rtos.ppt
rtos.pptrtos.ppt
rtos.ppt
 
Introduction to Real-Time Operating Systems
Introduction to Real-Time Operating SystemsIntroduction to Real-Time Operating Systems
Introduction to Real-Time Operating Systems
 
pptonrtosbychetan001-140213003314-phpapp02.pdf
pptonrtosbychetan001-140213003314-phpapp02.pdfpptonrtosbychetan001-140213003314-phpapp02.pdf
pptonrtosbychetan001-140213003314-phpapp02.pdf
 
Real Time Operating System
Real Time Operating SystemReal Time Operating System
Real Time Operating System
 
UNIT V PPT.ppt
UNIT V PPT.pptUNIT V PPT.ppt
UNIT V PPT.ppt
 
Rts assighment final
Rts assighment finalRts assighment final
Rts assighment final
 
Rtos Concepts
Rtos ConceptsRtos Concepts
Rtos Concepts
 
Real time system basic concept
Real time system basic conceptReal time system basic concept
Real time system basic concept
 
Real Time OS For Embedded Systems
Real Time OS For Embedded SystemsReal Time OS For Embedded Systems
Real Time OS For Embedded Systems
 
RTOS.pdf
RTOS.pdfRTOS.pdf
RTOS.pdf
 
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
 
Os Concepts
Os ConceptsOs Concepts
Os Concepts
 
Making Linux do Hard Real-time
Making Linux do Hard Real-timeMaking Linux do Hard Real-time
Making Linux do Hard Real-time
 
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
 
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
 
rtosbyshibu-131026100746-phpapp01.pdf
rtosbyshibu-131026100746-phpapp01.pdfrtosbyshibu-131026100746-phpapp01.pdf
rtosbyshibu-131026100746-phpapp01.pdf
 
Rtos by shibu
Rtos by shibuRtos by shibu
Rtos by shibu
 
Rtos
RtosRtos
Rtos
 
Realtime
RealtimeRealtime
Realtime
 

Plus de Ruchi Sharma (6)

Ipc feb4
Ipc feb4Ipc feb4
Ipc feb4
 
Ipc ppt
Ipc pptIpc ppt
Ipc ppt
 
EMBEDDED SYSTEMS
EMBEDDED SYSTEMSEMBEDDED SYSTEMS
EMBEDDED SYSTEMS
 
Nn3
Nn3Nn3
Nn3
 
Nn ppt
Nn pptNn ppt
Nn ppt
 
neural networks
neural networksneural networks
neural networks
 

Dernier

Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

Dernier (20)

How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 

Rtos

  • 1. By. Prof.Ruchi Sharma BVCOE NEW DELHI 02/16/13 1
  • 2. Fire alarm system: an example Central server TCP/IP over radio Controllers: ARM based Low bandwidth radio links Sensors: microcontroller based 02/16/13 2
  • 3. Fire Alarm System Problem Hundreds of sensors, each fitted with Low Range Wireless  Sensor information to be logged in a server & appropriate action initiated Possible Solution Collaborative Action  Routing  Dynamic – Sensors/controllers may go down  Auto Configurable – No/easy human intervention.  Less Collision/Link Clogging  Less no of intermediate nodes  Fast Response Time  Secure 02/16/13 3
  • 4. Processors MIPS Microcontrollers ~20 ARM7 100-133 ARM9 180-250 Strong ARM 206 Intel Xscale 400 Mips4Kcore 400 X86 02/16/13 4
  • 5. Real Time System A system is said to be Real Time if it is required to complete it’s work & deliver it’s services on time. Example – Flight Control System All tasks in that system must execute on time. Non Example – PC system 02/16/13 5
  • 6. Hard and Soft Real Time Systems Hard Real Time System Failure to meet deadlines is fatal example : Flight Control System Soft Real Time System Late completion of jobs is undesirable but not fatal. System performance degrades as more & more jobs miss deadlines Online Databases Qualitative Definition. 02/16/13 6
  • 7. Hard and Soft Real Time Systems (Operational Definition) Hard Real Time System Validation by provably correct procedures or extensive simulation that the system always meets the timings constraints Soft Real Time System Demonstration of jobs meeting some statistical constraints suffices. Example – Multimedia System 25 frames per second on an average 02/16/13 7
  • 8. Role of an OS in Real Time Systems Standalone Applications Often no OS involved Micro controller based Embedded Systems Some Real Time Applications are huge & complex Multiple threads Complicated Synchronization Requirements Filesystem / Network / Windowing support OS primitives reduce the software design time 02/16/13 8
  • 9. Features of RTOS’s Scheduling. Resource Allocation. Interrupt Handling. Other issues like kernel size. 02/16/13 9
  • 10. Scheduling in RTOS More information about the tasks are known No of tasks Resource Requirements Release Time Execution time Deadlines Being a more deterministic system better scheduling algorithms can be devised. 02/16/13 10
  • 11. Scheduling Algorithms in RTOS Clock Driven Scheduling Weighted Round Robin Scheduling Priority Scheduling (Greedy / List / Event Driven) 02/16/13 11
  • 12. Scheduling Algorithms in RTOS (contd) Clock Driven All parameters about jobs (release time/ execution time/deadline) known in advance. Schedule can be computed offline or at some regular time instances. Minimal runtime overhead. Not suitable for many applications. 02/16/13 12
  • 13. Scheduling Algorithms in RTOS (contd) Weighted Round Robin Jobs scheduled in FIFO manner Time quantum given to jobs is proportional to it’s weight Example use : High speed switching network  QOS guarantee. Not suitable for precedence constrained jobs.  Job A can run only after Job B. No point in giving time quantum to Job B before Job A. 02/16/13 13
  • 14. Scheduling Algorithms in RTOS (contd) Priority Scheduling (Greedy/List/Event Driven) Processor never left idle when there are ready tasks Processor allocated to processes according to priorities Priorities  static - at design time  Dynamic - at runtime 02/16/13 14
  • 15. Priority Scheduling Earliest Deadline First (EDF) Process with earliest deadline given highest priority Least Slack Time First (LSF) slack = relative deadline – execution left Rate Monotonic Scheduling (RMS) For periodic tasks Tasks priority inversely proportional to it’s period 02/16/13 15
  • 16. Resource Allocation in RTOS  Resource Allocation The issues with scheduling applicable here. Resources can be allocated in  Weighted Round Robin  Priority Based Some resources are non preemptible Example : semaphores Priority Inversion if priority scheduling is used 02/16/13 16
  • 17. 02/16/13 17
  • 18. Solutions to Priority Inversion Non Blocking Critical Section Higher priority Thread may get blocked by unrelated low priority thread Priority Ceiling Each resource has an assigned priority Priority of thread is the highest of all priorities of the resources it’s holding Priority Inheritance The thread holding a resource inherits the priority of the thread blocked on that resource 02/16/13 18
  • 19. Other RTOS issues Interrupt Latency should be very small Kernel has to respond to real time events Interrupts should be disabled for minimum possible time For embedded applications Kernel Size should be small Should fit in ROM Sophisticated features can be removed No Virtual Memory No Protection 02/16/13 19
  • 20. Linux for Real Time Applications Scheduling Priority Driven Approach  Optimize average case response time Interactive Processes Given Highest Priority  Aim to reduce response times of processes Real Time Processes  Processes with high priority  No notion of deadlines Resource Allocation No support for handling priority inversion 02/16/13 20
  • 21. Interrupt Handling in Linux Interrupts are disabled in ISR/critical sections of the kernel No worst case bound on interrupt latency avaliable eg: Disk Drivers may disable interrupt for few hundred milliseconds Not suitable for Real Time Applications Interrupts may be missed 02/16/13 21
  • 22. Other Problems with Linux Processes are non preemtible in Kernel Mode System calls like fork take a lot of time High priority thread might wait for a low priority thread to complete it’s system call Processes are heavy weight Context switch takes several hundred microseconds 02/16/13 22
  • 23. Why Linux Coexistence of Real Time Applications with non Real Time Ones Example http server Device Driver Base Stability 02/16/13 23
  • 24. RTLinux Real Time Kernel at the lowest level Linux Kernel is a low priority thread Executed only when no real time tasks Interrupts trapped by the Real Time Kernel and passed onto Linux Kernel Software emulation to hardware interrupts  Interrupts are queued by RTLinux  Software emulation to disable_interrupt() 02/16/13 24
  • 25. RTLinux (contd) Real Time Tasks Statically allocate memory No address space protection Non Real Time Tasks are developed in Linux Communication Queues Shared memory 02/16/13 25
  • 26. 02/16/13 26
  • 27. rtker – Our RTOS Motivation Our own OS  Full grasp over source code – Easily modifiable, portable Features Modular Design  Isolation of Architecture/CPU dependent and independent code – Easy to Port Pluggable Scheduler Two level Interrupt Handling Small footprint Oskit’s Device Driver Framework 02/16/13 27
  • 28. Pluggable Scheduler Scheduler - part of the Application Kernel interacts with the scheduler through an API Application developer needs to implement the scheduler API Can optimize on Data Structures & Algorithms for implementing the scheduler 02/16/13 28
  • 29. rtker – Block Diagram 02/16/13 29
  • 30. Two Level Interrupt Handling Two level Interrupt Handling Top Half Interrupt Handler  Called Immediately – Kernel never disables interrupts  Cannot invoke thread library functions - Race Conditions Bottom Half Interrupt Handler  Invoked when kernel not in Critical Section  Can invoke thread library functions Very Low Response time (as compared to Linux) 02/16/13 30
  • 31. Two Level Interrupt Handling 02/16/13 31
  • 32. 02/16/13 32
  • 33. Other Features Footprint Small footprint (~50kb) Oskit’s Device Driver Framework Allows direct porting of existing drivers from Linux. Example – Ethernet Driver of Linux 02/16/13 33
  • 34. Other RTOS’s LynxOS Microkernel Architecture  Kernel provides scheduling/interrupt handling Additional features through Kernel Plug Ins(KPIs)  TCP/IP stack , Filesystem  KPI’s are multithreaded Memory Protection/ Demand Paging Optional Development and Deployment on the same host  OS support for compilers/debuggers 02/16/13 34
  • 35. Other RTOS’s (contd) VxWorks Monolithic Architecture Real Time Posix compliant Cross development System pSOS Object Oriented OS 02/16/13 35
  • 36. • Interfacing Serial/parallel ports, USB, I2C, PCMCIA, IDE • Communication Serial, Ethernet, Low bandwidth radio, IrDA, 802.11b based devices • User Interface LCD, Keyboard, Touch sensors, Sound, Digital pads, Webcams • Sensors A variety of sensors using fire, temperature, pressure, water level, seismic, sound, vision 02/16/13 36