ucos-ii

19
04/27/22 02:46 AM Micro-Controller Operating Sy stem Version 2 Introduction to µCOS II Presented by Vikram Inoli

Upload: napalanivel

Post on 13-Dec-2015

217 views

Category:

Documents


3 download

DESCRIPTION

it is an RTOS for uCs

TRANSCRIPT

Page 1: uCOS-II

04/18/23 10:10 AM Micro-Controller Operating System Version 2

Introduction toµCOS II

Presented byVikram Inoli

Page 2: uCOS-II

04/18/23 10:10 AM Micro-Controller Operating System Version 2

Overview of μC/OS-II

• μC/OS-II is a highly portable, ROMable, very scalable, preemptive real-time, deterministic, multitasking kernel

• 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 to 64 bit• Memory footprint is about 20KB for a fully

functional kernel.• Source code is about 5,500 lines, in ANSI C.• It’s open source but not free for commercial

usages.

Page 3: uCOS-II

04/18/23 10:10 AM Micro-Controller Operating System Version 2

Features of μC/OS-II

• Source code• Portable• ROMable• Preemptive• Multi-tasking• Deterministic• Task stacks• Services• Interrupt Management• Robust and reliable

Page 4: uCOS-II

04/18/23 10:10 AM Micro-Controller Operating System Version 2

Usage of μC/OS-II in various fields

• Cameras• Medical instruments• Engine control• Musical instruments• Network adapter• Highway telephone call box• ATM machine• Industrial robots• ……

Page 5: uCOS-II

04/18/23 10:10 AM Micro-Controller Operating System Version 2

Porting of μC/OS-II on various platforms

Manufacture MCU• AMD 80x86• Analog Device SHARC (AD21065L)• ARM ARM7• Atmel AVR, AT103• Fujitsu SPARC• Hitachi 64180, H8-300H, H8S,SH2,SH3• Infineon Tri.Core, 80C166/167• Intel Strong ARM110,80C251,XC52, 80x86,

196K• Motorola M68HC08, M68HC11, M68HC12, M68HC16,

M68000, CPU32, DSP568xx, Cold.Fire,M.Core, PowerPC8xx,MPC555

• Philips XA• ST 80C166/167• TI TMS320-C40, TMS320-C6201• Automation V8• Zilog Z-80, Z-180

Page 6: uCOS-II

04/18/23 10:10 AM Micro-Controller Operating System Version 2

Task Management

• Task Creation• Task Stack & Stack Checking• Task Deletion• Suspend and Resume a Task• Get Information about a Task

Page 7: uCOS-II

04/18/23 10:10 AM Micro-Controller Operating System Version 2

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. (Something on the lines of Rate Monotonic Scheduling)

• The task priority number also serves as the task identifier

Page 8: uCOS-II

04/18/23 10:10 AM Micro-Controller Operating System Version 2

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)

Page 9: uCOS-II

04/18/23 10:10 AM Micro-Controller Operating System Version 2

Task States

Page 10: uCOS-II

04/18/23 10:10 AM Micro-Controller Operating System Version 2

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

Page 11: uCOS-II

04/18/23 10:10 AM Micro-Controller Operating System Version 2

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

Page 12: uCOS-II

04/18/23 10:10 AM Micro-Controller Operating System Version 2

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

Page 13: uCOS-II

04/18/23 10:10 AM Micro-Controller Operating System Version 2

Time Management

Five services:

• OSTimeDLY()• OSTimeDLYHMSM()• OSTimeDlyResume()• OSTimeGet()• OSTimeSet()

Page 14: uCOS-II

04/18/23 10:10 AM Micro-Controller Operating System Version 2

Writing application under µCOS-II

• Tasks running under a multitasking kernel should bewritten in one of two ways:

• A non-returning forever loop.• For example:void Task (void *){

PerformInitialisation();while (1){

// What you wish to do; // What else you wish to do;call OS service (); // e.g. OSTimeDelay,

OSSemPend, etc.}

}

Page 15: uCOS-II

04/18/23 10:10 AM Micro-Controller Operating System Version 2

Writing application under µCOS-II• A task that deletes itself after running. • For example:void Task (void *){

// What you wish to do;// What else you wish to do;call OS service (); // e.g. OSTimeDelay,

// OSSemPend, etc.OSTaskDelete(); // Ask the OS to delete the task

}

Page 16: uCOS-II

04/18/23 10:10 AM Micro-Controller Operating System Version 2

Difference between µCOS and µCOS-II• Addition of a fixed-sized memory

manager• User definable callouts on task creation,

task deletion, task switch and system tick

• Supports TCB extensions• Stack checking • μC/OS-II is split into a few source files to

make the code easier to maintain whereas μC/OS (ver1.1) was available in only 2 files

Page 17: uCOS-II

04/18/23 10:10 AM Micro-Controller Operating System Version 2

References

• MicroC/OS-II The Real-Time Kernel Second Edition– Jean J. Labrosse

• MicroC/OS-II e-book (1st edition)– Jean J. Labrosse

Page 18: uCOS-II

04/18/23 10:10 AM Micro-Controller Operating System Version 2

Thank You

Page 19: uCOS-II

04/18/23 10:10 AM Micro-Controller Operating System Version 2

Truth can be stated in a thousand different ways, yet each one can be true.

- Swami Vivekananda