rtos
play

RTOS Real-Time Operating Systems Chenyang Lu OS Support for - PowerPoint PPT Presentation

RTOS Real-Time Operating Systems Chenyang Lu OS Support for Real-Time Real-Time OS Real-time extensions to general-purpose OS Chenyang Lu 2 RTOS: Features for Efficiency Small Minimal set of functionality Fast context switch


  1. RTOS Real-Time Operating Systems Chenyang Lu

  2. OS Support for Real-Time Ø Real-Time OS Ø Real-time extensions to general-purpose OS Chenyang Lu 2

  3. RTOS: Features for Efficiency Ø Small Ø Minimal set of functionality Ø Fast context switch Ø Fast and time bounded response to interrupts Ø Fixed or variable partitions of memory q May not support paging or virtual memory q May support locking code and data in memory Ø Sequential file that can accumulate data at fast rate q May be memory-based Chenyang Lu 3

  4. Code Size Name Code Size Target CPU pOSEK 2K Microcontrollers pSOSystem PII->ARM Thumb VxWorks 286K Pentium -> Strong ARM QNX Nutrino >100K Pentium II -> NEC QNX RealTime 100K Pentium II -> SH4 OS-9 Pentium -> SH4 Chorus OS 10K Pentium -> Strong ARM ARIEL 19K SH2, ARM Thumb Creem 560 bytes ATMEL 8051 Chenyang Lu 4

  5. RTOS: Features for Real-Time Ø Preemptive priority scheduling q At least 32 priority levels, commonly 128-256 priority levels q Priority inheritance/ceiling protocol Ø System calls q Bounded execution times q Short non-preemptable code Ø High-resolution system clock q Resolution down to nanoseconds q But it takes about a microsecond to process a timer interrupt Chenyang Lu 5

  6. Other Important Features Ø Conformance to standards q Real-Time POSIX API q TCP/IP Ø Modularity and configurability q Small kernel q Pluggable modules Chenyang Lu 6

  7. Example: VRTX Ø VRTXsa q RT -POSIX compliant q Full real-time support Ø VRTXmc q Optimized for power and footprint Ø First RTOS certified by FAA q 100% code coverage in testing Ø Runs the Hubble Space Telescope Chenyang Lu 7

  8. Real-Time Extensions to General OS Ø Generally slower and less predictable than RTOS Ø More functionality and development support Ø Standard interfaces Ø Suitable for soft real-time applications Chenyang Lu 8

  9. How Real-Time Is Linux? Ø I believe that Linux is ready to handle applications requiring sub- millisecond process-scheduling and interrupt latencies with 99.99+ percent probabilities of success . No, that does not cover every imaginable real-time application, but it does cover a very large and important subset. Ø The Linux 2.6 kernel, if configured carefully and run on fast hardware, can provide sub-millisecond interrupt and process scheduling latencies with extremely high probabilities of success. Ø There are patches out there that are expected to provide latencies in the tens of microseconds . These patches need some work, but are maturing quickly. Paul McKenney, IBM Linux Technology Center Shrinking slices: Looking at real time for Linux, PowerPC, and Cell Chenyang Lu 9

  10. Why isn’t Linux real-time? Ø The Linux kernel only allows a process to preempt another under certain circumstances: q when the CPU is running user-mode code; q when kernel code returns from a system call or an interrupt to user space; q when kernel code blocks on a mutex, or explicitly yields control to another process. Ø If kernel code is executing, a high priority thread cannot preempt the kernel until the kernel code yields control. Ø In the worst case , the latency could potentially be hundreds milliseconds or more. Source: https://rt.wiki.kernel.org/ Chenyang Lu 10

  11. Linux Scheduling Ø Real-time scheduling class q Fixed priority • SCHED_FIFO: First-In-First-Out • SCHED_RR: Round-Robin q Earliest Deadline First • SCHED_DEADLINE Ø Non-real-time scheduling class (SCHED_NORMAL) Ø Default q Real-time: 0 – 99 q Non-real-time: 100 – 139 Chenyang Lu 11

  12. Real-time Linux Ø Core kernel modifications: patches q Require modifications to Linux kernel q Example: CONFIG_PREEMPT_RT patch Ø Compliant kernels: modified native RTOS q Linux binaries can run without modifications q Example: LynxOS Ø Dual kernels: real-time kernel sits below Linux q Real-time kernel traps all interrupts and schedules all processes q Linux runs as a low-priority process q Example: RT -Linux (FSLabs) Chenyang Lu 12

  13. CONFIG_PREEMPT_RT Patch Ø Convert Linux into a fully preemptible kernel. Ø Locks q Making in-kernel locking-primitives preemptible through reimplementation with rt-mutexes. q Critical sections protected by spinlock_t and rwlock_t are preemptible. q Priority inheritance for in-kernel spinlocks and semaphores. Ø Convert interrupt handlers into preemptible kernel threads. Ø Convert timer API into separate infrastructures for high resolution kernel timers plus one for timeouts, leading to user space POSIX timers with high resolution. Source: https://rt.wiki.kernel.org/ Chenyang Lu 13

  14. Multi-core Real-Time Scheduler Ø Push-pull scheduler schedules tasks across CPUs. Ø Every CPU has a runqueue. Ø Push: considers all the runqueues within its root domain to find the one of a lower priority than the task being pushed. q Push a task when it wakes up on a runqueue running a task of higher priority q Push a task when a higher-priority task on the same runqueue wakes up and preempts it Ø Pull: whenever a runqueue is about to schedule a task that is lower in priority than the previous one, it checks whether it can pull tasks of a higher priority from other runqueues. Chenyang Lu 14

  15. RT-Linux • Real-time kernel traps all interrupts and schedules all processes • Linux runs as a low-priority process • Real-time applications cannot take advantage of Linux calls Linux Process Linux Process RT Process Linux Kernel Software Interrupts Scheduling Real-Time Kernel Hardware Interrupts Chenyang Lu 15

  16. More Information Ø Real-Time Linux Wiki: https://rt.wiki.kernel.org/index.php/Frequently_Asked_Questions Ø Real-Time Linux Kernel Scheduler: http://www.linuxjournal.com/magazine/real-time-linux-kernel-scheduler Chenyang Lu 16

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend