Resource Kernels: Linux/RK

Post on 23-Jan-2016

42 views 0 download

Tags:

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 Presentation

Transcript of Resource Kernels: Linux/RK

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?

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

Linux/RK Architecture

Hardware

ResourceKernel Linux

KernelKernel

User-Level

LoadableKernelModule

LinuxProcess

LinuxProcess

LinuxProcess

Kernel

Source: Dr. Rajkumar at CMU

• 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

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

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

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

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

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

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

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

Hard reservation

Firm reservation

Soft reservation

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

Workload with both CPU and Disk requirements

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

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 DH

DL

TH

TL

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

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

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