0% found this document useful (0 votes)
115 views

RTLinux

RTLinux is an operating system that allows real-time and Linux tasks to run concurrently on the same system. It uses a small real-time kernel that coexists with the Linux kernel. RTLinux features include real-time scheduling algorithms, predictable delays due to its small size, finer timer resolution, a preemptible kernel, and no virtual memory. Common schedulers in RTLinux include first-in-first-out, earliest deadline first, and rate-monotonic. RTLinux aims to overcome limitations of Linux for real-time tasks such as unpredictable scheduling and coarse timer resolution.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
115 views

RTLinux

RTLinux is an operating system that allows real-time and Linux tasks to run concurrently on the same system. It uses a small real-time kernel that coexists with the Linux kernel. RTLinux features include real-time scheduling algorithms, predictable delays due to its small size, finer timer resolution, a preemptible kernel, and no virtual memory. Common schedulers in RTLinux include first-in-first-out, earliest deadline first, and rate-monotonic. RTLinux aims to overcome limitations of Linux for real-time tasks such as unpredictable scheduling and coarse timer resolution.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 30

RTLinux v.s.

Linux
Defects of Linux
• Linux scheduling algorithms are not designed for real-time tasks.
– Linux will “batch” operations to make more efficient use of the hardware.
• Linux scheduling is unpredictable.
– Linux processes are heavyweight processes.
– It can take several hundred microseconds to finish a context switch.
• Linux Timer resolution is coarse, 10 ms.
• Linux Kernel is Non-preemptible .
– Even the lowest priority task is running.
– Linux will make high priority tasks wait for low priority tasks to release resources.
• Linux disables interrupts used for coarse-grained synchronization.
– “Coarse grained” synchronization means that there are long intervals when one
task has exclusive use of some data.
• Linux uses virtual memory.
• Linux reorders requests for efficiency (e.g., for disk I/O).
RTLinux
 RT-Linux is an operating system in which a small
real-time kernel coexists with the POSIX-like Linux
kernel.
 RTLinux is module oriented.
 Scheduler.
 The “earliest deadline first” scheduler.
 Rate-monotonic scheduler.
 The module that implements RT-FIFOs.
 RTLinux decouples the mechanisms of the real-time
kernel from the mechanisms of the general purpose
kernel.
 Each can be optimized independently.
 The RT kernel can be kept small and simple.
RTLinux Features
 Real-time scheduling algorithm.
 Predictable delays.
 By its small size and limited operations.
 Finer timer resolution.
 Preemptible kernel.
 The RTLinux executive is itself nonpreemptible.
 Its routine are very small and fast, this does not cause big delays.
 Interrupts from Linux are disabled.
 No virtual memory.
Scheduler
 RT-Linux contains a dynamic scheduler.

 RT-Linux has many kinds of Schedulers.


 FIFO.
 The “earliest deadline first” scheduler.
 Rate-monotonic scheduler.
RT FIFO
• Real-time FIFOs are used to pass information
between real-time process and ordinary Linux
process.
• Real-time FIFOs are designed to never block the
real-time task.
• RT-FIFOs are, like real-time tasks, never paged
out. This eliminates the problem of unpredictable
delays due to paging.
Timer Resolution
 If the kernel was patched with UTIME, we could schedule
processes with microsecond resolution.
 Running rtlinux-V3.0 Kernel 2.2.19 on the 486 allows stable
hard real-time operation. Giving:
 15 microseconds worst case jitter.
 10 microseconds event resolution.
 17 nanoseconds timer resolution.
 6 microseconds interrupt response time. (This value was measured
on interrupts on the parallel port)
 High resolution timing functions give nanosecond resolution
(limited by the hardware only.)
Applications
Linux, RTLinux, and RTAI (1)
Linux RTLinux RTAI
Alpha, ARM, i386, MIPS, PowerPC, Sparc, i386, PPC, ARM, Alpha, i386, MIPS, PPC, ARM, m68k-
Hardware SuperH, Etrax, m68k, PA-RISC MIPS nommu
Multi-processor Yes Yes Yes

