135
Real-Time Operating Systems

RTOS Concepts

  • Upload
    pranati

  • View
    268

  • Download
    2

Embed Size (px)

Citation preview

Page 1: RTOS Concepts

Real-Time Operating Systems

Page 2: RTOS Concepts

What is RTOS?• A RTOS (Real-Time Operating System)

– Is an Operating Systems 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

Page 3: RTOS Concepts

Real Time System

• A system is said to be Real Time if it is required to complete it’s work & deliver it’s services on time.

• Example – Flight Control System– All tasks in that system must execute on time.

• Non Example – PC system

Page 4: RTOS Concepts

GPOS

(GENERAL PURPOSE OPERATING SYSTEMS) RTOS

Time No time bound processing, task has not got any time limit to finish work.

time bound processing, task has to complete work within given time

frame. Deterministic behavior

Memory Architecture

Full virtual memory /Monolithic architecture

Flat memory architecture

Size/latency GPOS are non scalable and has larger footprint and higher context switch latency.

RTOS are scalable and has smaller footprint and low context switch latency and interrupt latency.

Scheduling round robin way of scheduling. priority preemptive scheduling preemption is a must feature

Memory Tight memory constraints are not considered. it is not light-weight.

should not take up too much memory since embedded systems come with tight memory constraints

priority Priority consideration for each task is not as strict as RTOS

Each task must have a priority

Page 5: RTOS Concepts

RTS• Tasks or processes attempt to control or react to

events that take place in the outside world

• These events occur in “real time” and process must be able to keep up with them

Page 6: RTOS Concepts

Examples of RTS• ATM machine updating database• Control of laboratory experiments• Process control plants• Robotics• Air traffic control• Telecommunications• Military command and control systems

Page 7: RTOS Concepts

Engine control system-A real time system

Page 8: RTOS Concepts

Engine control system-A real time system

Page 9: RTOS Concepts

Why an RTOS?

Page 10: RTOS Concepts

Why an RTOS?

Page 11: RTOS Concepts

Role of an OS in Real Time Systems

• Standalone Applications– Often no OS involved– Micro controller based Embedded Systems

• Some Real Time Applications are huge & complex– Multiple threads– Complicated Synchronization Requirements– Filesystem / Network / Windowing support– OS primitives reduce the software design time

Page 12: RTOS Concepts

Characteristics of RTOS• Deterministic

– Operations are performed at fixed, predetermined times or within predetermined time intervals

– Concerned with how long the operating system delays before acknowledging an interrupt

Page 13: RTOS Concepts

Characteristics of RTOS• Responsiveness

– How long, after acknowledgment, it takes the operating system to service the interrupt

– Includes amount of time to begin execution of the interrupt

– Includes the amount of time to service the interrupt

Page 14: RTOS Concepts

Characteristics of RTOS• User control

– User specifies priority

– Specify paging

– What processes must always reside in main memory

– Disks algorithms to use

– Rights of processes

Page 15: RTOS Concepts

Characteristics of RTOS• Reliability

– Degradation of performance may have catastrophic consequences

– Attempt either to correct the problem or minimize its effects while continuing to run

– Most critical, high priority tasks execute

Page 16: RTOS Concepts

Features of RTOS• Fast context switch• Small size(kernel should fit within ROM)• Ability to respond to external interrupts quickly• Multitasking with interprocess communication tools such as

semaphores, signals, and events• Use of special sequential files that can accumulate data at a

fast rate• Preemptive scheduling based on priority (scheduling)• Delay tasks for fixed amount of time • Special alarms and timeouts.• Resource allocation

Page 17: RTOS Concepts

Types of Real-Time Systems• Hard Real-Time

– Missing a deadline has catastrophic results for the system

• Soft Real-Time– Reduction in system quality is acceptable– Deadlines may be missed and can be recovered from

• Non Real-Time– No deadlines have to be met

Page 18: RTOS Concepts

Examples• Soft real time e.g.

– “this flight is on time 98 times out of 100”

• Hard real time e.g.– “The emergency valve opens within 20

