Micrium µc/os II RTOS Introduction EE J. E. Lumpp

Similar documents
Int tmytask() { while(1){ .. } }

INTERRUPT MANAGEMENT An interrupt is a hardware mechanism used to service an event that can be external or internal to

Nios II. uc/os-ii porting with Nios II Altera Corporation

Embedded Systems: OS

Embedded Systems: OS. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Lab 8 Real-time OS - 1

Tasks. Task Implementation and management

Real-Time Programming


Embedded Software TI2726 B. 7. Embedded software design. Koen Langendoen. Embedded Software Group

Micriμm. Getting Started with Micriμm s. Matt Gordon, Sr. Applications Engineer. 9L05I Renesas Electronics America Inc.

What s An OS? Cyclic Executive. Interrupts. Advantages Simple implementation Low overhead Very predictable

Lecture 3: Concurrency & Tasking

Introduction to Real-Time Operating Systems

Preemptive Scheduling

Micrium OS Kernel Labs

Programming in Real-Time OS (uc/os-ii)

Stellaris Robotic Evaluation Board and Micriµm µc/os-iii

Embedded Systems. 5. Operating Systems. Lothar Thiele. Computer Engineering and Networks Laboratory

µc/os-ii for the Philips XA

GLOSSARY. VisualDSP++ Kernel (VDK) User s Guide B-1

Real-time operating systems and scheduling

A New Real-time Kernel development on an embedded platform

ENGG4420 CHAPTER 2 HOMEWORK

Systemy RT i embedded Wykład 11 Systemy RTOS

REAL TIME OPERATING SYSTEMS: A COMPLETE OVERVIEW

IT2A4 EMBEDDED SYSTEMS

Real Time Operating System: Inter-Process Communication (IPC)

Reference Model and Scheduling Policies for Real-Time Systems

Micriµm, Inc. µc/os-view

Exam TI2720-C/TI2725-C Embedded Software

Embedding OS in AVR microcontrollers. Prof. Prabhat Ranjan DA-IICT, Gandhinagar

References & Terminology

REAL-TIME MULTITASKING KERNEL FOR IBM-BASED MICROCOMPUTERS

What is a Real Time Operating System?

Zilog Real-Time Kernel

8: Scheduling. Scheduling. Mark Handley

Task Based Programming Revisited Real Time Operating Systems

Putting it All Together

Real Time Kernel v1.1

Multiprocessor and Real- Time Scheduling. Chapter 10

NuttX Realtime Programming

SMD149 - Operating Systems

EE458 - Embedded Systems Introduction to uc/os

NetBurner s uc/os RTOS Library

Embedded Operating Systems

ZiLOG Real-Time Kernel Version 1.2.0

Programming with μc/os-ii Operating System on the Ide68k Integrated Development Environment

Module 8. Industrial Embedded and Communication Systems. Version 2 EE IIT, Kharagpur 1

Introduction to Embedded Systems

Efficiency and memory footprint of Xilkernel for the Microblaze soft processor

Lecture 3. Introduction to Real-Time kernels. Real-Time Systems

EE 472 Embedded Systems. Name solutions. Instructions:

Operating Systems Design Fall 2010 Exam 1 Review. Paul Krzyzanowski

2.5 Timers Continuous Clock Task Timers Application Timers Memory Management

Introduction to the ThreadX Debugger Plugin for the IAR Embedded Workbench C-SPYDebugger

real-time kernel documentation

AC OB S. Multi-threaded FW framework (OS) for embedded ARM systems Torsten Jaekel, June 2014

The components in the middle are core and the components on the outside are optional.

FreeRTOS. A Brief Overview. Christopher Kenna. October 1, Avionics. FreeRTOS 1 / 34

CODE TIME TECHNOLOGIES. Abassi RTOS. Porting Document. 8051/8052 Keil Compiler

PROCESS SCHEDULING II. CS124 Operating Systems Fall , Lecture 13

Micriμm. For the way Engineers work

Intertask Communication

BASICS OF THE RENESAS SYNERGY PLATFORM

Implementing Scheduling Algorithms. Real-Time and Embedded Systems (M) Lecture 9

Grundlagen Microcontroller Interrupts. Günther Gridling Bettina Weiss

Interrupts and Time. Real-Time Systems, Lecture 5. Martina Maggio 28 January Lund University, Department of Automatic Control

Processes and Multitasking

Interrupts and Time. Interrupts. Content. Real-Time Systems, Lecture 5. External Communication. Interrupts. Interrupts

FreeRTOS. Alberto Bosio. February 27, Université de Montpellier Alberto Bosio (UM) FreeRTOS February 27, / 52

Xinu on the Transputer

Context Switch DAVID KALINSKY

OPERATING SYSTEM CONCEPTS UNDERSTAND!!! IMPLEMENT!!! ANALYZE!!!

Revision 1.6 March 26, uc/os RTOS Library

In Class Assignment 2

Operating System Concepts Ch. 5: Scheduling

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

