The Real-Time Operating System ucos-ii



Similar documents
8. MicroC/OS-II Real-Time Operating System

REAL TIME OPERATING SYSTEMS. Lesson-3:

快 速 porting μc/os-ii 及 driver 解 說

Page 1 of 5. IS 335: Information Technology in Business Lecture Outline Operating Systems

REAL TIME OPERATING SYSTEMS. Lesson-10:

Performance Comparison of RTOS

Mobile Operating Systems Lesson 03 PalmOS Part 1

SYSTEM ecos Embedded Configurable Operating System

POSIX. RTOSes Part I. POSIX Versions. POSIX Versions (2)

1. Computer System Structure and Components

Operating System Manual. Realtime Communication System for netx. Kernel API Function Reference.

Linux 2.4. Linux. Windows

Chapter 3: Operating-System Structures. System Components Operating System Services System Calls System Programs System Structure Virtual Machines

Operating Systems 4 th Class

Mobile Operating Systems Lesson 05 Windows CE Part 1

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

Review from last time. CS 537 Lecture 3 OS Structure. OS structure. What you should learn from this lecture

CPU Scheduling. CPU Scheduling

Linux Scheduler. Linux Scheduler

Embedded Systems. 6. Real-Time Operating Systems

Lecture 3 Theoretical Foundations of RTOS

Outline: Operating Systems

I/O Management. General Computer Architecture. Goals for I/O. Levels of I/O. Naming. I/O Management. COMP755 Advanced Operating Systems 1

Why Threads Are A Bad Idea (for most purposes)

Linux Process Scheduling Policy

STUDY GUIDE CHAPTER 4

Chapter 1 Lesson 3 Hardware Elements in the Embedded Systems Chapter-1L03: "Embedded Systems - ", Raj Kamal, Publs.: McGraw-Hill Education

Real-Time Systems Prof. Dr. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Chapter 12. Development Tools for Microcontroller Applications

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Operating System Software

OPERATING SYSTEM SERVICES

PROGRAMMING CONCEPTS AND EMBEDDED PROGRAMMING IN C, C++ and JAVA: Lesson-4: Data Structures: Stacks

Chapter 1 Computer System Overview

Technology in Action. Alan Evans Kendall Martin Mary Anne Poatsy. Eleventh Edition. Copyright 2015 Pearson Education, Inc.

Chapter 3. Operating Systems

Chapter 11 I/O Management and Disk Scheduling

Predictable response times in event-driven real-time systems

Operating Systems. Lecture 03. February 11, 2013

Computers. Hardware. The Central Processing Unit (CPU) CMPT 125: Lecture 1: Understanding the Computer

REAL TIME OPERATING SYSTEM PROGRAMMING-II: II: Windows CE, OSEK and Real time Linux. Lesson-12: Real Time Linux

CSC 2405: Computer Systems II

Have both hardware and software. Want to hide the details from the programmer (user).

System Software and TinyAUTOSAR

Lesson-3 CASE STUDY OF AN EMBEDDED SYSTEM FOR SMART CARD

Linux Driver Devices. Why, When, Which, How?

Introduction to Operating Systems. Perspective of the Computer. System Software. Indiana University Chen Yu

Operating system Dr. Shroouq J.

Chapter 1 FUNDAMENTALS OF OPERATING SYSTEM

Lesson Objectives. To provide a grand tour of the major operating systems components To provide coverage of basic computer system organization