microsecond after this event occurs, irrespective of system load.”

– “this parachute automatically opens without fail when you reach 500 feet above ground.”

Page 19: RTOS Concepts

Soft Real Time• Good average case performance

• Low deviation from average –case performance

• Temporally speaking: soft real time systems are statistically predictable, but a single event is neither predictable nor guaranteed.

• soft real time systems are not suited for handling mission critical events.

• Soft real-time systems are typically used where there is some issue of concurrent access and the need to keep a number of connected systems up to date with changing situation.

• software that maintains and updates the flight plans for commercial airliners. The flight plans must be kept reasonably current but can operate to a latency of seconds.

• Live audio-video systems are also usually soft real-time; violation of constraints results in degraded quality, but the system can continue to operate.

Page 20: RTOS Concepts

Hard Real Time• Predictable performance at each moment of time, not as

“average”

• Low Latency response to events

• Precise scheduling of periodic tasks

• No real time event is ever missed

• System response is load-independent

• e.g. RTLinux, QNX, ECOS, VxWORKS....

Page 21: RTOS Concepts

RTOS Concepts

Page 22: RTOS Concepts

Critical Section of Code

• A critical section of code, also called a critical region, is code that needs to be treated indivisibly. Once the section of code starts executing, it must not be interrupted. To ensure this, interrupts are typically disabled before the critical code is executed and enabled when the critical code is finished.

Page 23: RTOS Concepts

Critical Sections

Page 24: RTOS Concepts

Resource

• A resource is any entity used by a task. • A resource can be an I/O device such as a

printer, a keyboard, a display, or a variable, a structure, an array, etc.

Page 25: RTOS Concepts

Shared Resource

• A shared resource is a resource that can be used by more than one task. Each task should gain exclusive access to the shared resource to prevent data corruption. This is called Mutual Exclusion

Page 26: RTOS Concepts

Multitasking

• Multitasking is the process of scheduling and switching the CPU (Central Processing Unit) between several tasks; a single CPU switches its attention between several sequential tasks.

Page 27: RTOS Concepts

Task

Page 28: RTOS Concepts

Task

• A task, also called a thread, is a simple program that thinks it has the CPU all to itself.

• The design process for a real-time application involves splitting the work to be done into tasks which are responsible for a portion of the problem.

• Each task is assigned a priority, its own set of CPU registers, and its own stack area

Page 29: RTOS Concepts
Page 30: RTOS Concepts

State Diagram• Task states

RunningReadyDormant ISR

Waiting

task create

task delete

task start

task is preempted

interrupt

intExit

task resume

tasksuspend

task delete

task delete

Ready

Running

Blocked

Page 31: RTOS Concepts

Priority

Page 32: RTOS Concepts

Task Priority

• Static Priorities:• Task priorities are said to be static when the

priority of each task does not change during the application's execution.

• Each task is thus given a fixed priority at compile time. All the tasks and their timing constraints are known at compile time in a system where priorities are static.

Page 33: RTOS Concepts

• Dynamic Priorities• Task priorities are said to be dynamic if the

priority of tasks can be changed during the application's execution; each task can change its priority at run-time. This is a desirable feature to have in a real-time kernel to avoid priority inversion problem.

Page 34: RTOS Concepts

Priority Inversion Problem• Priority inversion is an undesirable situation in

which a higher priority task gets blocked (waits for CPU) for more time than that it is supposed to, by lower priority tasks.

• Example:• Let T1 , T2 , and T3 be the three periodic tasks with

decreasing order of priorities. • Let T1 and T3 share a resource “S”.

Page 35: RTOS Concepts
Page 36: RTOS Concepts

• T3-lock on semaphore S enters critical section• T1 ready-preempts T3-T1 tries to lock semaphore S-

locked by T3-T1 is blocked• T2 ready-preempts T3 while T3 is in critical section• T1(high priority) is blocked for longer duration of

time as T2 got executed in between

Page 37: RTOS Concepts

Priority Inversion -- Example• T3 obtains a lock on the semaphore S and enters its critical