Institutionen för systemteknik

AN HONORS UNIVERSITY IN MARYLAND UMBC. AvrX. Yousef Ebrahimi Professor Ryan Robucci

CODE TIME TECHNOLOGIES. Abassi RTOS. Porting Document. ARM Cortex-M3 CCS

Real-Time Systems Hermann Härtig Real-Time Operating Systems Brief Overview

Concurrent Programming

Lesson 5: Software for embedding in System- Part 2

Software Development with an Open Source RTOS

Modeling Software with SystemC 3.0

BASICS OF THE RENESAS SYNERGY TM

2. Introduction to Software for Embedded Systems

Process Coordination and Shared Data

FreeRTOS. A Brief Overview. Christopher Kenna. October 1, Avionics. FreeRTOS 1 / 34

Implementation of the ART Real Time Micro Kernel

Design and implementation of Earliest point initial (EDF) algorithm Using ARM core processor

EE458 - Embedded Systems Lecture 8 Semaphores

Signals, Synchronization. CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han

Measurement laboratory 3 Embedded operating systems

Process Coordination and Shared Data

Hands-on Workshop: Freescale MQX and Tower System RTOS Getting Started (Part 2)

ENGG4420 CHAPTER 2 LECTURE 6

238P: Operating Systems. Lecture 14: Process scheduling

6/20/2018. Lecture 2: Platforms & RTOS. Outline. Lab Setup (20 min) Labs work. Lecture: Platform + RTOS

Transcription:

Micrium µc/os II RTOS Introduction (by Jean Labrosse) EE599 001 Fall 2012 J. E. Lumpp

μc/os II μc/os II is a highly portable, ROMable, very scalable, preemptive real time, deterministic, multitasking kernel It can manage up to 64 tasks (56 user tasks available) It has connectivity with μc/guiand μc/fs (GUIand File Systems for μc/os II) It is ported to more than 100 microprocessors and microcontrollers It is simple to use and simple to implement but very effective compared to the price/performance p ratio. It supports all type of processors from 8 bit to 64 bit 2

µc/os Porting 3

Task Management Services Task Creation Task Stack & Stack Checking Task Deletion Change a Task s Priority Suspend and Resume a Task Get Information about a Task 4

Task Features μc/os II can manage up to 64 tasks. The four highest priority tasks and the four lowest priority tasks are reserved for its own use. This leaves us with 56 application tasks. The lower the value of the priority, the higher the priority of the task. (e.g., Rate Monotonic Scheduling) The task priority number also serves as the task identifier 5

Embedded Program w/o RTOS Foreground #2 ISR #2 Foreground #1 ISR #1 ISR #1 Background Task #1 Task #2 Task #3 Infinite loop Time 6

Super Loop Background response time is the background execution time Non deterministic Affected by control flow (if, while ) High latency Changes to code changes timing Affected by if, for, while Poll to see if ISR occurred ISR Task #1 Task #2 Task #3 Task #4 Infinite loop 7

Foreground/Background g Tasks All tasks /functions() have the same priority Code executes in sequence => No Shared Data Bugs If an important event occurs, it s handled at the samepriority as everything else May need to execute the same code often to avoid missing an event Task #1 Task #2 Task #3 Task #4 Infinite it loop 8

RTOS Real Time Operating System Software that manages the time of a microprocessor, microcontroller, or a digital signal processor Prioritizes the work to be done Provides multitasking Provides services to the application Semaphores Message mailboxes and queues Event flags Time delays, timers, andtimeouts Task management Memory management Bandwidthassessment assessment idle time 9

Preemption 1. Pre emptive: Always runs the highest available task. Tasks of identical priority it share CPU time (fully pre emptive with round robin time slicing) 2. Cooperative: Context switches only occur if a task blocks, or explicitly relinquishes CPU control 10

RTOS Advantages Software that manages the time of a microprocessor or microcontroller Ensures that the most important code runs first Allows Multitasking Do more than one thing at the same time Application is broken down into multiple tasks, each handling oneaspect of your application It s like having multiple CPUs Provides valuable services to your application Time delays dl Resource sharing Inter task communication and synchronization 11

RTOS Tasks A task is a function that appears it has the CPU all to itself Each Task has Its own stack space A priority i based on its importance A task contains application code and calls to OS functions 12

Example Task A task is an infinite loop void Task (void *p_arg) { Do something with argument p_arg; Task initialization; for (;;) { /* Processing (Your Code) */ Wait for event; /* Time to expire... */ /* Signal from ISR... */ /* Signal from task... */ /* Processing (Your Code) */ } } 13

Designing with µc/os II High Priority Task Task Task Each Task Importance Task Event Event Task Task Low Priority Task Task Infinite it Loop 14

Task States 15

uc/os II API There are several functions called API of uc/os II using these api functions we can write our application on uc/os II API is used to handle Tasks Semaphores and Mutex Memory Management Timer etc. 16

