6.0 INTRODUCTION TO REAL-TIME OPERATING SYSTEMS (RTOS/RTK)

Slides:



Advertisements
Similar presentations
Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee.
Advertisements

Concurrency: Mutual Exclusion and Synchronization Chapter 5.
Resource management and Synchronization Akos Ledeczi EECE 354, Fall 2010 Vanderbilt University.
Ch. 7 Process Synchronization (1/2) I Background F Producer - Consumer process :  Compiler, Assembler, Loader, · · · · · · F Bounded buffer.
Chapter 6: Process Synchronization
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
Mutual Exclusion.
Informationsteknologi Wednesday, September 26, 2007 Computer Systems/Operating Systems - Class 91 Today’s class Mutual exclusion and synchronization 
Computer Systems/Operating Systems - Class 8
1 Concurrency: Mutual Exclusion and Synchronization Chapter 5.
Embedded Systems Introduction to Real-Time Operating Systems C.-Z. Yang Sept.-Dec
Avishai Wool lecture Introduction to Systems Programming Lecture 4 Inter-Process / Inter-Thread Communication.
CSE Fall Introduction - 1 What is an Embedded Systems  Its not a desktop system  Fixed or semi-fixed functionality (not user programmable)
Processes 1 CS502 Spring 2006 Processes Week 2 – CS 502.
Chapter 7 Interupts DMA Channels Context Switching.
Real-Time Kernels and Operating Systems. Operating System: Software that coordinates multiple tasks in processor, including peripheral interfacing Types.
IN2305-II Embedded Programming Lecture 6: RTOS Introduction.
Race Conditions CS550 Operating Systems. Review So far, we have discussed Processes and Threads and talked about multithreading and MPI processes by example.
Mehmet Can Vuran, Instructor University of Nebraska-Lincoln Acknowledgement: Overheads adapted from those provided by the authors of the textbook.
Introduction to Embedded Systems
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Introduction to Concurrency.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Mutual Exclusion.
Multiple Processor Systems. Multiprocessor Systems Continuous need for faster computers –shared memory model ( access nsec) –message passing multiprocessor.
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
ECGR-6185 µC/OS II Nayana Rao University of North Carolina at Charlotte.
MicroC/OS-II S O T R.  MicroC/OS-II (commonly termed as µC/OS- II or uC/OS-II), is the acronym for Micro-Controller Operating Systems Version 2.  It.
1 VxWorks 5.4 Group A3: Wafa’ Jaffal Kathryn Bean.
6.0 INTRODUCTION TO REAL-TIME OPERATING SYSTEMS (RTOS) 6.0 Introduction A more complex software architecture is needed to handle multiple tasks, coordination,
Slides created by: Professor Ian G. Harris Operating Systems  Allow the processor to perform several tasks at virtually the same time Ex. Web Controlled.
1 Device Controller I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller or adapter.
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Mutual Exclusion Mutexes, Semaphores.
Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee.
LPC2148's RTOS Bruce Chhuon 4/10/07. What is a Real Time Operating System? ● A Real Time Operating System (RTOS) manages hardware and software resources.
REAL-TIME OPERATING SYSTEMS
Advanced Operating Systems CIS 720
Process Management Process Concept Why only the global variables?
Topics Covered What is Real Time Operating System (RTOS)
CS703 – Advanced Operating Systems
Auburn University COMP 3500 Introduction to Operating Systems Synchronization: Part 4 Classical Synchronization Problems.
Background on the need for Synchronization
Computer Architecture
Getting Started with the µC/OS-III Real Time Kernel
An Embedded Software Primer
Process Synchronization and Communication
Semaphores -Gajendra Singh.
Inter-Process Communication and Synchronization
Concurrency: Mutual Exclusion and Synchronization
An Embedded Software Primer
Computer System Overview
Real-Time Operating Systems
Synchronization Issues
BIC 10503: COMPUTER ARCHITECTURE
Lecture 2 Part 2 Process Synchronization
Concurrency, Processes and Threads
Operating Systems : Overview
Implementing Mutual Exclusion
Embedded System Development Lecture 7 2/21/2007
February 5, 2004 Adrienne Noble
Operating Systems : Overview
CSE 153 Design of Operating Systems Winter 19
CS333 Intro to Operating Systems
CSE 153 Design of Operating Systems Winter 2019
Threads CSE 2431: Introduction to Operating Systems
Akos Ledeczi EECE 6354, Fall 2017 Vanderbilt University
Akos Ledeczi EECE 6354, Fall 2015 Vanderbilt University
Presentation transcript:

6.0 INTRODUCTION TO REAL-TIME OPERATING SYSTEMS (RTOS/RTK) A more complex software architecture is needed to handle multiple tasks, coordination, communication, and interrupt handling – an RTOS architecture Distinction: Desktop OS – OS is in control at all times and runs applications, OS runs in different address space RTOS – OS and embedded software are integrated, ES starts and activates the OS – both run in the same address space (RTOS is less protected) RTOS includes only service routines needed by the ES application RTOS vendors: VsWorks , VTRX, Nucleus, LynxOS, uC/OS Most conform to POSIX (IEEE standard for OS interfaces) Desirable RTOS properties: use less memory, application programming interface, debugging tools, support for variety of microprocessors, already-debugged network drivers

