1 / 52

Introduction to RTOS

Introduction to RTOS. Agenda. Overview What is Real-Time Embedded System What is RTOS? Structure of RTOS Priority Scheduling Synchronization Example: uC/OS Debugging Feature Market Status. Agenda. Overview What is Real-Time Embedded System What is RTOS? Structure of RTOS

borka
Download Presentation

Introduction to RTOS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to RTOS

  2. Agenda • Overview • What is Real-Time Embedded System • What is RTOS? • Structure of RTOS • Priority Scheduling • Synchronization • Example: uC/OS • Debugging Feature • Market Status

  3. Agenda • Overview • What is Real-Time Embedded System • What is RTOS? • Structure of RTOS • Priority Scheduling • Synchronization • Example: uC/OS • Debugging Feature • Market Status

  4. What is Embedded System • Definition • Electrical control system which is designed to perform predefined specific function with combination of computer hardware and software. (Mechanical parts can be included for its needs.) • As processor power increases, • More complex work can be handled by processor.

  5. Embedded System • Embedded system = processor-based embedded system • SoC = Embedded system on silicon chip = Core-based SoC • Embedded System is already the common solution • “Latest top-level BMWs contain over 1000 microprocessors” • “… the New York Times has estimated thatthe average American comes into contactwith about 60 micro-processors every day…”

  6. Processor-embedded System • Most of the embedded designs includes processor(s) • Adopting processor-based design shortens time-to-market. • Processor has become powerful enough to execute complex workload.

  7. Real-Time Embedded System • Definition • Devices designed for dedicated purposes where the correctness of the system depends not only on the logical result of the computation but also on the time at which the results are produced.

  8. What is RTOS? • What is real-time? • Hard real-time • Job must be completed within the dead-line. • Static or dynamic scheduled task • Hard to solve if the task is invoked by external event. • Has been researched over 20 years but there is no successful commercial products yet. • Soft real-time • There is no hard dead line. • Order of execution is determined by priority. • OS can not generally guarantee the specified timing behavior, but it works in most of the practical cases in carefully designed system. • RTOS, if not specified otherwise, denotes this class.

  9. Real-Time Operating System • Operating system is very familiar to everyone. • Ex; Windows-XP, Linux… • OS helps people easily exploit the power of the computer without detailed knowledge of the hardware through GUI, and multitasking, etc. • However, in embedded systems: • There’s no need to give dazzling graphic interface/performance. • Must control its task with real-time constraints. • Car air-bag must be operated in 3 ms after collision. • When the button in MP3 player is pressed, the menu must pop up in one second.

  10. Technical Pressure Nielsen’s law: Bandwidth doubles every 12 months Embedded SW: Doubles every 10 months Complexity Moore’s law: IC complexity doubles every 18 months 2000 2010 Source: ST Microelectronics

  11. Embedded System Embedded System Core-basedSystem Real-TimeSystem Most embedded system targets this area.

  12. Where Can Real-Time Systems be Found? • RT-systems are everywhere: • plant control • control of production processes / industrial automation • railway switching systems • automotive applications • flight control systems • environmental acquisition and monitoring • telecommunication systems • robotics • military systems • space missions • household appliances • virtual / augmented reality

  13. Embedded System on Chip • Today SoC includes several modules such as • MCU, VLIW, DSP • Memories • ASICs • Busing scheme • Application Software • RTOS

  14. Real-Time Properties • Time means being correct • not only in logical results, • but also on the time the results are produced • Real indicates: Reaction to external events must occur during their evolution. • Real-time means • deadline to be met under all (even the worst) circumstances.

  15. Hard/Firm/Soft RT(real time) • RT task is called hard • if missing its deadline may cause catastrophic consequences on the environment under control • RT task is called firm • if missing its deadline makes the result useless, but missing does not cause serious damage • RT task is called soft • if meeting its deadline is desirable (e.g. for performance reasons) but missing does not cause serious damage

  16. Hard/Firm/Soft RT value value deadline non-realtime soft finishing time finishing time value value deadline deadline firm hard finishing time finishing time

  17. Examples of Hard/Firm/Soft RT

  18. History of RTOS • Originated as Monitor program, which • includes Boot loader, Interrupt Service Routine, and • communicates with external debugging program, and • Is generally custom-made • RTOS becomes more and more complex • To control task in real-time, kernel is essential. • It controls each task as a thread/process, which interacts with one another through inter-process communication mechanism. • Some commercial RTOS also includes: • Network module such as TCP/IP • Simple file system implemented on hard-disk or flash memory • Text-based user interface shell

  19. OS Basic: Layer • Laplante (1997) defines OS by describing a software hierarchy User Interface Shell Operating System File system Executive Kernel Inter-process Comm. Micro-kernel Process scheduling Thread scheduling Nano-kernel

  20. OS Basic: Preemption • Preemption • OS can switch to another task execution even though the current task has not reached the predefined time point. • Preemptive kernel is generally less stable. Old Task New Task

  21. OS Basic: Resource Constraints • Private resource: dedicated to a particular process • Shared resource: to be used by more than one process • Exclusive resource: shared resource where simultaneous access from different processes is not allowed • Critical resource: resource that is used under mutual exclusion constraints. Management using semaphores (e.g.)

  22. How RTOS differs from general-purpose OS • In task scheduling, • RTOS has a preemptive kernel, while in general-purpose OS (e.g. UNIX), although there is priority, task switching occurs only at predefined time boundary. • RTOS handles only one process at a time but in multiple threads. • In memory management, • RTOS neither requires virtual memory nor protection mechanism. (Some commercial RTOS supports these features, though.)

  23. Reusable HW and SW parts in embedded system design UserApplication Kernel SystemControl TCP/IP SW devicedriver devicedriver devicedriver IP(standardperipheral) IP(computingblock) User customblock HW RTOS Standard parts (Reuse possible) Customizing parts

  24. Agenda • Overview • What is Embedded System • What is RTOS? • Structure of RTOS • Priority Scheduling • Synchronization • Example: uC/OS • Debugging Feature • Market Status

  25. Main roles of RTOS • Task management • Every task is implemented as a thread for easy programming and fast execution. • Priority is assigned to each task. • Memory management • I/O management • Determines the execution order of tasks, which is known as Synchronization • Inter-process Communication • Message queues

  26. System Tables Dispatcher Interrupt Service Routines (ISR) System Services RTOS Structure AlgorithmDevelopment Task Management Inter-process Comm. SystemDesign RTOS Memory Management I/O Management System Architecture Selection I/O Design

  27. Operating System Structure:System Tables • System Tables: • Task-Control-Blocks (TCB) • These hold information necessary to run the tasks. • Device-Control-Blocks (DCB) • These hold information necessary for the operating system to use the I/O devices. Also, each device may have an additional table or buffer to hold I/O information • Service-Control-Blocks (SCB) • These specify the parameters for a request for the operating system to perform some function. • E.g. signal is implemented as SCB. • Asynchronous event processing and exception handling • It resumes the task blocked by event flags

  28. Operating System Structure:The Dispatcher • The dispatcher is a program module that determines which task will run next after something triggers the system to switch control to a new task. • Also called as scheduler Running dispatch Block preemption Blocked Ready Wake upby signal

  29. Scheduling algorithm • Static hard real-time • All task activations can be pre-calculated off-line. • At run-time dispatching is performed in a simple way due to predefined scheduling table • Very sophisticated off-line algorithm • System is inflexible to environmental change • Dynamic hard real-time • Guarantee must be made on-line each time a new task enters the system • Hard to guarantee its correctness. • Soft real-time • Priority-based scheduling • Best effort to perform in average • Unpredictable

  30. Preemptive Priority Scheduling t3 t2 t2 priority t1 t1 time = preemption = task completion

  31. Synchronization • Roles of synchronization • Determine the order of executed tasks • Resource or critical section management • E.g. I/O must be occupied by only one task in the specified time. • Types of synchronization objects • Semaphores • Mutexes • Barrier • Conditional variables • Whether exclusion applied or not is based on a condition.

  32. Synchronization t1 t2 t2 t3 t1 t2 t1 t3 BLOCKED BLOCKED … … BLOCKED … BLOCKED … time t3 t2 (c) Barrier statement deters Execution until some number Of such statements occur. (Synchronization in narrow sense) (b) Semaphore count (multiple=2 tokens) (a) Mutex(single token) = try to take/has taken/release resource

  33. Communication • Communications • Mailbox – single messages (Existence of message in the mailbox allows continuing the task waiting for it.) • Queues – multiple messages t1 t2 t3 t2 M1 t1 time M2 BLOCKED … M1 M1 M1 t3 t2 M2 t3 (a) Mailbox (b) Queue

  34. t3 t3 t2 priority t1 t1 t1 time t3 t1 t3 priority t2 t1 time Priority Inversion Too MuchWaiting! = preemption = block = try to take/has taken/release semaphore

  35. Portability • Board Support Package (BSP) • RTOS can be applied to any application board • Application board needs to be redesigned when the target is changed. • After the information related to the user application board (ex. Memory map, interrupt number assignment, frequency of system timer) is collected, it is put together in one parameter file called BSP. • In some general OS, it is called as HAL (Hardware Abstraction Layer) which includes processor information.

  36. Agenda • Overview • What is Embedded System • What is RTOS? • Structure of RTOS • Priority Scheduling • Synchronization • Example: uC/OS • Debugging Feature • Market Status

  37. uC/OS • Simple real-time kernel • Source code is open to everyone. • Supporting features • System Table • Task Control Block (TCB) • Event Control Block (ECB) • Signal is called as ‘event’ in uC/OS • Some kind of Service Control Block • No device driver • Scheduler • Manage look up tables to invoke task faster • Ready table for TCB’s • Event table for ECB’s

  38. Structure of uC/OS IdleTask Context Switch Usertask1 Usertask2 Usertask3 … Scheduler update ReadyTable TCBfor task1 TCBfor task2 TCBfor task3 … priority PENDING or READY update EventTable ECBfor event1 ECBfor event2 ECBfor event3 … Task list priority Event list

  39. Code example • Body of MP3 decoder • MP3 decoding algorithm • Play/Pause button • Volume up/down Min. 3 independent tasks BtnCheck() { OSMboxPost(BtnPress, PLAY_BTN); /* Signal to Message Box */ } main() { … Set_IntrVect(TIMER_IRQ, OSTickClk); Set_IntrVect(IOPORT_IRQ, BtnCheck); … Task1 = OSCreateTask(MP3DecTask, NULL, 10); Task2 = OSCreateTask(VolCtrlTask, NULL, 20); Task3 = OSCreateTask(BtnCtrlTask, NULL, 30); … } Interrupt handler task function priority

  40. Task management of uC/OS • Task Control Block (TCB) • State of task • WAITING or READY • Priority • Stack • Each task has an independent stack • Static stack assignment • Array variable is given as stack • Value of registers are saved in private stack while context switching • Task Ready Table • Finding highest priority task for running • Scheduler does not need to scan whole TCB’s

  41. Event management of uC/OS • Event Control Block (ECB) • List of tasks waiting for this event • Event type • Semaphore/message box/message queue • Counter (for semaphore) • Event ready table • Finding highest priority task waiting for the event • A table is attached to each event.

  42. Accessing I/O in uC/OS unsigned int *simple_port = 0x10000; struct { unsigned char buffer; union { unsigned char byte; struct { ready : 1; empty : 1; busy : 1; unused : 5; } bit; } status; } *uart = 0x20000; Task1() { if (*simple_port ==1 ) { *simple_port = 0; } if (uart->status.bit.ready) { uart->buffer = 0x30; Pointer-based I/O Access Structure of pointer - well structured to model complex registers Modeling flag in bit-wise access User program

  43. Agenda • Overview • What is Embedded System • What is RTOS? • Structure of RTOS • Priority Scheduling • Synchronization • Example: uC/OS • Debugging Feature

  44. Simulation Environment • RTOS Simulation Model • Vendor supports simulation model of RTOS. • The designer programs his/her own modules in programming language such as C. • Check validity with event monitor • Log events with precedence relationship. • Show the order of executed tasks. • It can only verify functional behavior. • No method to handle timing information.

  45. Simulation Environment • Co-simulation Environment • Connecting Instruction Set Simulator (ISS) with HDL Simulator. • Verify the system in cycle-accurate level. User Program HW IP BusInterface IPC ISS BFM IPC: InterProcess Communication BFM: Bus Functional Model

  46. Debugging Feature • Source-level Debugger • Runs with • ISS, or • In-Circuit Emulator(ICE), where the Debugger controls embedded processor execution via JTAG port

  47. Example: WindRiver Tornado II Target Host Core Tornado Tools Real-Time Embedded Applications Plug-ins Graphic Connectivity WindPower Tool SimulationEnvironment Java Support File System WindView ScopePak Posix Lib. Connectivity Virtual Performance Pak CodeTest Coverage Virtual Memory CodetestMem CodeTest Trace Multiprocessor Support Visual SlickEdit Look! ethernet Wind Micro-kernel DebugAgent SNiFF+ SNiFF+ Pro serial line Core OS custom ICE/JTAG/BDM BSP Third Party Tools Wind River Reference Hardware

  48. Agenda • Overview • What is Embedded System • What is RTOS? • Structure of RTOS • Priority Scheduling • Synchronization • Example: uC/OS • Debugging Feature • Market Stauts

  49. Market Environment • Many Commercial and Free RTOSs presents • WindRiver(VxWork, pSOS), QNX, eCOS… • Embedded Linux begins to spread • Today’s commercial RTOS have • Modular design • You can select the function which you really want. • Better to decrease size of required memory • Many custom modules are prepared • TCP/IP, SNMP, … • And they sells…

  50. Embedded Market

More Related