Upload
ansel
View
69
Download
1
Embed Size (px)
DESCRIPTION
CSED191 | 컴퓨터공학소개 | November 2006. Real-Time Operating Systems. 서광열 , 류준호 , 오병찬. What is a Real-Time OS?. A RTOS(Real-Time Operating System) An Operating System with the necessary features to support a Real-Time System What is a Real-Time System? - PowerPoint PPT Presentation
Citation preview
Real-Time Operating Systems
CSED191 | 컴퓨터공학소개 | November 2006
서광열 , 류준호 , 오병찬
What is a Real-Time OS?• A RTOS(Real-Time Operating System)
− An Operating System with the necessary features to support a Real-Time System
• What is a Real-Time System?− A system where correctness depends not only
on the correctness of the logical result of the computation, but also on the result delivery time
− A system that responds in a timely, predictable way to unpredictable external stimuli arrivals
• 99% of all RTOS are for the embedded systems market
Examples of Real-Time AppsGSM cell phone• One TDMA
frame/4.6 ms• Maximum
latency guarnatee < 500 usec
Video• HDTV 60
frames/sec -> 16 ms/frame
Audio• 1-10 ms
Network Traffic Routing
• Real-Time QOS(Quality of Service) contraints
Type of Real-Time Systems• Hard Real-Time
− Missing a deadline has catastrophic results for the system
• Firm Real-Time− Missing a deadline causes an
unacceptable quality reduction
• Soft Real-Time− Reduction in system quality is
acceptable− Deadlines may be missed and can
be recovered from
Characteristics of RTOS1. Scheduling2. Intertask communication and resource
sharing3. Interrupt handlers and the scheduler4. Memory allocation
From Wikipedia
Scheduling• Minimize the worst-case length of time
spent in the scheduler's critical section • Pre-emptive priority scheduling – higher
priority tasks may interrupt lower priority tasks
Running
Ready Blocked
BlockDispatch
Timer run-out
Wakeup
Task 1Prio 7
Task 2Prio 5
Task 3Prio 10 Choose the highest priority task
Intertask communication and resource sharing
• Sharing data and hardware resources among multiple tasks− Unsafe for two tasks to access
the same specific data or hardware resource simultaneously
• Common approaches1. Temporarily masking/disabling
interrupts2. Binary Semaphores3. Message passing
− RTOS− Priority Inversion Problem− Priority Inheritnace
Thread 1 Thread 2
LockHeldBy 1
SharedResource
Waiting
Low Priority High Priority
Interrupt handlers and the scheduler• Keep interrupt handlers
as short as possible
• Procedures1. Acknowledge or disable
the interrupt 2. The interrupt handler
queues work to be done at a lower priority level, often by unblocking a driver task
Top Half(Interrupt disabled)
Bottom Half(Low priority)
Interrupts
DeferredProcess
Linux Interrupt HandlingExample
Memory Allocation Requirements
• Problems1. Speed of allocation:
Scanning a linked list of indeterminate length is not acceptable
2. Memory fragmentation
• Possible solution− Use simple fixed-size
block allocation Fragmented Memory
VxWorks
CASE STUDY
CASE: VxWorks
Features• Modularized kernel
− Many libraries and subroutines• High-speed interrupt process
− Separated Task/Interrupt stacks− Shorter interrupt latency than Linux
• Cross-compiling target software to run on various target CPU architectures
CASE: VxWorks
The pros• Multi-thread model OS• An application merges with OS kernel• It can access common workplace
(memory) freely• The size of OS is small, good for small
systems (easy to make)
CASE: VxWorks
The cons
• A simple bug can spoil whole system• Specialized to some vendors• Commercial software
− High license cost, even running royalty exists
• Plus, the market of linux-based OS is going bigger and bigger
CASE: VxWorks
Usages• Mars Pathfinder Lander fault protection
− continuously monitors hundreds of parts of the spacecraft for a wide range of problems
CASE: VxWorks
Usages (Continued)• Boeing 787 common core system
− the backbone of the airplane's computers, networks and interfacing electronics
Windows CE
CASE STUDY
CASE: Windows CE
Features
• Preemptive kernel• Predictable synchronization mechanism• Predictable and bounded interrupt
latency
CASE: Windows CE Preemptive Multitasking• Eight levels of thread priority
− Real-time processing device drivers− Kernel threads and normal applications− Applications that always can be
preempted• Does not age priorities• Does not mask interrupts
CASE: Windows CE Predictable synchronization mechanism
• Correct interaction between threads− mutex, critical section, and event objects
• "FIFO-by-priority" order− First come first served order− Different queue for each priority levels
CASE: Windows CE Interrupt latency• Amount of time that elapse
− Arrives at the processor− Interrupt processing begins
• Bounded and predictable− Possible to calculate worst-case latency
• Does not support nested interrupts
Real-time Linux
CASE STUDY
CASE: Real-time Linux Linux is not a Real-Time OS
Hardware(CPU, Memory, Disks, etc)
Linux LinuxProcess
LinuxProcess
LinuxProcess
OOPS!
CASE: Real-time Linux (1) FSMLab’s RTLinux
RTOS
Hardware(CPU, Memory, Disks, etc)
RTThread
RTThread
RTThread(Linux)
Linux LinuxProcess
LinuxProcess
FixedPriority
Scheduler
LowestPriority
CASE: Real-time Linux (1) RTLinux Characteristics• RTLinux is nonpreemptible
− Small size and limited operations guarantee predictable delay
• Real-time tasks− Direct access to hardware− No virtual memory− Written as a special Linux module,
dynamically loaded into memory• No Linux kernel modification
CASE: Real-time Linux (2) MontaVista’s Preemptive Kernel• 2.4 Linux kernel is
not preemptive− Higher priority
task should be suspended
CASE: Real-time Linux (2) Preemptive Kernel• Preemptive kernel
− Originate from SMP supports (spinlocks)
− Improve latency• Lock breaking
− Some spinlocks contains a long loop
• Voluntary Preemption− Use might_sleep() debugging
macro− Release all held spinlocks and
reacquire when awakened• Priority Inheritance Mutexes
− The PI mutex patch replaces the spinlocks with priority inheritance mutexes
Others emhancements• BKL• Interrupt Threads• Read/write locks• Kernel lists/queues/fifos• Deadlock detection• Instrumentation
The End