resource kernels: linux/rk
DESCRIPTION
Resource Kernels: Linux/RK. Raj Rajkumar, Kanaka Juvva, Anastasio Molano and Shui Oikawa, “Resource Kernels: A Resource-Centric Approach to Real-Time Systems”, In Proceedings of the SPIE/ACM Conference on Multimedia Computing and Networking, January 1998. Before we start…. Unix Scheduling - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Resource Kernels: Linux/RK](https://reader035.vdocuments.site/reader035/viewer/2022062323/56815249550346895dc087f0/html5/thumbnails/1.jpg)
Resource Kernels: Linux/RK
Raj Rajkumar, Kanaka Juvva, Anastasio Molano and Shui Oikawa, “Resource Kernels: A Resource-Centric Approach to Real-Time Systems”, In Proceedings of the SPIE/ACM Conference on Multimedia Computing and Networking, January 1998.
![Page 2: Resource Kernels: Linux/RK](https://reader035.vdocuments.site/reader035/viewer/2022062323/56815249550346895dc087f0/html5/thumbnails/2.jpg)
Before we start…
• Unix Scheduling– Mainly for time-sharing– Multilevel feedback queue– Each queue applies Round Robin
scheduling– Priority varies dynamically, e.g., aging
![Page 3: Resource Kernels: Linux/RK](https://reader035.vdocuments.site/reader035/viewer/2022062323/56815249550346895dc087f0/html5/thumbnails/3.jpg)
Linux Scheduling
• Provides RT-POSIX interface• Fixed priority real-time scheduling classes
– SCHED_FIFO– SCHED_RR
• 100 priority levels• Timesharing in SCHED_OTHER• Relatively new preemptive Linux kernels• Enough support for real-time applications?
![Page 4: Resource Kernels: Linux/RK](https://reader035.vdocuments.site/reader035/viewer/2022062323/56815249550346895dc087f0/html5/thumbnails/4.jpg)
Extend Linux for real-time support
• Why extend Linux?– A large user base– Open-source– But, is the Linux footprint small enough
for embedded applications?
![Page 5: Resource Kernels: Linux/RK](https://reader035.vdocuments.site/reader035/viewer/2022062323/56815249550346895dc087f0/html5/thumbnails/5.jpg)
Resource Kernel• A Kernel that provides to applications Timely,
Guaranteed, and Enforced access to System Resources
• Allows Applications to specify only their Resource Demands – leaving the Kernel to satisfy those Demands using
hidden management schemesTask 1
Task 2
Task 3
Resource SetResource Set
Rsv 1 Rsv 2
Rsv 3
DiskBWNetBW
CPU
Reservation Parameters
“T”: Period (1/f)“C”: Execution time
within period“D”: Deadline within
period
Source: Dr. Rajkumar at CMU
![Page 6: Resource Kernels: Linux/RK](https://reader035.vdocuments.site/reader035/viewer/2022062323/56815249550346895dc087f0/html5/thumbnails/6.jpg)
Linux/RK Architecture
Hardware
ResourceKernel Linux
KernelKernel
User-Level
LoadableKernelModule
LinuxProcess
LinuxProcess
LinuxProcess
Kernel
Source: Dr. Rajkumar at CMU
![Page 7: Resource Kernels: Linux/RK](https://reader035.vdocuments.site/reader035/viewer/2022062323/56815249550346895dc087f0/html5/thumbnails/7.jpg)
• Open source Linux project: – www.fsmlabs.com – http://tldp.org/HOWTO/RTLinux-HOWTO.html
• Supports x86, PowerPC, Alpha
• Available as a patch to the regular Linux kernel
• Provides an RT API for developers
• Runs Linux kernel as lowest priority process
Diversion: RTLinux
Source: Cpre 458/558 by Dr. Manimaran at Iowa State University
![Page 8: Resource Kernels: Linux/RK](https://reader035.vdocuments.site/reader035/viewer/2022062323/56815249550346895dc087f0/html5/thumbnails/8.jpg)
Linux Kernel
System libraries
Device drivers Linux kernel
Hardware
I/O Hardware Interrupts
User Processes
Source: Cpre 458/558 by Dr. Manimaran at Iowa State University
![Page 9: Resource Kernels: Linux/RK](https://reader035.vdocuments.site/reader035/viewer/2022062323/56815249550346895dc087f0/html5/thumbnails/9.jpg)
RTLinux Kernel
Hardware
System libraries
Device drivers Linux kernel
I/O Software Interrupts
User Processes
RTLinux Plug-in
Real Time Tasks
RT-Scheduler
I/O Hardware Interrupts
Linux is executed in the background
Direct h/w access
Source: Cpre 458/558 by Dr. Manimaran at Iowa State University
![Page 10: Resource Kernels: Linux/RK](https://reader035.vdocuments.site/reader035/viewer/2022062323/56815249550346895dc087f0/html5/thumbnails/10.jpg)
Linux Kernel: code perspective
Linux Monolithic kernel core
M1
M2
M3
M4
Kernel Loadable M
odules
RAM DISK
Module M2 service (system call)
User
Process
M2
THE controller
Source: Cpre 458/558 by Dr. Manimaran at Iowa State University
![Page 11: Resource Kernels: Linux/RK](https://reader035.vdocuments.site/reader035/viewer/2022062323/56815249550346895dc087f0/html5/thumbnails/11.jpg)
RTLinux Kernel: code perspective
Linux Monolithic kernel core
RTM2
RTM3
M1
M2
Kernel Loadable M
odules
RAMDISK
Load RT core
RT Load command
RT-Core Module
RT core
M3
THE controller
Source: Cpre 458/558 by Dr. Manimaran at Iowa State University
![Page 12: Resource Kernels: Linux/RK](https://reader035.vdocuments.site/reader035/viewer/2022062323/56815249550346895dc087f0/html5/thumbnails/12.jpg)
Getting RTLinux ready• Configure and compile a fresh Linux kernel
(2.4.29)– Download the kernel fromhttp://www.kernel.org/pub/linux/kernel/v2.4/linux-2.4.29.tar.gz
• Patch the RTLinux to the Linux kernel
• Recompile the kernel and reboot the system into the new kernel
• Configure the RTLinux kernel and compile it
Source: Cpre 458/558 by Dr. Manimaran at Iowa State University
![Page 13: Resource Kernels: Linux/RK](https://reader035.vdocuments.site/reader035/viewer/2022062323/56815249550346895dc087f0/html5/thumbnails/13.jpg)
Linux/RK AbstractionsCMU’s Linux/RK supports several abstractions and primitives
for real-time scheduling of processes with real-time and QoS requirements:
• Resource reservations with latency guarantees– CPU cycles– Network bandwidth– Disk bandwidth
• Support for periodic tasks.• Support for 256 real-time fixed-priority levels. • High-resolution timers and clocks. • Bounding of priority inversion during synchronization
operations– Also works with reservations (reservation inheritance,
etc.) • Wiring down of memory pages.
Source: Dr. Rajkumar at CMU
![Page 14: Resource Kernels: Linux/RK](https://reader035.vdocuments.site/reader035/viewer/2022062323/56815249550346895dc087f0/html5/thumbnails/14.jpg)
Reservation Types
• Hard reservation: On depletion, it cannot be scheduled until it is replenished
• Firm reservation: On depletion, it can be scheduled if no other undepleted reservation or unreserved threads are ready to run
• Soft reservation: On depletion, it can be scheduled with other unreserved threads and depleted reservations
![Page 15: Resource Kernels: Linux/RK](https://reader035.vdocuments.site/reader035/viewer/2022062323/56815249550346895dc087f0/html5/thumbnails/15.jpg)
Hard reservation
![Page 16: Resource Kernels: Linux/RK](https://reader035.vdocuments.site/reader035/viewer/2022062323/56815249550346895dc087f0/html5/thumbnails/16.jpg)
Firm reservation
![Page 17: Resource Kernels: Linux/RK](https://reader035.vdocuments.site/reader035/viewer/2022062323/56815249550346895dc087f0/html5/thumbnails/17.jpg)
Soft reservation
![Page 18: Resource Kernels: Linux/RK](https://reader035.vdocuments.site/reader035/viewer/2022062323/56815249550346895dc087f0/html5/thumbnails/18.jpg)
Scheduling & Admission Control
• Each reservation receives a fixed priority according to period (RMS) or deadline (DMS)
• Admission control overhead
![Page 19: Resource Kernels: Linux/RK](https://reader035.vdocuments.site/reader035/viewer/2022062323/56815249550346895dc087f0/html5/thumbnails/19.jpg)
Disk Scheduling• Traditional RT systems avoided to use disk
– Unpredictable latencies– Disk access requests should be scheduled in conjunction
with the processor scheduling• Multiple resource problem with deadlines is NP-complete
[5]
• Disk bandwidth reservations in addition to CPU cycle reservations– EDF: Pick the reservation with the earliest deadline
• Immediate preemption of a disk access is impossible• EDF is not optimal in a non-preemptive model• A lot of disk head movements
– EDF + Just-in-time scheduling• High priority tasks may finish early• Exploit “slack” to serve requests close to the current head
position, similar to SCAN
![Page 20: Resource Kernels: Linux/RK](https://reader035.vdocuments.site/reader035/viewer/2022062323/56815249550346895dc087f0/html5/thumbnails/20.jpg)
Workload with both CPU and Disk requirements
![Page 21: Resource Kernels: Linux/RK](https://reader035.vdocuments.site/reader035/viewer/2022062323/56815249550346895dc087f0/html5/thumbnails/21.jpg)
Commercialized Linux/RK: TimeSys Linux
• Resource kernel and QoS Support– guaranteed, timely and enforced
access to CPU cycles and network bandwidth
• SMP support with QoS Reservations• Fully preemptive kernel• Fixed-priority scheduling (POSIX-
compliant)• High-resolution timer and clock support
(microsecond resolution)• Periodic processes• Message queues• Priority inheritance and priority ceiling
protocol emulation support to avoid unbounded priority inversion TimeSys Linux/RT
Real-Time Java
RT-App
App App
RT-App
TimeSys Corporation Source: Dr. Rajkumar at CMU
![Page 22: Resource Kernels: Linux/RK](https://reader035.vdocuments.site/reader035/viewer/2022062323/56815249550346895dc087f0/html5/thumbnails/22.jpg)
TimeSys Linux• TimeSys Linux/GPL
– Basic TimeSys Linux kernel– Full preemption at the kernel level, prioritized interrupt handlers,
unlimited priorities, ... • TimeSys Linux/Real-time
– Support priority inheritance and a POSIX-based high-resolution timer API
• TimeSys Linux/CPU – Support CPU reservation, which gives a thread, process, or process
group exclusive use of the CPU. • TimeSys Linux/Net
– Support network bandwidth reservation to guarantee that your thread or process will get the bandwidth it requires, regardless of network activity in other processes
• TimeSys Linux GPL: Downloadable from sourceforge.net/projects/timesysgpl • TimeSys Linux Install mini HOWTO:
http://doc.ece.uci.edu/~tharmon/files/TimeSys-Linux-Install-mini-HOWTO.html
![Page 23: Resource Kernels: Linux/RK](https://reader035.vdocuments.site/reader035/viewer/2022062323/56815249550346895dc087f0/html5/thumbnails/23.jpg)
#Priority levels and EDF
• EDF is hard to implement because most operating systems only support a fixed number of priority levels (typically <= 256)
• Deadline scheduling, e.g., EDF, can be better fixed priority scheduling which is oblivious to deadlines– Example: Consider the following scenario in
RMS DH
DL
TH
TL
![Page 24: Resource Kernels: Linux/RK](https://reader035.vdocuments.site/reader035/viewer/2022062323/56815249550346895dc087f0/html5/thumbnails/24.jpg)
Fixed priority vs. Dynamic priority
• Fixed priority– Supported by most kernels– Simple & little overhead– Low utilization bound
• RMS: 0.69
• Dynamic priority– Deadline is the first class citizen– High utilization bound: 1 in EDF– Limited priority levels in most kernels– More complex; High overhead
![Page 25: Resource Kernels: Linux/RK](https://reader035.vdocuments.site/reader035/viewer/2022062323/56815249550346895dc087f0/html5/thumbnails/25.jpg)
Average kernel preemption latency comparison
OS Average latency (us)
Average latency (us)
Linux < 10,000 100,000
Linux with preemptive kernel
< 1,000 100,000
TimeSys Linux/GPL
< 50 1,000
TimeSys Linux/Real-Time
< 10 51
Source: http://linuxdevices.com/articles/AT6106723802.html
![Page 26: Resource Kernels: Linux/RK](https://reader035.vdocuments.site/reader035/viewer/2022062323/56815249550346895dc087f0/html5/thumbnails/26.jpg)
Others
• Unix-based: QNX, LynxOS, …• Proprietary: pSOS, VxWorks, VRTX, …• More recently
– eCos– L4– μcOS-II
![Page 27: Resource Kernels: Linux/RK](https://reader035.vdocuments.site/reader035/viewer/2022062323/56815249550346895dc087f0/html5/thumbnails/27.jpg)
Announcement: Midterm Exam
• Midterm Exam on Oct. 12, 2006 for both on-campus and EngiNet students
• Format: In-Class, Closed-book, Closed-note exam
• Study Real-Time Scheduling, Synchronization, and Real-Time Operating Systems covered up to today’s lecture
• Focus on my lecture slides (supplemented by the papers on the reading list)
• From Oct. 2, we will discuss RTDB – Read paper [D1] in the reading list