section to use a shared resource.

• T1 becomes ready to run and preempts T3. Then, T1 tries to enter its critical section by first trying to lock S. But, S is already locked by T3 and hence T1 is blocked.

• T2 becomes ready to run. Since only T2 and T3 are ready to run, T2 preempts T3 while T3 is in its critical section.

• Ideally, one would prefer that the highest priority task (T1) be blocked no longer than the time for T3 to complete its critical section. However, the duration of blocking is, in fact, unpredictable because task T2 got executed in between.

Page 38: RTOS Concepts

• Dynamic Priorities• Task priorities are said to be dynamic if the

priority of tasks can be changed during the application's execution; each task can change its priority at run-time. This is a desirable feature to have in a real-time kernel to avoid priority inversion problem.

Page 39: RTOS Concepts

Priority Inheritance Protocol• Priority inheritance protocol solves the problem of priority

inversion.

• Under this protocol, if a higher priority task TH is blocked by a lower priority task TL, because TL is currently executing critical section needed by TH, TL temporarily inherits the priority of TH.

• When blocking ceases (i.e., TL exits the critical section), TL resumes its original priority.

• Unfortunately, priority inheritance may lead to deadlock.

Page 40: RTOS Concepts
Page 41: RTOS Concepts

Priority Inheritance Protocol – Deadlock• Assume T2 > T1 (i.e., T2 has high priority)

Page 42: RTOS Concepts

Deadlock

• If task T1 has exclusive access to resource R1 and task T2 has exclusive access to resource R2, then

• if T1 needs exclusive access to R2 and T2 needs exclusive access to R1, neither task can continue. They are deadlocked. The simplest way to avoid a deadlock is for tasks to:

• a) acquire all resources before proceeding,• b) acquire the resources in the same order, and• c) release the resources in the reverse order.

Page 43: RTOS Concepts

Deadlock

• Avoiding deadlock conditions requires careful attention to the way in which multiple tasks share semaphores and other RTOS resources.

• Deadlock conditions don't always show up easily during software testing.

Page 44: RTOS Concepts

Memory• The fundamental requirement for memory in a

real-time system is that its access time should be bound (or in other words predictable).

• As a direct consequence, the use of demand paging (swapping pages to disk) is prohibited for real-time processes.

• This is why systems providing a virtual memory mechanism should have the ability to “lock” the process into the main memory so swapping will not occur (Swapping is a mechanism that cannot be made predictable.)

Page 45: RTOS Concepts

Memory• Virtual memory is another technique that cannot be

made predictable, and therefore should notbe used in real-time systems.

• A simple solution is to allocate all memory for all objects you need during the life of the system and never de-allocate them.

• Another solution is always to allocate and de-allocate blocks of memory with a fixed size.

(Introducing internal fragmentation = never using some parts of memory internal to the blocks).

Page 46: RTOS Concepts

Memory Management

Page 47: RTOS Concepts

Memory• Static memory allocation

– All memory allocated to each process at system startup

• Expensive• Desirable solution for Hard-RT systems

• Dynamic memory allocation– Memory requests are made at runtime

• Should know what to do upon allocation failure• Some RTOSs support a timeout function

Page 48: RTOS Concepts

Memory

• In HRT static memory allocation is used.

• In SRT you have the option of dynamic memory allocation, no virtual memory, and no compaction.

• In non-RT you may want virtual memory and compaction.

Page 49: RTOS Concepts

Memory Requirements

• A minimal kernel for an 8-bit CPU that provides only scheduling, context switching, semaphore management, delays, and timeouts should require about 1 to 3 Kbytes of code space.

• Code space needed when a kernel is used.• Application code size + Kernel code size

Page 50: RTOS Concepts

Context Switch (or Task Switch)

• When a multitasking kernel decides to run a different task, it simply saves the current task's context (CPU registers) in the current task's context storage area – it’s stack Once this operation is performed, the new task's

• context is restored from its storage area and then resumes execution of the new task's code. This process is called a context switch or a task switch.