Scheduling SCHED_FIFO, SCHED_RR, SCHED_OTHER SCHED_FIFO, EDF, and RM Fixed priority

UNIX-processes &
Processes Pthreads Lightweight processes
Pthreads
Priorities
(0-100) (0-1,000,000) 0x3fffFfff-0)
lower - higher

Memory protection Yes No Yes

Dynamic memory Yes No Yes

Semaphores, Mutexes,
Inter-process Semaphores, Mutexes, Condition-var., Semaphores, Mutexes,
Condition-var., FIFO, Mailbox,
communication shared-mem, signals, pipes. Condition-var., FIFO
shared-mem, net_rpc, Pqueues.
Linux, RTLinux, and RTAI (2)
Linux RTLinux RTAI
Priority inversion
None Immediate ceiling Inheritance
control
Time
Configurable (HighResTimers) Hardware dependant Hardware dependant
resolution
Timers POSIX timers None None

Low level
No interrupt programming. Full control HW Full control HW
programming

FIFO, CBQ, CSZ, ATM, PRIO, RED, SFQ,


QoS TLE, TBF, GRED, Diffserv, Ingress, RSVP
None None

IP, UDP, TCP, SLIP, PPP, ICMP, DHCP,


Network RARP, RARP, TFTP, RPC, FTP, HTTP
None None

ReiserFS, ext2, ext3, NFS, CIFS, ADFS,


File Systems FAT, VFAT, NTFS, CRAMFS, ISO9660, None None
MINIX, QNX4, ROM, JFS, XFS, Flash

Semaphores, Mutexes,
Inter-process Semaphores, Mutexes, Condition-var., Semaphores, Mutexes,
Condition-var., FIFO, Mailbox,
communication shared-mem, signals, pipes. Condition-var., FIFO
shared-mem, net_rpc, Pqueues.
Linux, RTLinux, and RTAI (3)
API
Debug Languages
compatibility

GDB, DDD, Insight, System C, C++, ADA, POSIX 1003.1,


Linux
debugg, and LTT Java, etc. VxWorks, pSOS

RTLinux Simple trace, GDB C, C++ POSIX 1003.1c

Custom,
RTAI KGDB C
POSIX 1003.1b
Conclusions (1)

Test Metrics (ns) eCos RTLinux

Thread Creation Latency 16,130 – 34,300 137,216

Thread Deletion Latency 5,350 – 6,450 8,448

Mutex Latency 5,043 -25,340 5,043 – 46,912


Conclusions (2)
Conclusions (3)
Introduction to Real-Time Process
Scheduling
Introduction to Real-Time Process
Scheduling (1)
• Q: Many theories and algorithms in real-time
process scheduling seem to have simplified
assumptions without direct solutions to
engineers’ problems. Why should we know
them?
• A:
– Provide insight in choosing a good system design
and scheduling algorithm.
– Avoid poor or erroneous choices.
Introduction to Real-Time Process
Scheduling (3)
Job Shop Scheduling
Time
Independent Process Scheduling
(Liu & Layland, 1973, etc.) Multiprocessor Process Scheduling
(Dhall, 1972-, etc.)

Process Scheduling with


Non-Preemptable Resources Sporadic Process Scheduling
(Mok, 1983, Sha, Rajkumar, 1986, Baker, 1991, etc.) (Sprunt, 1989, etc.)
Non-preemptable Scheduling
(Baruah, 1990-, etc.)

Process Scheduling with End-to-End Delays Process Scheduling with


(Stankovic, Gerber, Lin, etc, since ?.) Probabilistic Guarantee
(Liu, Lehoczky, etc, since 1995.)
Process Scheduling with
Realistic Task Characteristics
(Liu, Mok, etc, since 1996.)

Process Scheduling with Multiple Rate-Based Scheduling