A task – a simple subroutine 6.0 INTRODUCTION TO RTOS 6.1 Tasks and Task States A task – a simple subroutine ES application makes calls to the RTOS functions to start tasks, passing to the OS, start address, stack pointers, etc. of the tasks Task States: Running Ready (possibly: suspended, pended) Blocked (possibly: waiting, dormant, delayed) Scheduler – keep tracks, schedules/shuffles tasks between Running and Ready states Blocking is self-blocking by tasks, and moved to Running state via other tasks’ interrupt signaling (when block-factor is removed/satisfied) When a task is unblocked with a higher priority over the ‘running’ task, the scheduler ‘switches’ context immediately (for all pre-emptive RTOSs) (See Fig 6.1)

6.0 INTRODUCTION TO RTOS 6.1 Tasks – 1 Issue – Scheduler/Task signal exchange for block-unblock of tasks via function calls Issue – All tasks are blocked and scheduler idles forever (not desirable!) Issue – Two or more tasks with same priority levels in Ready state (time-slice, FIFO) Example: scheduler switches from processor-hog vLevelsTask to vButtonTask (on user interruption by pressing a push-button), controlled by the main() which initializes the RTOS, sets priority levels, and starts the RTOS (See Fig 6.2, Fig 6.3, Fig 6.4)

6.0 INTRODUCTION TO RTOS 6.3 Tasks and Data Each tasks has its won context - not shared, private registers, stack, etc. In addition, several tasks share common data (via global data declaration; use of ‘extern’ in one task to point to another task that declares the shared data Shared data caused the ‘shared-data problem’ without solutions discussed in Chp4 or use of ‘Reentrancy’ characterization of functions (See Fig 6.5, Fig 6.6, Fig 6.7, and Fig 6.8)

Characteristics of reentrant functions – 6.0 INTRODUCTION TO RTOS 6.2 Tasks – 2 Reentrancy – A function that works correctly regardless of the number of tasks that call it between interrupts Characteristics of reentrant functions – Only access shared variable in an atomic-way, or when variable is on callee’s stack A reentrant function calls only reentrant functions A reentrant function uses system hardware (shared resource) atomically

Inspecting code to determine Reentrancy: 6.0 INTRODUCTION TO RTOS Inspecting code to determine Reentrancy: See Fig 6.9 – Where are data stored in C? Shared, non-shared, or stacked? See Fig 6.10 – Is it reentrant? What about variable fError? Is printf reentrant? If shared variables are not protected, could they be accessed using single assembly instructions (guaranteeing non-atomicity)?

Semaphores (lower or raise)

6.3 Semaphores and Shared Data – A new tool for atomicity 6.0 INTRODUCTION TO RTOS 6.3 Semaphores and Shared Data – A new tool for atomicity Semaphore – a variable/lock/flag used to control access to shared resource (to avoid shared-data problems in RTOS) Protection at the start is via primitive function, called take(lower), indexed by the semaphore Protection at the end is via a primitive function, called release(raise), also indexed similarly Simple semaphores – Binary semaphores are often adequate for shared data problems in RTOS (See Fig 6.12 and Fig 6.13)

6.3 Semaphores and Shared Data – 1 6.0 INTRODUCTION TO RTOS 6.3 Semaphores and Shared Data – 1 RTOS Semaphores & Initializing Semaphores Using binary semaphores to solve the ‘tank monitoring’ problem (See Fig 6.12 and Fig 6.13) The nuclear reactor system: The issue of initializing the semaphore variable in a dedicated task (not in a ‘competing’ task) before initializing the OS – timing of tasks and priority overrides, which can undermine the effect of the semaphores Solution: Call OSSemInit() before OSInit() (See Fig 6.14)

6.3 Semaphores and Shared Data – 2 6.0 INTRODUCTION TO RTOS 6.3 Semaphores and Shared Data – 2 Reentrancy, Semaphores, Multiple Semaphores, Device Signaling, Fig 6.15 – a reentrant function, protecting a shared data, cErrors, in critical section Each shared data (resource/device) requires a separate semaphore for individual protection, allowing multiple tasks and data/resources/devices to be shared exclusively, while allowing efficient implementation and response time Fig 6.16 – example of a printer device signaled by a report-buffering task, via semaphore signaling, on each print of lines constituting the formatted and buffered report

6.3 Semaphores and Shared Data – 3 6.0 INTRODUCTION TO RTOS 6.3 Semaphores and Shared Data – 3 Semaphore Problems – ‘Messing up’ with semaphores The initial values of semaphores – when not set properly or at the wrong place The ‘symmetry’ of takes and releases – must match or correspond – each ‘take’ must have a corresponding ‘release’ somewhere in the ES application ‘Taking’ the wrong semaphore unintentionally (issue with multiple semaphores) Holding a semaphore for too long can cause ‘waiting’ tasks’ deadline to be missed Priorities could be ‘inverted’ and usually solved by ‘priority inheritance/promotion’ (See Fig 6.17) Causing the deadly embrace problem (cycles) (See Fig 6.18)

6.3 Semaphores and Shared Data – 4 Variants: 6.0 INTRODUCTION TO RTOS 6.3 Semaphores and Shared Data – 4 Variants: Binary semaphores – single resource, one-at-a time, alternating in use (also for resources) Counting semaphores – multiple instances of resources, increase/decrease of integer semaphore variable Mutex – protects data shared while dealing with priority inversion problem Summary – Protecting shared data in RTOS Disabling/Enabling interrupts (for task code and interrupt routines), faster Taking/Releasing semaphores (can’t use them in interrupt routines), slower, affecting response times of those tasks that need the semaphore Disabling task switches (no effect on interrupt routines), holds all other tasks’ response