Page 51: RTOS Concepts

Context Switches

Page 52: RTOS Concepts

Example PIC24F

Page 53: RTOS Concepts

Kernel

• The kernel is the part of a multitasking system responsible for the management of tasks (that is, for managing the CPU's time) and communication between tasks. The fundamental service provided by the kernel is context switching.

• The use of a real-time kernel will generally simplify the design of systems by allowing the application to be divided into multiple tasks managed by the kernel.

• A kernel can allow you to make better use of your CPU by providing you with indispensible services such as

• semaphore management, queues, time delays etc.

Page 54: RTOS Concepts

Scheduling

Page 55: RTOS Concepts

Scheduling Tasks

Page 56: RTOS Concepts

Scheduler

• The scheduler, also called the dispatcher, is the part of the kernel responsible for determining which task will run next.

• Most real-time kernels are priority based. Each task is assigned a priority based on its importance. The priority for each task is application specific. In a priority-based kernel, control of the CPU will always be given to the highest priority task ready-to-run. When the highest-priority task gets the CPU, however, is determined by the type of kernel used.

• There are two types of priority-based kernels: • non-preemptive and preemptive.

Page 57: RTOS Concepts

Non-Preemptive Kernel

• Non-preemptive kernels require that each task does something to explicitly give up control of the CPU.

• Non-preemptive scheduling is also called• cooperative multitasking, tasks cooperate

with each other to share the CPU. This is done to maintain illusion of concurrency.

Page 58: RTOS Concepts

Co-Operative MultitaskingTasks execute until they pause or yield Tasks execute until they pause or yield- Must be written to explicitly yield.- System performance can be optimized Tasks can be given priorities

Page 59: RTOS Concepts

Pre-emptive Multitasking

Page 60: RTOS Concepts

Priority

Page 61: RTOS Concepts

Round Round-Robin Scheduling

Page 62: RTOS Concepts

Round Robin Scheduling

• When two or more tasks have the same priority, the kernel will allow one task to run for a predetermined amount of time, called a quantum, and then selects another task. This is also called time slicing. The kernel gives control to the next task in line if:

• a) the current task doesn't have any work to do during its time slice or

• b) the current task completes before the end of its time slice.

Page 63: RTOS Concepts

Priority-based Pre-emptive emptive Multi-tasking

Page 64: RTOS Concepts

Non-Preemptive Kernel

• Asynchronous events are still handled by• ISRs• An ISR can make a higher priority task ready

to run, but the ISR always returns to the interrupted task. The new higher priority task will gain control of the CPU only when the current task gives up the CPU.

Page 65: RTOS Concepts
Page 66: RTOS Concepts

advantages of a non-preemptive kernel

• interrupt latency is typically low• lesser need to guard shared data through the

use of semaphores.• Each task owns the CPU and you don't have to

fear that a task will be preempted.• semaphores should still be used. Shared I/O

devices may still require the use of mutual exclusion semaphores; for example, a task might still need exclusive access to a printer.

Page 67: RTOS Concepts

drawback of a non-preemptive kernel

• responsiveness• A higher priority task that has been made• ready to run may have to wait a long time to

run, because the current task must give up the CPU when it is ready.

Page 68: RTOS Concepts

Preemptive Kernel

• A preemptive kernel is used when system responsiveness is important

• The highest priority task ready to run is always given control of the CPU.

• If an ISR makes a higher priority task ready, when the ISR completes, the interrupted task is suspended and the new higher priority task is resumed.

• With a preemptive kernel, execution of the highest priority task is deterministic

Page 69: RTOS Concepts
Page 70: RTOS Concepts

Reentrancy

• A reentrant function is a function that can be used by more than one task without fear of data corruption. A reentrant

• function can be interrupted at any time and resumed at a later time without loss of data. Reentrant functions either use

• local variables (i.e., CPU registers or variables on the stack) or protect data when global variables are used.

Page 71: RTOS Concepts

copies of the arguments to strcpy() are placed on the task's stack, strcpy() can be invoked by multiple tasks without fear that the tasks will corrupt each other's pointers.

