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:



Advertisements
Similar presentations
1 Interprocess Communication 1. Ways of passing information 2. Guarded critical activities (e.g. updating shared data) 3. Proper sequencing in case of.
Advertisements

Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee.
1 Chapter 5 Concurrency: Mutual Exclusion and Synchronization Principals of Concurrency Mutual Exclusion: Hardware Support Semaphores Readers/Writers Problem.
CAS3SH3 Midterm Review. The midterm 50 min, Friday, Feb 27 th Materials through CPU scheduling closed book, closed note Types of questions: True & False,
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.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
Mutual Exclusion.
Real-Time Kernels and Operating Systems Basic Issue - Purchase commercial “off-the- shelf” system or custom build one Basic Functions –Task scheduling.
Informationsteknologi Wednesday, September 26, 2007 Computer Systems/Operating Systems - Class 91 Today’s class Mutual exclusion and synchronization 
Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee.
Chapter 5 Processes and Threads Copyright © 2008.
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.
1 CS318 Project #3 Preemptive Kernel. 2 Continuing from Project 2 Project 2 involved: Context Switch Stack Manipulation Saving State Moving between threads,
1 Concurrent and Distributed Systems Introduction 8 lectures on concurrency control in centralised systems - interaction of components in main memory -
CSE Fall Introduction - 1 What is an Embedded Systems  Its not a desktop system  Fixed or semi-fixed functionality (not user programmable)
Home: Phones OFF Please Unix Kernel Parminder Singh Kang Home:
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.
Race Conditions CS550 Operating Systems. Review So far, we have discussed Processes and Threads and talked about multithreading and MPI processes by example.
Embedded Systems Interrupts C.-Z. Yang Sept.-Dec
1 Chapter 13 Embedded Systems Embedded Systems Characteristics of Embedded Operating Systems.
ELN5622 Embedded Systems Class 8 Spring, 2003 Aaron Itskovich
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
Real-Time Systems Design1 Priority Inversion When a low-priority task blocks a higher-priority one, a priority inversion is said to occur Assume that priorities:
Getting Started with the µC/OS-III Real Time Kernel Akos Ledeczi EECE 6354, Fall 2015 Vanderbilt University.
2-1 The critical section –A piece of code which cannot be interrupted during execution Cases of critical sections –Modifying a block of memory shared by.
Real-Time Operating Systems for Embedded Computing 李姿宜 R ,06,10.
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.
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
ECGR-6185 µC/OS II Nayana Rao University of North Carolina at Charlotte.
Real Time Operating Systems Michael Thomas Date: Rev. 1.00Date.
Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee.
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.
CS399 New Beginnings Jonathan Walpole. 2 Concurrent Programming & Synchronization Primitives.
Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower than CPU.
CSE 153 Design of Operating Systems Winter 2015 Midterm Review.
Embedded Computer - Definition When a microcomputer is part of a larger product, it is said to be an embedded computer. The embedded computer retrieves.
Slides created by: Professor Ian G. Harris Operating Systems  Allow the processor to perform several tasks at virtually the same time Ex. Web Controlled.
Introduction Contain two or more CPU share common memory and peripherals. Provide greater system throughput. Multiple processor executing simultaneous.
1 Device Controller I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller or adapter.
SOC Consortium Course Material SoC Design Laboratory Lab 8 Real-time OS - 1 Speaker: Yung-Chih Chen Advisor: Prof. Chun-Yao Wang November 17, 2003 Department.
1 8. Basic Design Using a Real-Time Operating System Kim jung kil.
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
Big Picture Lab 4 Operating Systems C Andras Moritz
© 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.
Topics Covered What is Real Time Operating System (RTOS)
CS703 – Advanced Operating Systems
Background on the need for Synchronization
6.0 INTRODUCTION TO REAL-TIME OPERATING SYSTEMS (RTOS/RTK)
An Embedded Software Primer
Process Synchronization and Communication
An Embedded Software Primer
Operating Systems Chapter 5: Input/Output Management
Synchronization Issues
Lecture 2 Part 2 Process Synchronization
February 5, 2004 Adrienne Noble
CSE 153 Design of Operating Systems Winter 19
CSE 153 Design of Operating Systems Winter 2019
Threads CSE 2431: Introduction to Operating Systems
Presentation transcript:

6.0 INTRODUCTION TO REAL-TIME OPERATING SYSTEMS (RTOS) 6.0 Introduction 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 (we got it!), VTRX, Nucleus, LynxOS,  C/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

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) [Exit] Scheduler – 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)

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

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)?

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, indexed by the semaphore Protection at the end is via a primitive function, called release, 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.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.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.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.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