Objectives. Chapter 2: Operating-System Structures. Operating System Services (Cont.) Operating System Services. Operating System Services (Cont.

Chapter 2 System Structures

Digital Photo Bank / Portable HDD Pan Ocean E350 User Manual

Fastboot Techniques for x86 Architectures. Marcus Bortel Field Application Engineer QNX Software Systems

S7 for Windows S7-300/400

Thomas Fahrig Senior Developer Hypervisor Team. Hypervisor Architecture Terminology Goals Basics Details

TEST CHAPTERS 1 & 2 OPERATING SYSTEMS

Operating Systems Concepts: Chapter 7: Scheduling Strategies

Lecture 25 Symbian OS

Nios II-Based Intellectual Property Camera Design

A Configurable Hardware Scheduler for Real-Time Systems

Lesson-16: Real time clock DEVICES AND COMMUNICATION BUSES FOR DEVICES NETWORK

How to design and implement firmware for embedded systems

EE8205: Embedded Computer System Electrical and Computer Engineering, Ryerson University. Multitasking ARM-Applications with uvision and RTX

CS 3530 Operating Systems. L02 OS Intro Part 1 Dr. Ken Hoganson

the high-performance embedded kernel User Guide Version 5.0 Express Logic, Inc Toll Free 888.THREADX FAX

This tutorial will take you through step by step approach while learning Operating System concepts.

Deciding which process to run. (Deciding which thread to run) Deciding how long the chosen process can run

Real-Time Scheduling (Part 1) (Working Draft) Real-Time System Example

Chapter 6, The Operating System Machine Level

Operating System Fundamentals Robert Power & Robert Ford

White Paper. Real-time Capabilities for Linux SGI REACT Real-Time for Linux

Embedded OS. Product Information

COS 318: Operating Systems. I/O Device and Drivers. Input and Output. Definitions and General Method. Revisit Hardware

ADVANCED PROCESSOR ARCHITECTURES AND MEMORY ORGANISATION Lesson-17: Memory organisation, and types of memory

Below is a diagram explaining the data packet and the timing related to the mouse clock while receiving a byte from the PS-2 mouse:

Real Time Operating Systems. Tajana Simunic Rosing Department of Computer Science and Engineering University of California, San Diego.

Kernel. What is an Operating System? Systems Software and Application Software. The core of an OS is called kernel, which. Module 9: Operating Systems

Project 11: FreeRTOS TM Real-Time Control of a Stepper Motor

RS-485 Protocol Manual

Accurate Measurement of the Mains Electricity Frequency

Chapter 2: OS Overview

Chapter 2 Basic Structure of Computers. Jin-Fu Li Department of Electrical Engineering National Central University Jungli, Taiwan

Linux scheduler history. We will be talking about the O(1) scheduler

Operating System Tutorial

An Introduction To Simple Scheduling (Primarily targeted at Arduino Platform)

Embedded Operating Systems for Real-Time Applications

Real-Time Operating Systems With Example PICOS18. What is an Operating System?

Process Description and Control william stallings, maurizio pizzonia - sistemi operativi

Lesson 10:DESIGN PROCESS EXAMPLES Automatic Chocolate vending machine, smart card and digital camera

Memory Allocation. Static Allocation. Dynamic Allocation. Memory Management. Dynamic Allocation. Dynamic Storage Allocation

Operating Systems OBJECTIVES 7.1 DEFINITION. Chapter 7. Note:

Microprocessor & Assembly Language

Inside the Windows Vista kernel: Part 1

Microcontroller Systems. ELET 3232 Topic 8: Slot Machine Example

Priority Inversion Problem and Deadlock Situations

MACHINE ARCHITECTURE & LANGUAGE

Real-Time Scheduling 1 / 39

Chapter 11 I/O Management and Disk Scheduling

Scheduling 0 : Levels. High level scheduling: Medium level scheduling: Low level scheduling

Transcription:

The Real-Time Operating System ucos-ii Enric Pastor Dept. Arquitectura de Computadors µc/os-ii Overview µc/os-ii Task Management Rate Monotonic Scheduling Memory Management µc/gui µc/fs

Books and Resources MicroC/OS-II The Real-Time Kernel Second Edition Jean J. Labrosse Copy available in Library MicroC/OS-II e-book (1 st edition) Jean J. Labrosse Will be on the course website shortly µc/os-ii

µ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/gui and µc/fs (GUI and 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 ratio. It supports all type of processors from 8-bit to 64-bit Task Management Services Task Feature Task Creation Task Stack & Stack Checking Task Deletion Change a Task s Priority Suspend and Resume a Task Get Information about a Task

Task Feature µ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. (Something on the lines of Rate Monotonic Scheduling) The task priority number also serves as the task identifier 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, E i be the execution time of task i, and T i be the period of task i. Then, all deadlines will be met if the following inequality is satisfied: E i / T i n(2 1/n 1)

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(2 1/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 your system to use less than 60-70% of the CPU Process Cycle

Task Creation Two functions for creating a task: OSTaskCreate() OSTaskCreateExt() Task Management WAITING DORMANT ISR READY RUNNING

Task Management After the task is created, the task has to get a stack in which it will store its data A stack must consist of contiguous memory locations It is necessary to determine how much stack space a task actually uses. Deleting a task means the task will be returned to its dormant state and does not mean that the code for the task will be deleted. The calling task can delete itself. If another task tries to delete the current task, the resources are not freed and thus are lost. So the task has to delete itself after it uses its resources Task Management (contd..) Priority of the calling task or another task can be changed at run time. A task can suspend itself or another task, a suspended task can resume itself A task can obtain information about itself or other tasks. This information can be used to know what the task is doing at a particular time.

Memory Management The Memory management includes: Initializing the Memory Manager Creating a Memory Partition Obtaining Status of a Memory Partition Obtaining a Memory Block Returning a Memory Block Waiting for Memory Blocks from a Memory Partition Memory Management Each memory partition consists of several fixed-sized memory blocks A task obtains memory blocks from the memory partition A task must create a memory partition before it can be used Allocation and de-allocation of these fixed-sized memory blocks is done in constant time and is deterministic Multiple memory partitions can exist, so a task can obtain memory blocks of different sizes A specific memory block should be returned to its memory partition from which it came

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 Time Management Five services: OSTimeDLY() OSTimeDLYHMSM() OSTimeDlyResume() OSTimeGet() OSTimeSet()

Inter-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) Inter-task communication Single task waiting

Inter-task communication Multiple tasks waiting and signaling Inter-task communication Tasks can wait and signal along with an optional time out

Inter-task communication µc/os-ii semaphores 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 Inter-task communication µc/os-ii message-mailboxes: an µc/osii object that allows a task or ISR to send a pointer sized variable (pointing to a message) to another task.

Inter-task communication µc/os-ii message-queues Available services: Create, Post (FIFO), PostFront (LIFO), Pend, Accept, Query, Flush N = #of entries in the queue: Queue full if Post or PostFront called N times before a Pend or Accept Inter-task communication µc/os-ii message-queues organized as circular buffers.

Writing Applications Under µc/os-ii 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. } } Writing Applications Under µc/os-ii A task that deletes itself after running. For example: void Task (void *) { do this; do that; do the other thing; call OS service (); // e.g. OSTimeDelay, OSSemPend, etc. OSTaskDelete(); // Ask the OS to delete the task }

µc/gui µc/gui

µcgui (Contd..) Memory Devices: Frame buffer, the image of the windows etc are drawn on this buffer and when the drawing is completed, this is copied to the touch screen. This helps in preventing the flickering of the screen. Window Manager: It manages the windows that are created in the GUI. It handles all the mouse and keyboard events (touch screen in this case). Touch Screen: Touch Screen drivers LCD Drivers Anti-aliasing: This smoothens the fonts and other graphical entities. It gives a pleasant affect to the eye instead of the rugged look. µcgui (contd..) Widgets and Dialogs: A library to create the widgets (buttons, textboxes, etc) and dialog boxes. Reduces lot of effort to build everything using pixels and lines Font Converter: It converts a general font format (ttf, utf, etc) to the µcgui compatible fonts Bitmap Converter: It converts the 32-bit bitmap images to the compatible bitmap image that is used on µcgui µcgui supports all the processors from 8-bit to 16-bit

µc/fs µc/fs µc/fs is a FAT file system which can be used on any media Basic hardware access functions has to be provided MS-DOS/MS-Windows compatible FAT12 and FAT16 support Multiple device driver support allows to access different types of hardware with the file system at the same time Multiple media support. A device driver allows you to access different medias at the same time OS support: µc/fs can easily be integrated into any OS

µc/fs Device Drivers µc/fs has been designed to cooperate with any kind of hardware. To use a specific hardware with µc/fs, a device driver for that hardware is required. The device driver consists of basic I/O functions for accessing the hardware and a global table, which holds pointers to these functions. Available drivers are: RAM disk SMC (Smart Card) MMC (Multimedia Card) SD (Secure Digital) CF (Compact Flash) Windows (used by the Visual C++ demonstration and simulation code) IDE Hard Disk