Real Time Operating Systems

1y ago
6 Views
2 Downloads
1.16 MB
36 Pages
Last View : 20d ago
Last Download : 2m ago
Upload by : Oscar Steel
Transcription

Real Time Operating Systemsfrom Fundamentals of Real Time SystemsMukul Shirvaikar & Theodore ElbertChapter 41

Real Time Systems Design Various design approaches implemented by systemdesigners to meet real-time requirements Three general approaches to task scheduling:– ad-hoc scheduling– deterministic scheduling using a cyclic executive– non-deterministic, priority-driven scheduling using amultitasking executive Evolved over time with successively moresophisticated approaches culminating in a full-fledgedreal-time operating system2

Basic Solutions Ad-hoc scheduling is the simplest form of taskscheduling, if it can be called task scheduling at all For straightforward processing with no specificperiodic requirements, it provides satisfactory results– Tasks are functional program units– Dependencies are limited to precedence relationships– Not periodic since repetition is not at precise rate Program may be essentially written as an endless loopwith each task executing to completion in somepredetermined sequence3

Polled-Loop Systems Simplest form of Real-time “kernel”.Used for fast reaction to single eventsDo not require interrupts.Poll devices attached to the system continuouslyKeeps checking for a service request event, which canbe a flag or signal in the software Event flag is typically cleared upon servicing so thatthe system is ready for the next event or “burst”4

Polled-Loop Recipe5

