270 likes | 432 Views
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
E N D
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 • Mainly for time-sharing • Multilevel feedback queue • Each queue applies Round Robin scheduling • Priority varies dynamically, e.g., aging
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?
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?
Disk BW CPU NetBW 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 schemes Task 2 Reservation Parameters “T”: Period (1/f) “C”: Execution time within period “D”: Deadline within period Task 3 Task 1 Resource Set Rsv 1 Rsv 2 Rsv 3 Source: Dr. Rajkumar at CMU
Linux/RKArchitecture Linux Process Linux Process Linux Process User-Level Kernel Resource Kernel Linux Kernel Kernel Loadable Kernel Module Hardware Source: Dr. Rajkumar at CMU
Diversion: RTLinux • 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 Source: Cpre 458/558 by Dr. Manimaran at Iowa State University
Linux Kernel User Processes System libraries Linux kernel Device drivers I/O Hardware Interrupts Hardware Source: Cpre 458/558 by Dr. Manimaran at Iowa State University
RTLinux Kernel Linux is executed in the background User Processes Real Time Tasks System libraries Linux kernel Device drivers I/O Software Interrupts Direct h/w access RTLinux Plug-in RT-Scheduler I/O Hardware Interrupts Hardware Source: Cpre 458/558 by Dr. Manimaran at Iowa State University
Linux Kernel: code perspective THE controller User Process Kernel Loadable Modules Module M2 service (system call) M1 M2 M2 Linux Monolithic kernel core M3 M4 RAM DISK Source: Cpre 458/558 by Dr. Manimaran at Iowa State University
RTLinux Kernel: code perspective THE controller RT Load command RT core Kernel Loadable Modules Load RTcore RTM2 RTM3 Linux Monolithic kernel core M1 M2 RT-Core Module M3 RAM DISK Source: Cpre 458/558 by Dr. Manimaran at Iowa State University
Getting RTLinux ready • Configure and compile a fresh Linux kernel (2.4.29) • Download the kernel from http://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
Linux/RK Abstractions CMU’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
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
Scheduling & Admission Control • Each reservation receives a fixed priority according to period (RMS) or deadline (DMS) • Admission control overhead
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
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 Commercialized Linux/RK: TimeSys Linux SuiteTime tools App App RT-App RT-App Real-Time Java TimeSys Linux/RT Source: Dr. Rajkumar at CMU TimeSys Corporation
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
#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 TH DH TL DL
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
Average kernel preemption latency comparison Source: http://linuxdevices.com/articles/AT6106723802.html
Others • Unix-based: QNX, LynxOS, … • Proprietary: pSOS, VxWorks, VRTX, … • More recently • eCos • L4 • μcOS-II
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