Resources (Buttazzo, Liu, Brauah, Kuo, etc, since 1995.)
Uni-process Scheduling
• Fixed-Priority vs. Dynamic-Priority Scheduling
• Rate-Monotonic Scheduling Algorithm
• Earliest Deadline First Scheduling
Process Model
• Periodic process
– Each periodic process arrives at a regular frequency – a
special case of demand.
– r: ready time, d: relative deadline, p: period, c: worst
case computation time.
– For example, maintaining a display
• Sporadic process
– An aperiodic process with bounded inter-arrival time p.
– For example, turning on a light
• Other requirements and issues:
– process synchronization including precedence and critical
sections, process value, etc.
Performance Metrics
• Metrics for hard real-time processes:
– Schedulability, etc.
• Metrics for soft real-time processes:
– Miss ratio
– Accumulated value
– Response time, etc.
• Other metrics:
– Optimality, overload handling, mode-change handling,
stability, jitter, etc.
– Combinations of metrics.
Definitions
• Preemptive scheduling: allows process preemptions. (vs.
nonpreemptive scheduling)
• Online scheduling: allocates resources for processes
depending on the current workload. (vs. offline scheduling)
• Static scheduling: operates on a fixed set of processes and
produces a single schedule that is fixed at all time. (vs.
dynamic scheduling)
• Firm real-time process: will be killed after it misses its
deadline. (vs. hard and soft real-time)
• Fixed-priority scheduling: in which the priority of each
process is fixed for any instantiation. (vs. dynamic-priority
scheduling)
Rate Monotonic Scheduling Algorithm
(1)
• Assumptions:
– all periodic fixed-priority processes
– relative deadline = period
– independent process - no non-preemptable resources
• Rate Monotonic (RM) Scheduling Algorithm
– RM priority assignment: priority ~ 1/period.
– preemptive priority-driven scheduling.
• Example: T1 (p1=4, c1=2) and T2 (p2=5, c1=1)

0 1 2 3 4 5 6 7 8
Rate Monotonic Scheduling Algorithm (2)
• Critical Instant
– An instant at which a request of the process have the
largest completion/response time.
– An instance at which the process is requested
simultaneously with requests of all higher priority
processes.
• Usages
– Worst-case analysis
– Fully utilization of the processor power
– Example: T1 (p1=4, c1=2) and T2 (p2=5, c2=1)

0 1 2 3 4 5 6 7 8
Rate-Monotonic Analysis
• Schedulability Test:

  n(2 1) 1/ n
– A sufficient but not necessary condition.
– Achievable utilization factor αof a scheduling policy ci
P: any process set with total utilization factor P
no more than α is schedulable. i

– Given n processes,
• Stability:
– Let processes be sorted in RMi c order. The ith
process is schedulable if  j  i (21/ i  1)
j 1 p j

– An optimal fixed priority scheduling algorithm


Applications
• RM was chosen by
– Space Station Freedom Project
– FAA Advanced Automation System (AAS)
• RM influenced the specs of IEEE Futurebus+
• RMA is widely used for off-line analysis of
time-critical systems.
Earliest Deadline First Scheduling
Algorithm (1)
• Assumptions (similar to RM):
– all periodic dynamic-priority processes
– relative deadline = period
– independent process - no non-preemptable resources
• Earliest Deadline First (EDF) Scheduling Algorithm:
– EDF priority assignment: priority ~ absolute deadline.
i.e., arrival time t + relative deadline d.
– preemptive priority-driven scheduling
• Example: T1(c1=1, p1=2), T2(c2=2, p2=7)

0 1 2 3 4 5 6 7 8
Earliest Deadline First Scheduling
Algorithm (2)
• Schedulability Test:
– A sufficient and necessary condition
– Any process set is schedulable by EDF iff
ci
 P 1
i
• EDF is optimal for any independent process
scheduling algorithms.
• However, its implementation has considerable
overheads on OS’s with a fixed-priority scheduler
and is bad for (transiently) overloaded systems.

You might also like