27
Real-Time Operating Systems CSED191 | 컴컴컴컴컴컴컴 | November 2006 컴컴컴 , 컴컴컴 , 컴컴컴

Real-Time Operating Systems

  • 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

Page 1: Real-Time Operating Systems

Real-Time Operating Systems

CSED191 | 컴퓨터공학소개 | November 2006

서광열 , 류준호 , 오병찬

Page 2: 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?− 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

Page 3: Real-Time Operating Systems

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

Page 4: Real-Time Operating Systems

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

Page 5: Real-Time Operating Systems

Characteristics of RTOS1. Scheduling2. Intertask communication and resource

sharing3. Interrupt handlers and the scheduler4. Memory allocation

From Wikipedia

Page 6: Real-Time Operating Systems

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

Page 7: Real-Time Operating Systems

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

Page 8: Real-Time Operating Systems

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

Page 9: Real-Time Operating Systems

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

Page 10: Real-Time Operating Systems

VxWorks

CASE STUDY

Page 11: Real-Time Operating Systems

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

Page 12: Real-Time Operating Systems

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)

Page 13: Real-Time Operating Systems

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

Page 14: Real-Time Operating Systems

CASE: VxWorks

Usages• Mars Pathfinder Lander fault protection

− continuously monitors hundreds of parts of the spacecraft for a wide range of problems

Page 15: Real-Time Operating Systems

CASE: VxWorks

Usages (Continued)• Boeing 787 common core system

− the backbone of the airplane's computers, networks and interfacing electronics

Page 16: Real-Time Operating Systems

Windows CE

CASE STUDY

Page 17: Real-Time Operating Systems

CASE: Windows CE

Features

• Preemptive kernel• Predictable synchronization mechanism• Predictable and bounded interrupt

latency

Page 18: Real-Time Operating Systems

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

Page 19: Real-Time Operating Systems

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

Page 20: Real-Time Operating Systems

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

Page 21: Real-Time Operating Systems

Real-time Linux

CASE STUDY

Page 22: Real-Time Operating Systems

CASE: Real-time Linux Linux is not a Real-Time OS

Hardware(CPU, Memory, Disks, etc)

Linux LinuxProcess

LinuxProcess

LinuxProcess

OOPS!

Page 23: Real-Time Operating Systems

CASE: Real-time Linux (1) FSMLab’s RTLinux

RTOS

Hardware(CPU, Memory, Disks, etc)

RTThread

RTThread

RTThread(Linux)

Linux LinuxProcess

LinuxProcess

FixedPriority

Scheduler

LowestPriority

Page 24: Real-Time Operating Systems

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

Page 25: Real-Time Operating Systems

CASE: Real-time Linux (2) MontaVista’s Preemptive Kernel• 2.4 Linux kernel is

not preemptive− Higher priority

task should be suspended

Page 26: Real-Time Operating Systems

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

Page 27: Real-Time Operating Systems

The End