Page 72: RTOS Concepts

Non-Reentrant function

Page 73: RTOS Concepts
Page 74: RTOS Concepts

• The programmer intended to make swap() usable by any task. Figure 2-6 shows what could happen if a low priority task is interrupted while swap() F2-6(1) is executing. Note that at this point Temp contains 1. The ISR makes the higher priority task ready to run, and thus, at the completion of the ISR F2-6(2), the kernel (assuming µC/OS-II) is invoked to switch to this task F2-6(3). The high priority task sets Temp to 3 and swaps the contents of its variables correctly (that is, z is 4 and t is 3). The high priority task eventually relinquishes control to the low priority task

• F2-6(4) by calling a kernel service to delay itself for 1 clock tick (described later). The lower priority task is thus

• resumed F2-6(5). Note that at this point, Temp is still set to 3! When the low-priority task resumes execution, it sets y

• to 3 instead of 1.

Page 75: RTOS Concepts

Assigning Task Priorities

• An interesting technique called Rate Monotonic Scheduling (RMS) has been established to assign task priorities based on how often tasks execute. Simply put, tasks with the highest rate of execution are given the highest priority.

Page 76: RTOS Concepts

RMS makes a number of assumptions

• 1. All tasks are periodic (they occur at regular intervals).

• 2. Tasks do not synchronize with one another, share resources, or exchange data.

• 3. The CPU must always execute the highest priority task that is ready to run. In other words, preemptive scheduling must be used.

Page 77: RTOS Concepts

Rate Monotonic Scheduling• Promising method of scheduling for

periodic tasks

• Assign priorities based on their periods

• Task with the shortest period has the highest priority

Page 78: RTOS Concepts

Periodic Task Timing

Page 79: RTOS Concepts

RMS • Suppose we have n tasks with a fixed

period and computation time, so to meet all possible deadlines following expression must hold:

• Sum of the processor utilization cannot exceed 1 that is the maximum utilization of processor, this is infact for a perfect scheduling algorithm.

• For practical reasons this bound is less than 1, for RMS it is:--- + .... + --- < U(n) = n(2 - 1)

C1 Cn 1/ n

T1 Tn

Page 80: RTOS Concepts

RMS

Theorem (RMA Bound) Any set of n periodic tasks is RM-schedulable if the processor utilization, U, is no greater

than 1

2 1nn

.

This means that whenever U is at or below the given utilization bound, a schedule can be constructed with RM. In the limit when the number of tasks n , the maximum utilization limit is

1

lim 2 1 ln 2 0.69n

nn

Page 81: RTOS Concepts

RMS Example• Example: • Task P1: C1 = 20, T1 = 100,

U1 = 20/100 = 0.2• Task P2: C2 = 40, T2 = 150,

U2 = 40/150 = 0.267• Task P3: C3 = 100, T3 = 350,

U3 = 100/350 = 0.286• Total Utilization: =0.753

Page 82: RTOS Concepts

Deadline Scheduling• Real time is not just about sheer speed

• It is the completion of a task at a specified time, not early neither late.

Page 83: RTOS Concepts

Types of RT Tasks

• An aperiodic real time task is the one which has a dead line by that it must finish or start, or may have constraints on both start and finish.

• A periodic real time task is the one which has a dead line once every period ”T” or exactly ”T” units apart

Page 84: RTOS Concepts

Example Periodic Tasks• Consider an example of scheduling

periodic tasks with completion deadlines, system collects and processes data from two sensors A and B.

• Deadline for A to collect data is 20 ms and 50 ms for B.

• A takes 10 ms to process the sample including operating system overhead and B takes 25 ms.

Page 85: RTOS Concepts

Example Periodic Tasks

Page 86: RTOS Concepts

Example Periodic Tasks

Page 87: RTOS Concepts

Example Aperiodic tasks

Page 88: RTOS Concepts

Example Aperiodic tasks

Page 89: RTOS Concepts

Mutual Exclusion

