RTO1.pptx

download RTO1.pptx

of 42

Transcript of RTO1.pptx

  • 7/30/2019 RTO1.pptx

    1/42

    Real Time Operating System

    1

  • 7/30/2019 RTO1.pptx

    2/42

    Comparison with conventional

    OSGPOSGeneral purpose OS

    Too costly for embedded

    applications

    Increased demand onRT functionality

    Windows NT, 2K,

    XP,

    Solaris, IBM AIX, HP-

    UX Linux

    Etc

    RTOSRealtime OS

    Embedded applicationsIndustrial robots, spacecraft,industrial control, flight control,and scientific research equipmentHigh degree of configurability andextensibility required

    Linux? RT Linux VxWorks Windows CE QNX LynxOS RTEMS OS-9

    2

  • 7/30/2019 RTO1.pptx

    3/42

    Comparison with conventional

    OSRT systems require specific support from OSConventional OS kernels are inadequate w.r.t. RTrequirements

    Multitasking/scheduling provided through system calls does not take time into account (introduce unboundeddelays)

    Interrupt management achieved by setting interrupt priority > than process priority increase system reactivity but may cause unboundeddelays on process execution even due to unimportant interrupts

    Basic IPC and synchronization primitives may causepriority inversion (high priority task blocked by alow priority task)

    No concept of RT clock/deadline

    3

    Goal: Minimal Response Time

  • 7/30/2019 RTO1.pptx

    4/42

    Real-Time Operating Systems

    Definition Systems whose correctness depends on theirtemporal aspects as well as their functionalaspects

    A system is said to be Real Time if it isrequired to complete its work & deliver itsservices on time.

    Performance measure

    Timeliness on timing constraints (deadlines) Speed/average case performance are lesssignificant.

    Key property Predictability on timing constraints

    4

  • 7/30/2019 RTO1.pptx

    5/42

    Features of Real-Time Operating

    Systems

    Timeliness OS has to provide mechanisms for

    time management handling tasks with explicit time constraints

    Achieved through properscheduling

    algorithms Core of an RTOS! Predictability

    to guarantee in advance the deadlinesatisfaction

    to notify when deadline cannot be guaranteed Affected by several issues such as

    characteristics of the processor (pipelinig,cache, DMA, ...), I/O & interrupts, Synchronization &IPC, Architecture, Memory management, Applicationsand Scheduling!

    5

  • 7/30/2019 RTO1.pptx

    6/42

    Features of RTOS: Services

    SchedulingResource AllocationInterrupt handling: Interrupt Latency should be verysmall

    Kernel has to respond to real time events Interrupts should be disabled for minimum possible

    timeFor embedded applications Kernel Size should besmall

    Should fit in ROMSophisticated features can be removed

    No Virtual Memory No Protection

    Fault tolerance HW/SW failures must not cause a crash Design for peak load

    All scenarios must be considered

    6

  • 7/30/2019 RTO1.pptx

    7/42

    Characteristics of Real Time

    Operating Systems

    Large and complex OR small and embedded Vary from a few hundred lines of assembler or Cto millions of lines of lines of high-level language code Concurrent control of separate system

    components Devices operate in parallel in the real-world, hence,better to model this parallelism by concurrent entities in theprogram

    Facilities to interact with special purpose

    hardware Need to be able to program devices in a reliableand abstract way

    7

  • 7/30/2019 RTO1.pptx

    8/42

    Characteristics of Real Time

    Operating SystemsExtreme reliability and safety

    Embedded systems typically control the environment inwhich they operate

    Failure to control can result in loss of life, damage toenvironment or economic loss

    Guaranteed response times We need to be able to predict with confidence the worst caseresponse times for systems

    Efficiency is important but predictability is essential In RTS, performance guarantees are:

    Task- and/or class centric Often ensured a priori

    In conventional systems, performance is: System oriented and often throughput oriented Post-processing ( wait and see )

    8

  • 7/30/2019 RTO1.pptx

    9/42

    Structure of Real time systems

    9

  • 7/30/2019 RTO1.pptx

    10/42

  • 7/30/2019 RTO1.pptx

    11/42

    Tasks in RTOS (2)

    Task : a sequence of similar jobs Periodic task (p,e)

    Its jobs repeat regularly

    Periodp = inter-release time (0

  • 7/30/2019 RTO1.pptx

    12/42

    Performance measures, estimating

    program runtimes

    Completion ratio / miss ration

    Maximize total usefulness value

    (weighted sum)

    Maximize value of a taskMinimize lateness

    Minimize error (imprecise tasks)

    Feasibility (all tasks meet their deadlines)

    12

  • 7/30/2019 RTO1.pptx

    13/42

    Performance metric: Response

    Time

    Response time Duration from released time to finish time

    13

    (4,1)

    (5,2)

    (10,2)

    5

    5

    10

    10 15

    15

    T1

    T2

    T3

  • 7/30/2019 RTO1.pptx

    14/42

    Performance metric: Response

    Time

    Response time Duration from released time to finish time

    14

    (4,1)

    (5,2)

    (10,2)

    Response Time of T3

    5

    5

    10

    10 15

    15

    T1

    T2

    T3

  • 7/30/2019 RTO1.pptx

    15/42

    Task assignment

    Cyclic executive schedulingCooperative scheduling

    scheduler relies on the current process to give upthe CPU before it can start the execution of anotherprocess

    A static priority-driven schedulercan preemptthe current process to start a new process.Priorities are set pre-execution

    E.g., Rate-monotonic scheduling (RMS), DeadlineMonotonic scheduling (DM)

    A dynamic priority-driven scheduler can assign,and possibly also redefine, process priorities atrun-time.

    E.g., Earliest Deadline First (EDF), Least LaxityFirst (LLF)

    15

  • 7/30/2019 RTO1.pptx

    16/42

    Scheduling in RTOS : Deadlines

    Hard deadline Disastrous or very serious consequences may occur ifthe deadline is missed Validation is essential : can all the deadlines be met,even under worst-case scenario?

    Deterministic guarantees

    Soft deadline Ideally, the deadline should be met for maximumperformance. The performance degrades in case ofdeadline misses.

    Best effort approaches Statistical guarantees

    16

  • 7/30/2019 RTO1.pptx

    17/42

    Schedulability

    Property indicating whether a real-time

    system (a set of real-time tasks) can meet

    their deadlines

    17

    (4,1)

    (5,2)

    (7,2)

  • 7/30/2019 RTO1.pptx

    18/42

    Real-Time Scheduling

    Determines the order of real-time task

    executions

    Static-priority scheduling

    Dynamic-priority scheduling

    18

    (4,1)

    (5,2)

    (7,2)

    5

    5

    10

    10 15

    15

  • 7/30/2019 RTO1.pptx

    19/42

    RM (Rate Monotonic)

    Optimal static-priority scheduling

    It assigns priority according to period

    A task with a shorter period has a higher priority

    Executes a job with the shortest period

    19

    (4,1)

    (5,2)

    (7,2)

    5

    5

    10

    10 15

    15

    T1

    T2

    T3

  • 7/30/2019 RTO1.pptx

    20/42

    RM (Rate Monotonic)

    Executes a job with the shortest period

    20

    (4,1)

    (5,2)

    (7,2)

    5

    5

    10

    10 15

    15

    T1

    T2

    T3

  • 7/30/2019 RTO1.pptx

    21/42

    RM (Rate Monotonic)

    Executes a job with the shortest period

    21

    (4,1)

    (5,2)

    (7,2)

    Deadline Miss !

    5

    5

    10

    10 15

    15

    T1

    T2

    T3

  • 7/30/2019 RTO1.pptx

    22/42

    EDF (Earliest Deadline First)

    Optimal dynamic priority scheduling

    A task with a shorter deadline has a higher

    priority

    Executes a job with the earliest deadline

    22

    (4,1)

    (5,2)

    (7,2)

    5

    5

    10

    10 15

    15

    T1

    T2

    T3

  • 7/30/2019 RTO1.pptx

    23/42

    EDF (Earliest Deadline First)

    Executes a job with the earliest deadline

    23

    (4,1)

    (5,2)

    (7,2)

    5

    5

    10

    10 15

    15

    T1

    T2

    T3

  • 7/30/2019 RTO1.pptx

    24/42

    EDF (Earliest Deadline First)

    Executes a job with the earliest deadline

    24

    (4,1)

    (5,2)

    (7,2)

    5

    5

    10

    10 15

    15

    T1

    T2

    T3

  • 7/30/2019 RTO1.pptx

    25/42

    EDF (Earliest Deadline First)

    Executes a job with the earliest deadline

    25

    (4,1)

    (5,2)

    (7,2)

    5

    5

    10

    10 15

    15

    T1

    T2

    T3

  • 7/30/2019 RTO1.pptx

    26/42

    EDF (Earliest Deadline First)

    Optimal scheduling algorithm if there is a schedule for a set of real-time

    tasks,

    EDF can schedule it.

    26

    (4,1)

    (5,2)

    (7,2)

    5

    5

    10

    10 15

    15

    T1

    T2

    T3

  • 7/30/2019 RTO1.pptx

    27/42

    EDF Overload Conditions

    Domino effect during overload conditions Example: T1(4,3), T2(5,3), T3(6,3), T4(7,3)

    27

    T1

    50 7

    T2 T3 T4

    3 6

    Deadline Miss !

    T1

    50 7

    T3

    3 6

    Better schedules :

    T1

    50 7

    T4

    3 6

  • 7/30/2019 RTO1.pptx

    28/42

    RM vs. EDF

    Rate Monotonic Simpler implementation, even in systemswithout explicit support for timing constraints(periods, deadlines)

    Predictability for the highest priority tasks

    EDF Full processor utilization

    Misbehavior during overload conditions

    28

  • 7/30/2019 RTO1.pptx

    29/42

    Priority(P1) > Priority (P2) P1, P2 share a critical section (CS) P1 must wait until P2 exits CS even if P(P1) > P(P2) Maximum blocking time equals the time needed by P2 to execute its CS

    It is a direct consequence of mutual exclusionIn general the blocking time cannot be bounded by CS of the lower priorityprocess

    29

  • 7/30/2019 RTO1.pptx

    30/42

    Priority inversion (2)

    Typical characterization of priority inversion A medium-priority task preempts a lower-priority task which

    is using a shared resource on which a higher priority task is

    blocked

    If the higher-priority task would be otherwise ready to run,

    but a medium-priority task is currently running instead, a priority

    inversion is said to occur

    30

  • 7/30/2019 RTO1.pptx

    31/42

    Priority Inheritance

    Basic protocol [Sha 1990]1.A job Juses its assigned priority, unless it is in its CS and blockshigher priority jobs In which case, Jinherits PH, the highest priorityof the jobs blocked by JWhen Jexits the CS, it resumes thepriority it had at the point of entry into the CS2.Priority inheritance is transitive

    AdvantageTransparent to schedulerDisadvantageDeadlock possible in the case of bad use of semaphoresChained blocking: if P accesses n resources locked by processeswith lower priorities, P must wait for n CS

    31

  • 7/30/2019 RTO1.pptx

    32/42

    Priority Inheritance (2)

    32

  • 7/30/2019 RTO1.pptx

    33/42

    Priority Inheritance (3)

    33

    Deadlocks

  • 7/30/2019 RTO1.pptx

    34/42

    Priority Inheritance (4): ChainedBlocking

    A weakness of the priority inheritance protocol is that it does not preventchained blocking.Suppose a medium priority thread attempts to take a mutex owned by alow priority thread, but while the low priority thread's priority is elevated tomedium by priority inheritance, a high priority thread becomes runnable andattempts to take another mutex already owned by the medium prioritythread. The medium priority thread's priority is increased to high, but the

    high priority thread now must wait for both the low priority thread and themedium priority thread to complete before it can run again.The chain of blocking critical sections can extend to include the criticalsections of any threads that might access the same mutex. Not only doesthis make it much more difficult for the system designer to computeoverhead, but since the system designer must compute the worst caseoverhead, the chained blocking phenomenon may result in a much less

    efficient system.These blocking factors are added into the computation time for tasks in theRMA analysis, potentially rendering the system unschedulable.

    34

  • 7/30/2019 RTO1.pptx

    35/42

    Priority Ceiling

    In priority ceiling protocol, each resource is assigned apriority ceiling, which is a priority equal to the highestpriority of any task which may lock the resource.A task T is allowed to enter a critical section only if itsassigned priority is higher than the priority ceilings of all

    semaphores currently locked by tasks other than T.Task T runs at its assigned priority unless it is in acritical section and blocks higher priority tasks.When a task exits the critical section it resumes thepriority it had at the point of entry into the critical section.Prevents Deadlocks and Chained Blocking

    35

  • 7/30/2019 RTO1.pptx

    36/42

    Priority Ceiling (2)

    36

    p0>p1>p2

  • 7/30/2019 RTO1.pptx

    37/42

    Intertask Communication &

    Synchronization

    These services makes it possible topass information from one task to

    another without information ever beingdamaged.

    Makes it possible for tasks tocoordinate & productively cooperatewith each other.

    37

  • 7/30/2019 RTO1.pptx

    38/42

    Inter-Task communication &

    Synchronization

    The most important communication b/w tasks in an OS isthe passing of data from one task to another.

    If messages are sent more quickly than they can behandled, the OS provides message queues for holding themessages until they can be processed.

    38

    Message

    Producer Task

    Message

    Receiver Task

  • 7/30/2019 RTO1.pptx

    39/42

  • 7/30/2019 RTO1.pptx

    40/42

    Message passing in RTOS

    In RTOS, the OS copies a pointer to the message,delivers the pointer to the message-receiver task,and then deletes the copy of the pointer withmessage-sender task.

    40

    Message Sender

    Task

    RAM

    Message Receiver

    TaskRTOS

    msg_ptr

    msg_ptr

    Message Message

    Classification (based on

  • 7/30/2019 RTO1.pptx

    41/42

    Classification (based onarchitectures) and applications of

    various RTOSRTOS for small footprint, mobile and connecteddevices The real-time features ofWindows CE 3.0, a high lymodular real-time embedded OS for small footprint, mobile32-bit intelligent connected devices.

    RTOS for complex, hard real-time applications LynxOS , a POSIX-compatible, multiprocess,multithreaded OS designed for complex real-timeapplications that require fast and deterministic response.

    General purpose RTOS in the embedded industry VxWorks, the most widely adopted RTOS in the

    embedded industry. VxWorks is a flexible, scalable RTOSwith over 1800 APIs and is available on all popular CPUplatforms.

    41

    Classification (based on

  • 7/30/2019 RTO1.pptx

    42/42

    Classification (based onarchitectures) and applications of

    various RTOSRTOS for the Java Platform The Jbed RTOS package is a real-time capable virtualmachine developed for embedded systems and Internetapplications under the Java platform.

    Objected-oriented RTOS

    pSOSystem is a modular object-oriented operatingsystem. The objects in pSOS include tasks, memoryregions, message queues, and semaphores.

    Real-time features in general purpose OS Adding real-time features to common general purposeoperating systems viz., Windows NT and UNIX.

    Research real-time kernels: Real-time kernels such as Spring and Arx are used forongoing research on RTOS