Polled-Loop Systems Simple while loop that executes multiple ‘tasks’. Tasks must not block. Tasks must have a known maximum execution time.loop{/*if (packet here) /*{packet here 0;/*process data(); /*}if (timer event) /*{readCCR();/*process event();/*}}do forevercheck flag*/*/reset flag*/process data */check flag*/resets timer event flag */process event */6

Polled-Loop Systems Dedicated to the status loop, thereby making itimpossible to do other tasks or even enter a “powersaving” or sleep mode Not possible to guarantee that the peripherals will beserviced in the correct order or priority level7

Finite State Machines Allows the system to transition between differentstates System tasks divided into sub-tasks and then a stateassociated with each one Once a sub-task is completed, the program changesthe state Relinquishes control to the main loop which thendecides the next sub-task to perform based upon aswitch statement associated with the designated state8

Finite State Machines States: a set of condition for a machine that exists fora non-trivial amount of time. The meaning of nontrivial is project dependent. Events: a set of actions that occur effectively instantlyin the context of the project FSMs can be used in conjunction with interrupts orpolling to form fairly sophisticated systems9

Finite State Machines ExampleStatesEventsStoppedStart button pressedStartingStart succeededRunningStop button pressedWhat event(s) are missing from this example?10

The Multitasking Executive (RTOS) Embedded systems have a singular purpose. To accomplish this purpose, they may require runningmultiple tasks simultaneously. Tasks must not block, they are called upon repeatedly,they must remember their state. Some tasks are more important than others. Tasks may need to communicate with each other. An RTOS provides the framework to make this allhappen.11

Process vs. Task vs. Thread In contemporary operating systems,– Application is a separately loadable program.– A task or process is a running application.(Windows task manager lets you manage processes) In an embedded system– Process is an executing program. A process has its owndedicated memory space.– Threads are semi-independent tasks that operate under aprocess. Threads share the memory space of the process.Threads can share data structures and variables.– Task Thread12

The Multitasking Executive (RTOS) Sophisticated approach to the task schedulingproblem is a multitasking executive or RTOS An RTOS schedules tasks in real-time based ontheir current priority chosen based on ascheduling strategy or metric The primary function of a multitaskingexecutive is to schedule the tasks for executionin a manner that ensures the meeting ofsystem operational requirements13

The Multitasking Executive (RTOS)14

The Multitasking Executive (RTOS) Task (or tasks if there are multiple processors)with the highest priority will be scheduled forexecution unless the execution of the task isblocked A task is said to be blocked if the current stateof program execution requires that it not beallowed to execute. For example, the task maybe waiting for some lower priority task toprovide it with needed data15

The Multitasking Executive (RTOS) Tasks can be added or deleted or the prioritiesof tasks can be changed without the necessityto change the system or redesign it - greatamount of flexibility Appropriate for systems with– Synchronous requirements– Non-deterministic task execution times (times mayvary over successive executions)– Large asynchronous components16

The Multitasking Executive (RTOS) The core functional component is a softwarecomponent called a multitasking executive In addition to task scheduling it provides otherservices– task synchronization (primitive operations, such assemaphores, and queues)– inter-task communication (signals and mailboxes)– memory management– Modules: device drivers, file system support,networking, protocols17

The Multitasking Executive (RTOS) Task synchronization involves suspension andresumption of a task in accordance with thestatus of other tasks – known as contextswitching The context is the minimal information about atask that must be saved before suspension ofthe task so that it may be resumed at a laterinstant (register contents, I/O, memorymanagement, etc.)18

The Multitasking Executive (RTOS) Stored in protected memory in a data structurecalled the Task Control Block (TCB) or ThreadDefinition Structure (TDS) Context switching takes time that is overheadfrom the viewpoint of the application program.The amount of time required for contextswitching is one of important benchmarks usedto judge the efficiency of a multitaskingexecutive19

The Multitasking Executive (RTOS) Concurrent execution - only an impressionprovided to the user that multiple tasks arerunning at the same time, because a singleprocessor can only implement one task at anyinstant of time Parallel execution - multi-core or multiprocessor configurations and can actuallyexecute tasks in parallel (still concurrent oneach individual processor)20

The Multitasking Executive (RTOS) Concurrent execution - Multiple tasks can be“active” at any instant of time and executesequentially using a simple time-slicing scheme(also known as round-robin scheduling) Alternatively, such context switching can alsobe based on preemption due to priorities orresources.21

The Concurrently Executing Task RTOS must provide for the creation, deletion,preemption and monitoring of tasks or threads The term “thread” is increasingly used insteadof the term “task” to describe a distinctsequence of operations, since the use ofmulticore processors has becomecommonplace over the last few years22

The Concurrently Executing Task Storage space requirements for the context of atask must be specified and provision must bemade for multiple instances of the same task Other properties such as the task identifier andthe task priority must also be maintained It is convenient to maintain such informationabout a task or thread in a data structure orobject - task control block, or TCB or ThreadDefinition Structure (TDS).23

The Concurrently Executing TaskTCB - Task Control Blockstruct osTaskControlBlock {string TASK NAME;uint32 t priorty;char *register save;uint32 t STATE;time t ACTIVATION TIME;}TASK NAME – the name of the taskthat acts as an identifier for startingthe task, suspending the task, orperforming some other operationaffecting the taskACTIVATION TIME – the time instancein the future when the task will beactivatedREGISTER SAVE area – the area wherethe processor register contents arestored upon task suspensionSTATE – the state of the task typicallyrunning (currently has the necessaryresources and is executing)suspended (currently blocked fromexecution awaiting action)ready, (not blocked from execution,but waiting for resources necessaryfor execution)PRIORITY – the priority of the taskwhich may remain fixed or changeduring the system operation based onstatic or dynamic priority assignment24

The Concurrently Executing Task A process state diagram as a partially definedfinite state machineExecutingPreemptedResourceMissingTask withHighest PriorityReadyNo rtedScheduleTaskTerminatedDormant25

Mutex Threads operating in the same memory space haveaccess to the same data structures & resources. A mutex (mutual exclusion object) is an softwareobject used to control access to shared resources. A mutex is created for each resource requiringexclusive access. A thread requests access to the shared resourcebefore using it (it may block) The thread releases the mutex before moving on A mutex is non-recursive26

The System Timer RTOS - one of the most important tasks is tomaintain accurate time (not world time forwhich there are special chips) Rather it is a measure of elapsed time betweenevents Special timer sub-system that can be set tointerrupt the operating system at regularintervals (timer interrupt based on clock)27

The System Timer Typically this value can range from 1ms to100ms (commonly 10ms) The clock tick interrupt can be viewed as thesystem’s heartbeat Granularity – system need vs. overhead The “real-time clock” – supported in hardwareby a peripheral - on or off chip28

The System Timer Most of the modern ARM processor cores– have an additional component on them known asthe “SysTick” timer. Does STM32L4 have one?– Implemented as simple increment or decrementcounters that produce a hardware interrupt orsystem exception that must be handled by the CPU– RTOS treats this exception as high-priority and the“scheduler” part of the RTOS is invoked at this time– It makes decisions about system level issues such aswhich task should run in the next time slice29

Preemptive Scheduling Task “preemption” and is one of the powerfultools that allows the RTOS to meet deadlinesimposed by scheduling constraints Preemption results in the suspension of thecurrently executing task in order to permitanother task to execute (after context switchingof course)30

Preemptive Scheduling31

Preemptive Scheduling Static and dynamic task scheduling algorithmsdo not have guaranteed closed form solutionsunder most normal operating conditions andcan sometimes lead to unpredictable behavior As systems get larger with manyinterdependent parts, it is increasingly difficultto do so, leading to the increasingly prevalentuse of dynamic scheduling with techniquesbased on preemption32

Precedence Constraints One task must complete execution before oneor more of the other tasks can begin execution Add a layer of complexity to the schedulingprocess or algorithms– deterministic schedules - precedence constraintshelp to satisfy task synchronization requirements– non-deterministic schedules - precedenceconstraints implemented with inter-taskcommunication33

Choosing a RTOS The choice of the RTOS is one of the mostimportant decisions made by the systemdesigners. It is very important to review RTOSfeatures before arriving at a choice since it isvery difficult to change it once it has beenmade. This is especially true for products andcompanies that must support their softwarethrough several generations of the product.Software can be difficult to port and test on adifferent RTOS in the future.34

Commercial RTOSVariety of flavors and pricing options FreeRTOS.orgPOSIX (IEEE Standard)AMX (KADAK)C Executive (JMI Software)RTX (CMX Systems)eCos (Red Hat)INTEGRITY (Green HillsSoftware)LynxOS (LynuxWorks)μC/OS-II (Micrium)Neutrino (QNX SoftwareSystems)Nucleus (Mentor Graphics) RTOS-32 (OnTime Software)OS-9 (Microware)OSE (OSE Systems)pSOSystem (Wind River)QNX (QNX Software Systems)Quadros (RTXC)RTEMS (OAR)ThreadX (Express Logic)Linux/RT (TimeSys)VRTX (Mentor Graphics)VxWorks (Wind River)35

CMSIS Model (RTX)CMSIS Cortex Microcontroller Software Interface Standard36

Real Time Operating Systems 1 from Fundamentals of Real Time Systems Mukul Shirvaikar & Theodore Elbert Chapter 4. 2 . The "real-time clock" -supported in hardware by a peripheral - on or off chip. 29 The System Timer Most of the modern ARM processor cores

Related Documents:

1.1 Hard Real Time vs. Soft Real Time Hard real time systems and soft real time systems are both used in industry for different tasks [15]. The primary difference between hard real time systems and soft real time systems is that their consequences of missing a deadline dif-fer from each other. For instance, performance (e.g. stability) of a hard real time system such as an avionic control .

Introduction to Real-Time Systems Real-Time Systems, Lecture 1 Martina Maggio and Karl-Erik Arze n 21 January 2020 Lund University, Department of Automatic Control Content [Real-Time Control System: Chapter 1, 2] 1. Real-Time Systems: De nitions 2. Real-Time Systems: Characteristics 3. Real-Time Systems: Paradigms

Operating Systems, Embedded Systems, and Real-Time Systems Janez Puhan Ljubljana, 2015. CIP-CatalogingInPublication NationalandUniversityLibrary,Ljubljana 004.451(078.5)(0.034.2) PUHAN,Janez,1969-Operating Systems, Embedded Systems, and Real-Time Systems [Electronic

computing operating systems and real-time operating systems is the need for " deterministic " timing behavior in the real-time operating systems. Formally, "deterministic" timing means that operating system services consume only known and expected amounts of time. In theory, these service times could be expressed as mathematical formulas.

Key words and phrases: operating system design, real time operating system, layered operating system, software architecture, and process communication. CR Categories: 3.80, 3.83, 4.35. i. INTRODUCTION The Modular Operating System for SUMC (MOSS) is a general purpose real time operating

asics of real-time PCR 1 1.1 Introduction 2 1.2 Overview of real-time PCR 3 1.3 Overview of real-time PCR components 4 1.4 Real-time PCR analysis technology 6 1.5 Real-time PCR fluorescence detection systems 10 1.6 Melting curve analysis 14 1.7 Passive reference dyes 15 1.8 Contamination prevention 16 1.9 Multiplex real-time PCR 16 1.10 Internal controls and reference genes 18

CPSC-663: Real-Time Systems Deterministic Cache Analysis 1 Introduction to Cache Analysis for Real-Time Systems [C. Ferdinand and R. Wilhelm, "Efficient and Precise Cache Behavior Prediction for Real-Time Systems", Real-Time Systems, 17, 131-181, (1999)] (memory performance) Ignoring cache leads to significant resource under-utilization.

10.2 The Real-Time Operating System (RTOS) Real-time operating systems are built around a multi-tasking kernel which controls the allocation of time slices to tasks. A time slice is the period of time a given task has for execution before it is stopped and replaced by another task. This process, also known as context