• The most common methods to obtain exclusive access to shared resources are:

• a) Disabling interrupts• b) Test-And-Set• c) Disabling scheduling• d) Using semaphores

Page 90: RTOS Concepts

Synchronization

• A task can be synchronized with an ISR, or another task when no data is being exchanged, by using a semaphore

• A task initiates an I/O operation and then waits for the semaphore.

• When the I/O operation is complete, an ISR (or another task) signals the semaphore and the task is resumed.

• the semaphore is drawn as a flag, to indicate that it is used to signal the occurrence of an event

Page 91: RTOS Concepts
Page 92: RTOS Concepts
Page 93: RTOS Concepts

• When the first task reaches a certain point, it signals the second task and then waits for a signal from the second task.

• Similarly, when the second task reaches a certain point, it signals the first task and then waits for a signal from the first task At this point, both tasks are synchronized with each other.

Page 94: RTOS Concepts
Page 95: RTOS Concepts

Events

Page 96: RTOS Concepts

Event Flags

• Event flags are used when a task needs to synchronize with the occurrence of multiple events.

• The task can be synchronized when any of the events have occurred. This is called disjunctive synchronization (logical OR).

• A task can also be synchronized when all events have occurred. This is called conjunctive synchronization (logical AND).

Page 97: RTOS Concepts
Page 98: RTOS Concepts

Intertask Communication

• Message queues• Pipes• Fifos• Mailboxes• Semaphore• Shared memory

Page 99: RTOS Concepts

Inter-task Communication

Page 100: RTOS Concepts

Interrupts

• An interrupt is a hardware mechanism used to inform the CPU that an asynchronous event has occurred. When an interrupt is recognized, the CPU saves part (or all) of its context (i.e. registers) and jumps to a special subroutine called an Interrupt Service Routine, or ISR.

Page 101: RTOS Concepts

Interrupts• RT systems respond to external events

– External events are translated by the hardware and interrupts are introduced to the system

• Interrupt Service Routines (ISRs) handle system interrupts– May be stand alone or part of a device driver

• RTOSs should allow lower level ISRs to be preempted by higher lever ISRs

– ISRs must be completed as quickly as possible

Page 102: RTOS Concepts

Interrupts

Page 103: RTOS Concepts

Interrupts– Interrupt Dispatch Time

• Time the hardware needs to bring the interrupt to the processor

– Interrupt Routine• ISR execution time

– Other Interrupt• Time needed for managing each simultaneous pending

interrupt

– Pre-emption• Time needed to execute critical code during which no pre-

emption may happen

Page 104: RTOS Concepts

Interrupts– Scheduling

• Time needed to make the decision on which thread to run

– Context Switch• Time to switch from one context to another

– Return from System Call• Extra time needed when the interrupt occurred while a system

call was being executed

• System calls cause software interrupts (SWIs)– Portable Operating System Interface (POSIX) defines the

syntax of many of the library calls that execute the SWIs.

Page 105: RTOS Concepts

Interrupt Latency

• the most important specification of a real-time kernel is the amount of time interrupts are disabled.

• All real-time systems disable interrupts to manipulate critical sections of code and re-enable interrupts when the critical

• section has executed. The longer interrupts are disabled, the higher the interrupt latency

Page 106: RTOS Concepts

Interrupt latency.

• Maximum amount of time interrupts are disabled

• +• Time to start executing the first instruction in

the ISR

Page 107: RTOS Concepts

Interrupt Response

• Interrupt response is defined as the time between the reception of the interrupt and the start of the user code which will handle the interrupt. The interrupt response time accounts for all the overhead involved in handling an interrupt.

• Typically, the processor's context (CPU registers) is saved on the stack before the user code is executed.

Page 108: RTOS Concepts

Interrupt Response

• Interrupt latency• +• Time to save the CPU's context

Page 109: RTOS Concepts

Interrupt response, Non-preemptive kernel.

• For a non-preemptive kernel, the user ISR code is executed immediately after the processor's context is saved. The

• response time to an interrupt for a non-preemptive kernel is

