Uses in Embedded Systems
Uses in Embedded Systems
Uses in Embedded Systems
The MicroC/OS kernel was published originally in a three-part article in Embedded Systems
Programming magazine and the book μC/OS The Real-Time Kernel by Jean J. Labrosse). 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 in versions II
and III.
Based on the source code written for μC/OS, and introduced as a commercial product in
1998, μC/OS-II is a portable, ROM-able, scalable, preemptive, real-time, deterministic,
multitasking kernel for microprocessors, and digital signal processors (DSPs). It manages up
to 255 application tasks. Its size can be scaled (between 5 and 24 Kbytes) to only contain the
features needed for a given use.
Most of μC/OS-II is written in highly portable ANSI C, with target microprocessor-specific
code written in assembly language. Use of the latter is minimized to ease porting to other
processors.
Uses in embedded systems
μC/OS-II was designed for embedded uses. If the producer has the proper tool chain (i.e., C
compiler, assembler, and linker-locator), μC/OS-II can be embedded as part of a product.
μC/OS-II is used in many embedded systems, including:
Avionics
Medical equipment and devices
Data communications equipment
White goods (appliances)
Mobile phones, personal digital assistants (PDAs), MIDs
Industrial controls
Consumer electronics
Automotive
Task states
μ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 (see figure below additionally)
Dormant
Ready
Running
Waiting (for an event)
Interrupted (interrupt service routine (ISR))
Further, it can manage up to 255 tasks. However, it is recommended that eight of these tasks
be reserved for μC/OS-II, leaving an application up to 247 tasks.
Kernels
The kernel is the name given to the program that does most of the housekeeping tasks for the
operating system. The boot loader hands control over to the kernel, which initializes the
various devices to a known state and makes the computer ready for general operations. The
kernel is responsible for managing tasks (i.e., for managing the CPU's time) and
communicating between tasks.[4] The fundamental service provided by the kernel is context
switching.
The scheduler is the part of the kernel responsible for determining which task runs next.
[5]
Most real-time kernels are priority based. In a priority-based kernel, control of the CPU is
always given to the highest priority task ready to run. Two types of priority-based kernels
exist: non-preemptive and preemptive. Nonpreemptive kernels require that each task do
something to explicitly give up control of the CPU. A preemptive kernel is used when system
responsiveness is more important. Thus, μC/OS-II and most commercial real-time kernels are
preemptive. The highest priority task ready to run is always given control of the CPU.
Assigning tasks
Tasks with the highest rate of execution are given the highest priority using rate-monotonic
scheduling. This scheduling algorithm is used in real-time operating systems (RTOS) with
a static-priority scheduling class.
Managing tasks
In computing, a task is a unit of execution. In some operating systems, a task is synonymous
with a process, in others with a thread. In batch processing computer systems, a task is a unit
of execution within a job. The system user of μC/OS-II is able to control the tasks by using
the following features:
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[9]
Managing memory
To avoid fragmentation, μC/OS-II allows applications to obtain fixed-sized memory blocks
from a partition made of a contiguous memory area. All memory blocks are the same size,
and the partition contains an integral number of blocks. Allocation and deallocation of these
memory blocks is done in constant time and is a deterministic system.[10]
Managing time
μC/OS-II requires that a periodic time source be provided to keep track of time delays and
timeouts. A tick should occur between 10 and 1000 times per second, or Hertz. The faster the
tick rate, the more overhead μC/OS-II imposes on the system. The frequency of the clock tick
depends on the desired tick resolution of an application. Tick sources can be obtained by
dedicating a hardware timer, or by generating an interrupt from an alternating current (AC)
power line (50 or 60 Hz) signal. This periodic time source is termed a clock tick.[11]
After a clock tick is determined, tasks can be:
Delaying a task
Resume a delayed task