MicroC/OS-II

From Wikipedia, the free encyclopedia
Jump to: navigation, search
MicroC/OS
Developer Micrium
Written in ANSI C
OS family Real-time operating systems
Working state Production/Stable
Source model Source available
Latest release OS-III
Marketing target Embedded devices
Platforms ARM Cortex-M3, ARM Cortex-M4F, ARM ARM7TDMI, Atmel AVR
Kernel type Microkernel
Default user interface μC/GUI
License Commercial, free for College and Universities
Official website micrium.com/page/products/rtos

MicroC/OS-II (commonly termed as µC/OS-II or uC/OS-II), is the acronym for Micro-Controller Operating Systems Version 2. It is a priority-based pre-emptive real-time multitasking operating system kernel for microprocessors, written mainly in the C programming language. It is intended for use in embedded systems. Its features are:

  • It is a very small real-time kernel.
  • Memory footprint is about 20KB for a fully functional kernel.
  • Source code is written mostly in ANSI C.
  • 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.

MicroC/OS-II is the second generation of a kernel originally published (with source code) in a two-part 1992 article in Embedded Systems Programming magazine and the book µC/OS The Real-Time Kernel by Jean J. Labrosse (ISBN 0-87930-444-8). The author intended at first to simply describe the internals of a portable operating system he had developed for his own use, but later developed the OS as a commercial product.

µC/OS-II is currently maintained by Micrium Inc. and can be licensed per product or per product line. Use of the operating system is free for educational non-commercial use. Additionally, Micrium provides other middleware software products such as µC/CAN, µC/FL, µC/FS, µC/GUI, µC/Modbus, µC/TCP-IP, µC/USB and a large assortment of µC/TCP-IP applications such as client software for DHCP, POP3, SNTP, FTP, TFTP, DNS, SMTP, and TTCP. Server software includes HTTP, FTP, and TFTP. PPP is also available.

On March 24, 2009, Micrium released an enhanced product, µC/OS-III, with licensed source code available for US$9,995 per end-product.[1] µC/OS-III features unlimited number of tasks and priorities, and round robin scheduling.

Task states[edit]

µC/OS-II is a multitasking operating system. Each task is an infinite loop and can be in any one of the following five states:

Task Management (Services)[edit]

  • 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[edit]

μ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 56 tasks for applications. The lower the value of the priority, the higher the priority of the task. (Something along the lines of Rate Monotonic Scheduling). The task priority number also serves as the task identifier.

Task Creation and Management[edit]

There are two functions for creating a task: OSTaskCreate() & OSTaskCreateExt(). After the task is created, the task has to get a stack in which it will store its data. The 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. 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[edit]

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. The services of 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.

Time Management[edit]

A clock tick is a periodic time source to keep track of time delays and time outs. Here, tick intervals varies from 10 ~ 100 ms. The faster the tick rate, the higher the overhead imposed on the system. Whenever a clock tick occurs μC/OS-II increments a 32- bit counter, the counter starts at zero, and rolls over every 4,294,967,295 (2^32-1) ticks. A task can be delayed and a delayed task can also be resumed. It involves five services that includes: OSTimeDLY(), OSTimeDLYHMSM(), OSTimeDlyResume(), OSTimeGet(), OSTimeSet().

Inter-Task Communication[edit]

Inter-task or inter process communication in μC/OS takes place using: Semaphores, Message mailbox, Message queues, Tasks and Interrupt service routines (ISR). They can interact with each other through an ECB (event control block).

Writing Applications Under μC/OS[edit]

Tasks running under a multitasking kernel should be written in one of two ways:

1. 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.
       }
     }

2. 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
      }

Ports[edit]

µC/OS-II has ports for most popular processors and boards in the market and is suitable for use in safety critical embedded systems such as aviation, medical systems and nuclear installations. There are significantly more ports than listed here, and ports are subject to continuous development. If a particular processor isn't listed here, inquiries can be made at Micrium's website.

Altera:

Analog Devices:

ARM:

Atmel:

Freescale/Motorola:

  • 6800/01/02/03
  • 6809
  • 68HC08
  • 68HC11
  • 68HC12
  • 68HC16
  • 680xx
  • 683xx
  • MC9S12
  • M683xx
  • MCF5272
  • MCF5275
  • i.MX21
  • MC9S08
  • MPC551x

Fujitsu:

IBM/AMCC:

Ingenic:

Intel:

Lattice Semiconductor:

Microchip Technology:

Mitsubishi:

NEC:

  • 78K4
  • V850E

NXP Semiconductors:

OpenRISC:

  • OR32

Rabbit Inc:

  • Rabbit4000
  • Rabbit5000

Renesas/Hitachi:

STMicroelectronics:

Texas Instruments:

Xilinx:

See also[edit]

MicroC/OS-III

References[edit]

  1. ^ "Micrium Expands RTOS Family with µC/OS-III" (Press release). Micriµm, Inc. 2009-03-24. Retrieved 2013-10-28. 

External links[edit]