Micro-Controller Operating Systems
Micro-Controller Operating Systems is a real-time operating system designed by Jean J. Labrosse in 1991. It is a priority-based preemptive real-time kernel for microprocessors, written mostly in the programming language C. It is intended for use in embedded systems.
MicroC/OS allows defining several functions in C, each of which can execute as an independent thread or task. Each task runs at a different priority, and runs as if it owns the central processing unit. Lower priority tasks can be preempted by higher priority tasks at any time. Higher priority tasks use operating system services to allow lower priority tasks to execute. OS services are provided for managing tasks and memory, communicating between tasks, and timing.
History
The MicroC/OS kernel was published originally in a three-part article in Embedded Systems Programming magazine and the book The Real-Time Kernel by Labrosse. He intended at first to simply describe the internals of a portable OS he had developed for his own use, but later developed it as a commercial product in his own company Micrium, Inc. in versions II and III.In 2016 Micrium, Inc. was acquired by Silicon Laboratories and it was subsequently released as open-source under the Apache license.
Silicon Labs continues to maintain an open-source product named Micrium OS for use on their own silicon and a group of former Micrium, Inc. employees provides consultancy and support for both and Cesium RTOS, a proprietary fork made just after the open-source release.
μC/OS-II
Based on the source code written for, and introduced as a commercial product in 1998, is a portable, ROM-able, scalable, preemptive, real-time, deterministic, multitasking kernel for microprocessors, and digital signal processors. It manages up to 64 tasks. Its size can be scaled to only contain the features needed for a given use.Most of 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
was designed for embedded uses. If the producer has the proper toolchain, can be embedded as part of a product.is used in many embedded systems, including:
- Avionics
- Medical equipment and devices
- Data communications equipment
- White goods
- Mobile phones, personal digital assistants, MIDs
- Industrial controls
- Consumer electronics
- Automotive
Task states
is a multitasking operating system. Each task is an infinite loop and can be in any one of the following five states- Dormant
- Ready
- Running
- Waiting
- Interrupted
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 and communicating between tasks. 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. 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, 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 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 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
Managing memory
To avoid fragmentation, 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.Managing time
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 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 power line signal. This periodic time source is termed a clock tick.After a clock tick is determined, tasks can be:
- Delaying a task
- Resume a delayed task
Communicating between tasks
Intertask or interprocess communication in occurs via: semaphores, message mailbox, message queues, tasks, and interrupt service routines. They can interact with each other when a task or an ISR signals a task through a kernel object called an event control block. The signal is considered to be an event.μC/OS-III
is the acronym for Micro-Controller Operating Systems Version 3, introduced in 2009 and adding functionality to the RTOS.offers all of the features and functions of. The biggest difference is the number of supported tasks. allows only 1 task at each of 255 priority levels, for a maximum of 255 tasks. allows any number of application tasks, priority levels, and tasks per level, limited only by processor access to memory.
and are currently maintained by Micrium, Inc., a subsidiary of Silicon Labs, and can be licensed per product or per product line.
Uses in embedded systems
The uses are the same as forTask states
is a multitasking operating system. Each task is an infinite loop and can be in any one of five states. supports an unlimited number of task priorities but configuring to have between 32 and 256 task priorities typically suits most embedded systems well.Round robin scheduling
When two or more tasks have the same priority, the kernel allows one task to run for a predetermined amount of time, named a quantum, and then selects another task. This process is termed round robin scheduling or time slicing. The kernel gives control to the next task in line if:- The current task has no work to do during its time slice, or
- The current task completes before the end of its time slice, or
- The time slice ends.
Kernels
The kernel functionality for is the same as for.Managing tasks
Task management also functions the same as for. However, supports multitasking and allows an application to have any number of tasks. The maximum number of tasks is limited by only the amount of computer memory available to the processor.A task can be implemented viarunning to scheduled completion, in which the task deletes itself when it is finished, or more typically as an infinite loop, waiting for events to occur and processing those events.
Managing memory
Memory management is performed in the same way as in.Managing time
offers the same time managing features as. It also provides services to applications so that tasks can suspend their execution for user-defined time delays. Delays are specified by a number of either clock ticks, or hours, minutes, seconds, and milliseconds.Communicating between tasks
Sometimes, a task or ISR must communicate information to another task, because it is unsafe for two tasks to access the same specific data or hardware resource at once. This can be resolved via an information transfer, termed inter-task communication. Information can be communicated between tasks in two ways: through global data, or by sending messages.When using global variables, each task or ISR must ensure that it has exclusive access to variables. If an ISR is involved, the only way to ensure exclusive access to common variables is to disable interrupts. If two tasks share data, each can gain exclusive access to variables by either disabling interrupts, locking the scheduler, using a semaphore, or preferably, using a mutual exclusion semaphore. Messages can be sent to either an intermediate object called a message queue, or directly to a task, since in, each task has its own built-in message queue. Use an external message queue if multiple tasks are to wait for messages. Send a message directly to a task if only one task will process the data received. While a task waits for a message to arrive, it uses no CPU time.
Ports
A port involves three aspects: CPU, OS, and board specific code. and have ports for most popular processors and boards in the market and are suitable for use in safety critical embedded systems such as aviation, medical systems, and nuclear installations. A port involves writing or changing the contents of three kernel specific files:OS_CPU.H, OS_CPU_A.ASM, and OS_CPU_C.C. Finally create or change a board support package for the evaluation board or target board being used. A port is similar to a port. There are significantly more ports than listed here, and ports are subject to continuous development. Both and are supported by popular SSL/TLS libraries such as wolfSSL, which ensure security across all connections.