Module6 Notes
Module6 Notes
Module 6
μC/OS-II Features
• Jean J. Labrosse designed ucOS in 1992
• uCOS II in 1998 uCOS III in 2009
• μC/OS name derives from MicroController Operating System
• Also known as MUCOS, UCOS, ..
Characteristics
• Multitasking
• Deterministic
• Portable as ROM image
• Scalable
• It supports many CPU that are used in embedded systems
• Different Platforms support
• Full source code availability (www.micrium.com)
• Elegantly and very well documented in the book by its designer
The figure above describes four types of class belonging to the software layer of uC/OS.
Three layers pertain to kernel source files , namely processor-independent code layer,
application-specific code layer and processor-specific code layer.
Processor-Specific code contains functions used to interact with specific hardware and it is
written in assembly language of the processor. Code, describing context switching method and
interrupt handling methods necessary for the execution of upper layer are situated here.
Application-specific and processor-Independent code are written in C language.
Portable:
Most of uC/OS-II is written in highly portable ANSI C, with target microprocessor specific code
written in assembly language. Assembly language is kept to a minimum to make μC/OS -II easy
to port to other processors. OS, μC/OS-II can be ported to a large number of microprocessors as
long as the microprocessor provides a stack pointer and the CPU registers can be pushed onto
and popped from the stack. Also, the C compiler should either provide in-line assembly or
language extensions that allow you to enable and disable interrupts from C.
μC/OS-II can run on most 8-bit, 16-bit, 32-bit or even 64-bit microprocessors or microcontrollers
and, DSPs.
ROMable:
μC/OS-II was designed for embedded applications. This means that if you have the proper tool
chain (i.e. C compiler, assembler and linker/locator), you can embed μC/OS-II as part of a
product.
Scalable:
μC/OS-II is scalable so that you can use only the services that you need in your application. This
allows you to reduce the amount of memory (both RAM and ROM) needed by μC/OS-II on a
product per product basis. Scalability is accomplished with the use of conditional compilation.
You simply specify (through #define constants) which features you need for your product.
Preemptive:
μC/OS-II is a fully-preemptive real-time kernel. This means that μC/OS-II always runs the
highest priority task that is ready. Most commercial kernels are preemptive and μC/OS-II is
comparable in performance with many of them.
Multi-tasking:
The first version of μC/OS-II can manage up to 64 tasks, however, the current version of the
software ucOSII V2.8 priorities can go from 0 (highest priority) to a maximum of 254 (lowest
possible priority). The OS reserves eight (8) of these tasks for system use. Each task has a unique
priority assigned to it. μC/OS-II cannot do round robin scheduling, since no two tasks can have
the same priority.
Deterministic:
Execution time of all μC/OS-II functions and services are deterministic. This means that you can
always know how much time μC/OS-II will take to execute a function or a service.
Task stacks:
Each task requires its own stack, however, μC/OS-II allows each task to have a different stack
size. This allows you to reduce the amount of RAM needed in your application. With μC/OS-II’s
stack checking feature, you can determine exactly how much stack space each task actually
requires.
Services:
uC/OS-II provides a number of system services such as mailboxes, queues, semaphores, fixed-
sized memory partitions, time related functions, etc.
Interrupt Management:
Interrupts can suspend the execution of a task and, if a higher priority task is awakened as a
result of the interrupt, the highest priority task will run as soon as all nested interrupts complete.
Interrupts can be nested up to 255 levels deep.
Robust and reliable:
μC/OS-II is based on μC/OS which has been used in hundreds of commercial applications since
1992. μC/OS-II uses the same core and most of the same functions as μC/OS yet offers more
features.
Task
A task is a program that thinks it has the CPU for itself. A task runs as an infinite loop where all
task behavior happened. Only one task can run at a time. However 255 tasks can cohabit within
the same system. The order of execution is determined by task priority of each task.
A typical task given below:
Changing from one state to another is made by calling the functions displayed on the edges.
VxWorks Features
Signal
• IPC signal used for exception handling or handling software interrupt event
Task functions
• Task creation and activation are two distinct states
• Functions for the task creating, running, waiting, suspending (inhibiting task-execution) and
resuming, spawning (creating followed by activating), task-pending cum suspending .
Comparing uC/OS and VxWorks
uC/OS Vxworks
Developer Micrium, Inc., Silicon Labs Wind River (a wholly owned subsidiary of Intel Corporation)
Platforms ARM Cortex-M3, Cortex- x86 (including Intel Quark), x86-64, MIPS, PowerPC, SH-
M4F, ARM7TDMI; Atmel 4, ARM
AVR
Development C source code can support Host and target based development approach. Supports Device
any C cross compiler Software Optimization (DSO) methodology. Safety and security
certification
RTOS standard Does not support POSIX Supports RTOS standard POSIX
support functions
Interrupt Interrupts can suspend the • Separate context for tasks and ISRs [Each task has a separate
Handling execution of a task and, if a TCB, while ISRs a common stack] Schedules the ISRs
higher priority task is separately and has special functions for interrupt handling
awakened as a result of the
interrupt, the highest
priority task will run as
soon as all nested interrupts
complete. Interrupts can be
nested up to 255 levels
deep.
Round Robin Not supported since tasks Tasks with same priorities can be scheduled by Round robin
scheduling with same priority does not method
exist
Priority Not supported. So there is a Can prevent priority inversion, since the task can get an
Inheritance chance of priority inherited priority.
inversion.
Inter Process Semaphore, Mutex, Event Three different Semaphore functions for Synchronization .
Communication flags. MailBox and • Binary Semaphore for event signal flag,
Message QP. Provides for • Mutex Semaphore for mutually exclusive access using
resource key (mutex)
queuing of the messages.
• Counting semaphore for counting mechanism
Queues can be used for There is no Mailbox in Vxworks. •
priority posting of message Provides for two ways in which a pending task can unblock
using post front – (a) as per task priority (b) as a FIFO, when accepting or
taking an IPC