• Interrupt latency • +• Time to save the CPU's context

Page 110: RTOS Concepts

Interrupt response, Preemptive kernel.

• For a preemptive kernel, a special function provided by the kernel needs to be called. This function notifies the kernel that an ISR is in progress and allows the kernel to keep track of interrupt nesting.

Page 111: RTOS Concepts

Interrupt response, Preemptive kernel

• Interrupt latency• +• Time to save the CPU's context • +• Execution time of the kernel ISR entry

function

Page 112: RTOS Concepts

Interrupt Recovery

• Interrupt recovery is defined as the time required for the processor to return to the interrupted code.

Page 113: RTOS Concepts

Interrupt recovery, Non-preemptive kernel.

• Time to restore the CPU's context • +• Time to execute the return from interrupt

instruction

Page 114: RTOS Concepts

Interrupt recovery, preemptive kernel.

• Time to determine if a higher priority task is ready

• +• Time to restore the CPU's context of the

highest priority task • +• Time to execute the return from interrupt

instruction

Page 115: RTOS Concepts

Interrupt Latency, Response, and Recovery

Page 116: RTOS Concepts

Interrupt latency, response, and recovery(Preemptive kernel)

Page 117: RTOS Concepts

Non-Maskable Interrupts (NMIs)

• Interrupt latency for an NMI.– Time to execute longest instruction +– Time to start executing the NMI ISR

• Interrupt response for an NMI.– Interrupt latency +– Time to save the CPU's context

• Interrupt recovery of an NMI.– Time to restore the CPU's context +– Time to execute the return from interrupt instruction

Page 118: RTOS Concepts

use this feature to pass parameters (i.e. larger variables) to and from the ISR and a task.

Page 119: RTOS Concepts

The total RAM required if the kernel does not support a separate interrupt stack

• Data space needed when a kernel is used.• Application code requirements • +• Data space (i.e. RAM) needed by the kernel • +• SUM(task stacks + MAX(ISR nesting))

Page 120: RTOS Concepts

the kernel supports a separate stack for interrupts

• Data space needed when a kernel is used.• Application code requirements• +• Data space (i.e. RAM) needed by the kernel • +• SUM(task stacks) • +• MAX(ISR nesting)

Page 121: RTOS Concepts

To reduce the amount of RAM needed in an application, carefulness about how you

use each task's stack for• a) large arrays and structures declared locally• to functions and ISRs• b) function (i.e., subroutine) nesting• c) interrupt nesting• d) library functions stack usage• e) function calls with many arguments

Page 122: RTOS Concepts

• This especially the case when running an RTOS and wanting to share relatively small amounts of RAM amongst two or three or four tasks' stacks.

Page 123: RTOS Concepts

• a multitasking system will require more code space (ROM) and data space (RAM)

• The amount of extra ROM depends only on the size of the kernel, and the amount of

• RAM depends on the number of tasks in your system.

Page 124: RTOS Concepts

Advantages and Disadvantages of Real-Time Kernels

• An RTOS allow you to make better use of• your resources by providing you with precious

services such as semaphores, mailboxes, queues, time delays, timeouts

• With a preemptive RTOS, all time-critical events are handled as quickly and as efficiently as possible.

• There are currently about 80+ RTOS vendors. Products are available for 8-, 16-, and 32-bit microprocessors.

• Disdvantage: cost

Page 125: RTOS Concepts

Real-Time Systems Summary

Page 126: RTOS Concepts

When is an RTOS appropriate?

Page 127: RTOS Concepts

Why an RTOS?

Page 128: RTOS Concepts

Why an RTOS?

Page 129: RTOS Concepts

Concepts and Terminology

Page 130: RTOS Concepts

Memory Management

Page 131: RTOS Concepts

RTOS Configuration

Page 132: RTOS Concepts

Example Configuration

Page 133: RTOS Concepts

How to Choose/Factors influencing

Page 134: RTOS Concepts

RTOS Vendors

Page 135: RTOS Concepts

RTOS Vendor Websites