Kernel Structure How μc/os II handles access to critical sections of code, What a task is, and how μc/os II knows about your tasks, How tasks are scheduled, How μc/os II can determine how much of CPU your application is using, How do to write Interrupt Service Routines (ISRs), What a clock tick is and how μc/os II handles it, How to initialize μc/os II and, How to start multitasking. 17

Tasks 18

Tasks Management Uc os II can manage up to 64 tasks but it is recommended that leave the 4 above and 4 below priorities so effectively we have 56 task It means we can create upto 56 tasks OS_LOWEST_PRIO the lowest priority task is for the idle task Idle task means that if there is no task in ready queue still the cpu will execute this idle task. 19

Task Statistics Uc/os II contains a task that provide run time statistics OS_TaskStat() and is created by uc/os II if you set the configuration constant OS_TASK_STAT_EN to 1 When enabled OS_TaskStat() executes every second and computes the percentage of CPU usages OS_TaskStat() tells you how much CPU time is used by your application as a percentage This value is placed in 8 bit signed integer OSCPUUsage variable Resolution of OSCPUUsage is 1 percent 20

Interrupts under uc/os II μc/os II requires that an Interrupt Service Routine (ISR) be written in assembly language. μc/os II needs to know that you are servicing an ISR and thus, you need to either call OSIntEnter() or, increment the global variable OSIntNesting. μc/os II allows you to nest interrupts because it keeps track of nesting in OSIntNesting. ISR concludes by calling OSIntExit() which decrementsthethe interrupt nesting counter. 21

Interrupts under uc/os II This function notify uc/os II about beginning of of an interrupt Funtions OSIntExit() notify about the ending of an interrupt 22

Task Management Task is either an infinite loop function or a function that deletes itself Task code is not actually deleted, uc os II doesn't know about the task anymore so that code will not run. Task loop like any other C function Task must never return return type of a task must always be void Task functions are described in OS_TASK.C Using the function we can create, delete, change task's priority, suspend, resume and obtain information about a task 23

24

Time Management Clock Tick: A clock tick is a periodic time source to keep track of time delays and time outs. Tick intervals: 10 ~ 100 ms. The faster the tick rate, the higher the overhead imposed on the system. When ever a clock tick occurs μc/os II increments a 32 bit counter The counter starts at zero, and rolls over to 4,294,967,295 (2^32 1) ticks. A task can be delayed and a delayed task can also be resumed 25

Time Management Five services: OSTimeDLY() OSTimeDLYHMSM() S OSTimeDlyResume() OSTimeGet() OSTimeSet() 26

Inter task task communication Inter task or inter process communication in μc/os takes place using Semaphores Message mailbox Message queues Tasks and Interrupt service routines (ISR) can interact with each other through an ECB (event control block) 27

Semaphores A semaphore consists of a wait list and an integer counter. OSSemPend(): Counter ; If the value of the semaphore <0, then the task is blocked and moved to the wait list immediately. A time out t value can be specified. OSSemPost(): Counter++; If the value of the semaphore >= 0, then a task in the wait list is removed from the wait list. Reschedule ifneeded needed.

Single task waiting 29

Multiple tasks waiting and signaling 30

Tasks can wait and signal along with an optional time out 31

Sempahores μc/os IIsemaphores consist of two elements 16 bit unsigned integer count list of tasks waiting for semaphore μc/osii provides Create, post, pend accept and query services 32

μc/os II message mailboxesmailboxes μc/osii object that allows a task or ISR to send a pointer sized variable (pointing to a message) to another task. 33

μc/os II message queues Available services: Create, Post (FIFO), PostFront (LIFO), Pend, Accept, p,query, Flush N = #of entries in the queue: Queue full if Post or PostFront called N times before a Pend or Accept μc/os II / message queues organized as circular buffers. 34

Tasks loops Tasks running under a multitasking kernel should be written in one of two ways: A non returning forever loop. For example: void Task (void *) { DoInitStuff(); while (1) { do this; do that; do the other thing; call OS service (); // e.g. OSTimeDelay, OSSemPend, etc. } } 35

Rate Monotonic Scheduling In Rate Monotonic Scheduling tasks with the highest rate of execution are given the highest priority Assumptions: All tasks are periodic Tasks do not synchronize with one another, share resources, etc. Preemptive scheduling is used (always runs the highest priority task that is ready) Under these assumptions, let n be the number of tasks, Ei be the execution time of task i, and Ti be the period of task i. Then, all deadlines will be met if the following inequality is satisfied: ΣEi / Ti n(21/n 1) 36

Rate Monotonic Scheduling: Example Suppose we have 3 tasks. Task 1 runs at 100 Hz and takes 2 ms. Task 2 runs at 50 Hz and takes 1 ms. Task 3 runs at 66.7 Hz and takes 7 ms. Apply RMS theory (2/10) + (1/20) + (7/15) = 0.717 3(21/3 1) = 0.780 Thus, all the deadlines will be met General Solution? As n, the right hand side of the inequality goes to ln(2)= 0.6931. Thus, you should design 37