You are on page 1of 19

Introduction to

COS II

Presented by
Vikram Inoli
09/02/15 03:01 PM

Micro-Controller Operatin

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.
Its open source but not free for commercial
usages.
09/02/15 03:01 PM

Micro-Controller Operatin

Features of C/OS-II

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

09/02/15 03:01 PM

Micro-Controller Operatin

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

09/02/15 03:01 PM

Micro-Controller Operatin

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

09/02/15 03:01 PM

Micro-Controller Operatin

Task Management

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

09/02/15 03:01 PM

Micro-Controller Operatin

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

09/02/15 03:01 PM

Micro-Controller Operatin

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)

09/02/15 03:01 PM

Micro-Controller Operatin

Task States

09/02/15 03:01 PM

Micro-Controller Operatin

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

09/02/15 03:01 PM

Micro-Controller Operatin

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

09/02/15 03:01 PM

Micro-Controller Operatin

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
09/02/15 03:01 PM

Micro-Controller Operatin

Time Management
Five services:

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

09/02/15 03:01 PM

Micro-Controller Operatin

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:
voidTask(void*)
{
PerformInitialisation();
while(1)
{
//Whatyouwishtodo;
//Whatelseyouwishtodo;
callOSservice();//e.g.OSTimeDelay,
OSSemPend,etc.
}
}

09/02/15 03:01 PM

Micro-Controller Operatin

Writing application under


COS-II

A task that deletes itself after running.


For example:

voidTask(void*)
{
//Whatyouwishtodo;
//Whatelseyouwishtodo;
callOSservice();//e.g.OSTimeDelay,
//OSSemPend,etc.
OSTaskDelete();//AsktheOStodeletethetask
}

09/02/15 03:01 PM

Micro-Controller Operatin

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
09/02/15 03:01 PM

Micro-Controller Operatin

References
MicroC/OS-II The Real-Time Kernel
Second Edition
Jean J. Labrosse
MicroC/OS-II e-book (1st edition)
Jean J. Labrosse

09/02/15 03:01 PM

Micro-Controller Operatin

Thank You

09/02/15 03:01 PM

Micro-Controller Operatin

Truth can be stated in a


thousand different ways, yet
each one can be true.
- Swami Vivekananda
09/02/15 03:01 PM

Micro-Controller Operatin

You might also like