| website = {{URL|www.micrium.com/products}}
}}
'''Micro-Controller Operating Systems''' ('''MicroC/OS''', stylized as '''µCμC/OS''') is a [[real-time operating system]] (RTOS) designed by embedded software developer, Jean J. Labrosse in 1991. It is a priority-based [[Preemption (computing)|preemptive]] [[Real-time computing|real-time]] kernel for [[microprocessor]]s, written mostly in the programming language [[C (programming language)|C]]. It is intended for use in [[embedded system]]s.
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]] (CPU). Lower priority tasks can be preempted by higher priority tasks at any time. Higher priority tasks use operating system (OS) services (such as a delay or event) to allow lower priority tasks to execute. OS services are provided for managing tasks and memory, communicating between tasks, and timing.<ref>{{cite web|url=http://people.ece.cornell.edu/land/courses/ece5760/NiosII_muCOS/|title=NiosII GCC with MicroC/OS|author=<!--Not stated--> |date=June 2006 |website=School of Electrical and Computer Engineering |publisher=Cornell University |access-date=25 April 2017}}</ref>
==History==
The MicroC/OS kernel was published originally in a three-part article in Embedded Systems Programming magazine and the book ''µCμ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 [[Software portability|portable]] operating system he had developed for his own use, but later developed the OS as a commercial product in versions II and III.
==µCμC/OS-II==
Based on the source code written for µCμC/OS, and introduced as a commercial product in 1998, µCμC/OS-II is a [[Software portability|portable]], ROM-able, [[scalable]], preemptive, real-time, deterministic, multitasking [[Kernel (operating system)|kernel]] for [[microprocessor]]s, and [[digital signal processor]]s (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μ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μ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μC/OS-II can be embedded as part of a product.
µCμC/OS-II is used in many embedded systems, including:
* [[Avionics]]
* [[Medical equipment]] and devices
===Task states===
µCμC/OS-II is a [[Computer multitasking|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
*Waiting (for an event)
*Interrupted ([[Interrupt handler|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μC/OS-II, leaving an application up to 247 tasks.<ref>{{cite book|last=Labrosse|first=Jean J.|title=MicroC/OS-II: The Real Time Kernel|page=77|edition=Second}}</ref>
===Kernels===
The [[Kernel (operating system)|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.<ref>[[Wikiversity:Operating Systems/Kernel Models#Monolithic Kernel]]</ref> The kernel is responsible for managing tasks (i.e., for managing the CPU’sCPU's time) and communicating between tasks.<ref>{{cite book|last=Labrosse|first=Jean J.|title=MicroC/OS-II: The Real Time Kernel|page=39|edition=Second}}</ref> The fundamental service provided by the kernel is [[context switch]]ing.
The [[scheduler]] is the part of the kernel responsible for determining which task runs next.<ref name="LabrosseP40">{{cite book|last=Labrosse|first=Jean J.|title=MicroC/OS-II: The Real Time Kernel|page=40|edition=Second}}</ref> 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: [[Computer multitasking#Cooperative multitasking|non-preemptive]] and [[Preemption (computing)|preemptive]]. Nonpreemptive kernels require that each task do something to explicitly give up control of the CPU.<ref name="LabrosseP40" /> A preemptive kernel is used when system responsiveness is more important. Thus, µCμC/OS-II and most commercial real-time kernels are preemptive.<ref>{{cite book|last=Labrosse|first=Jean J.|title=MicroC/OS-II: The Real Time Kernel|page=42|edition=Second}}</ref> The highest priority task ready to run is always given control of the CPU.
===Assigning tasks===
===Managing tasks===
In [[computing]], a task is a unit of [[execution]]. In some [[operating systems]], a task is synonymous with a [[Process (computing)|process]], in others with a [[Thread (computing)|thread]]. In [[batch processing]] computer systems, a task is a unit of execution within a [[Job stream|job]].
The system user of µCμ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’stask's priority
*Suspend and resume a task
*Get information about a task<ref>{{cite book|last=Labrosse|first=Jean J.|title=MicroC/OS-II: The Real Time Kernel|pages=45–49|edition=Second}}</ref>
===Managing memory===
To avoid [[Fragmentation (computing)|fragmentation]], µCμC/OS-II allows applications to obtain fixed-sized memory blocks from a [[Memory management (operating systems)#Partitioned allocation|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]].<ref>{{cite book|last=Labrosse|first=Jean J.|title=MicroC/OS-II: The Real Time Kernel|pages=273–285|edition=Second}}</ref>
===Managing time===
µCμ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 (computing)|overhead]] µCμ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.<ref>{{cite book|last=Labrosse|first=Jean J.|title=MicroC/OS-II: The Real Time Kernel|pages=145–152|edition=Second}}</ref>
After a ''clock tick'' is determined, tasks can be:
===Communicating between tasks===
Intertask or interprocess communication in µCμC/OS-II occurs via: [[Semaphore (programming)|semaphores]], message mailbox, message queues, tasks, and [[Interrupt handler|interrupt service routines]] (ISRs). They can interact with each other when a task or an ISR signals a task through a kernel object called an event control block (ECB). The signal is considered to be an event.
==µCμC/OS-III==
µCμC/OS-III is the acronym for Micro-Controller Operating Systems Version 3, introduced in 2009 and adding functionality to the µCμC/OS-II RTOS.
µCμC/OS-III offers all of the features and functions of µCμC/OS-II. The biggest difference is the number of supported tasks. µCμC/OS-II allows only 1 task at each of 255 priority levels, for a maximum of 255 tasks. µCμC/OS-III allows any number of application tasks, priority levels, and tasks per level, limited only by processor access to memory.<ref>{{cite web |url=http://micrium.com/rtos/ucosiii/rtos-comparison/ |title=µCμC/OS-II and µCμC/OS-III Features Comparison |website=Micrium}}</ref><ref>{{cite web |url=http://micrium.com/rtos/ucosiii/overview/ |title=µCμC/OS-III overview |website=Micrium}}</ref>
µCμC/OS-II and µCμC/OS-III 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 for µCμC/OS-II
===Task states===
µCμC/OS-III is a [[Computer multitasking|multitasking]] operating system. Each task is an infinite loop and can be in any one of five states (dormant, ready, running, interrupted, or pending). Task priorities can range from 0 (highest priority) to a maximum of 255 (lowest possible priority).
===Round robin scheduling===
===Kernels===
The kernel functionality for µCμC/OS-III is the same as for µCμC/OS-II.
===Managing tasks===
Task management also functions the same as for µCμC/OS-II, however, µCμC/OS-III 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|memory]] (both code and data space) available to the processor.
A task can be implemented via [[run to completion scheduling]], 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 µCμC/OS-II.
===Managing time===
µCμC/OS-III offers the same time managing features as µCμC/OS-II. 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 [[millisecond]]s.
===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 [[interrupt]]s. If two tasks share data, each can gain exclusive access to variables by either disabling interrupts, locking the scheduler, using a [[Semaphore (programming)|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 µCμC/OS-III, 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 (BSP) code. µCμC/OS-II and µCμC/OS-III 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 μC/OS-III port involves writing or changing the contents of three kernel specific files: <code>OS_CPU.H</code>, <code>OS_CPU_A.ASM</code>, and <code>OS_CPU_C.C</code>. It is necessary to write or change the content of three CPU specific files: <code>CPU.H</code>, <code>CPU_A.ASM</code>, and <code>CPU_C.C</code>. Finally create or change a board support package (BSP) for the evaluation board or target board being used. A μC/OS-III port is similar to a μC/OS-II port. There are significantly more ports than listed here, and ports are subject to continuous development. Both µCμC/OS-II and µCμC/OS-III are supported by popular [[Transport Layer Security|SSL/TLS]] libraries such as [[wolfSSL]], which ensure security across all connections.
==References==
==Sources==
*[http://www.mil-embedded.com/news/db/?13968 Protocol Support for µCμC/OS-II from Fusion Embedded]
*Micrium-uCOS-III-UsersManual 1st Edition
*[http://micrium.com/download/%C2%B5cos-iii-the-real-time-kernel-for-the-renesas-rx62n/ uC/OS-III: The Real-Time Kernel for the Renesas RX62N]
*[http://people.ece.cornell.edu/land/courses/ece5760/NiosII_muCOS/uC_Functions.html Summary of Commonly Used uC/OS-II Functions and Data Structures]
*[http://people.ece.cornell.edu/land/courses/ece5760/NiosII_muCOS/ NiosII GCC with MicroC/OS]
*[http://www.win.tue.nl/~mholende/automotive/uCOS-II-RefMan.pdf µCμC/OS-II Reference Manual]
*[http://ftp1.digi.com/support/documentation/0220047_e.pdf How to Get a µCμC/OS-II Application Running]
{{Real-time operating systems}}
|