Micro-Controller Operating Systems
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 |
Micro-Controller Operating Systems (MicroC/OS) is a real-time operating system (RTOS) designed by embedded software developer, Jean J. Labrosse in 1991. It is a priority-based pre-emptive real-time for microprocessors, written mainly in the C programming language. It is intended for use in embedded systems.
MicroC/OS allows you to define several functions in C, each of which can execute as an independent thread or task. Each task runs at a different priority, and thinks that it owns the CPU. Lower priority tasks can be preempted by higher priority tasks at any time. Higher priority tasks use operating system services (such as a delay or event) to allow lower priority tasks to execute. There are operating system services provided for task management, inter-task communication, memory management, and for timing.[1]
History
The MicroC/OS kernel was originally published in a three-part 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 in versions II and III.
Writing Applications Under μC/OS
Tasks running under a multitasking kernel should be written in one of two ways:[2]
- A non-returning endless loop.
- A task that deletes itself after running.
µC/OS-II
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, pre-emptive, real-time, deterministic, multitasking kernel for microprocessors, and DSPs. It manages up to 255 application tasks, and its footprint can be scaled (between 5 Kbytes to 24 Kbytes) to only contain the features required for a specific application.
Most of µC/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.
Applications in Embedded Systems
µC/OS-II was designed for embedded applications, which 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.
µC/OS-II can be found in the following embedded systems
- Avionics
- Medical equipment/devices
- Data communications equipment
- White goods (appliances)
- Mobile phones, 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 (Interrupted (ISR))
Additionally it can manage up to 255 tasks; however, it is recommend that a user reserve eight of these tasks for µC/OS-II, leaving an application up to 247 tasks.[3]
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 operation.[4] The kernel is responsible for task management (i.e., for managing the CPU’s time) and communication between tasks.[5] 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.[6] 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. Non-preemptive kernels require that each task do something to explicitly give up control of the CPU.[7] A preemptive kernel is used when system responsiveness is important; therefore, µC/OS-II and most commercial real-time kernels are preemptive.[8] The highest priority task ready to run is always given control of the CPU.
Assigning of Tasks
Tasks with the highest rate of execution are given the highest priority using rate-monotonic scheduling.[9] This scheduling algorithm is used in real-time operating systems (RTOS) with a static-priority scheduling class.[10]
Task Management
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 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[11]
Memory Management
In order to avoid fragmentation, µC/OS-II allows your application 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.[12]
Time Management
µC/OS-II requires that a user provide a periodic time source 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 actual frequency of the clock tick depends on the desired tick resolution of your application. You can obtain a tick source either by dedicating a hardware timer or by generating an interrupt from an AC power line (50/60 Hz) signal. This periodic time source is called a clock tick.[13]
After a “Clock Tick” is determined, Tasks can be:
- Delaying a Task
- Resume a Delayed Task
Inter-task Communication
Inter-task or inter process communication in µC/OS-II takes place using: Semaphores, message mailbox, message queues, tasks and Interrupt service routines (ISR)). 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.
MicroC/OS-III
µC/OS-III® is the acronym for Micro-Controller Operating Systems Version 3, introduced in 2009 and adding functionality to the µC/OS-II RTOS.
µC/OS-III offers all the features and functionality of µC/OS-II. The biggest difference is the number of tasks. µC/OS-II allows only 1 task at each of 255 priority levels, so a maximum of 255 tasks. µC/OS-III allows an unlimited number of application tasks at each one of an unlimited number of priority levels, constrained only by a processor’s access to memory.[14][15]
µC/OS-II and µC/OS-III are currently maintained by Micrium Inc. and can be licensed per product or per product line.
Applications in Embedded Systems
The applications are the same as for µC/OS-II
Task States
µC/OS-III is a multi-tasking operating system. Each task is an infinite loop and can be in any one of the following five states (See Figure). Task priorities can range from 0 (highest priority) to a maximum of 255 (lowest possible priority).
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, called a quantum, and then selects another task. This process is called 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 µC/OS-III is the same as for µC/OS-II.
Task Management
Task management also functions the same as for µC/OS-II, however, µC/OS-III supports multitasking and allows the application to have any number of tasks. The maximum number of tasks is actually only limited by the amount of memory (both code and data space) available to the processor.
A task can be implemented as a run-to-completion task 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.
Memory Management
Memory management is handled in the same way as performed in µC/OS-II.
Time Management
µC/OS-III offers the same time management features as µC/OS-II. It also provides services to applications so that tasks can suspend their execution for user-defined time delays. Delays are either specified by a number of clock ticks or hours, minutes, seconds, and milliseconds.
Inter-task Communication
It is sometimes necessary for a task or an ISR to communicate information to another task, because it is "unsafe" for two tasks to access the same specific data or hardware resource simultaneously. This can be resolved through information transfer called inter-task communication. This information transfer is called 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 either by disabling interrupts, locking the scheduler, using a semaphore, or preferably, using a mutual-exclusion semaphore. Messages can either be sent to an intermediate object called a message queue, or directly to a task since in µ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. When a task waits for a message to arrive, it does not consume CPU time.
Ports
A port involves three aspects: CPU, OS and board specific (BSP) code. µC/OS-II and 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. μC/OS-III port consists of writing or changing the contents of three kernel specific files - OS_CPU.H, OS_CPU_A.ASM and OS_CPU_C.C. It is necessary to write or change the content of three CPU specific files: CPU.H, CPU_A.ASM and CPU_C.C. 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. If a particular processor isn't listed here, inquiries can be made at Micrium's website.
ARM:
- ARM7TDMI
- ARM720T
- ARM920T
- ARM926EJ-S
- Cortex-M3
- AVR
- AVR32
- AT91SAMxxxxx (ARM7/9)
- 6800/01/02/03
- 6809
- 68HC08
- 68HC11
- 68HC12
- 68HC16
- 680xx
- 683xx
- MC9S12
- M683xx
- MCF5272
- MCF5275
- i.MX21
- MC9S08
- MPC551x
IBM:
- PowerPC 430
- jz4720/25/30/32/40/50/55
- M16C/80
- R8C
- M32C
NEC:
- 78K4
- V850E
- OR12
Rabbit Inc:
- Rabbit4000
- Rabbit5000
- H8/3xx
- H8/5xx
- 64180
References
- ↑ "NiosII GCC with MicroC/OS.". http://people.ece.cornell.edu/land/courses/ece5760/NiosII_muCOS/index.html. External link in
|website=
(help); - ↑ Enric Pastor. "The Real-Time Operating System uCOS-II". p. 14.
- ↑ Labrosse,, Jean J. MicroC/OS-II: The Real Time Kernel (Second ed.). p. 77.
- ↑ Wikiversity:Operating Systems/Kernel Models#Monolithic Kernel
- ↑ Labrosse,, Jean J. MicroC/OS-II: The Real Time Kernel (Second ed.). p. 39.
- ↑ Labrosse,, Jean J. MicroC/OS-II: The Real Time Kernel (Second ed.). p. 40.
- ↑ Labrosse,, Jean J. MicroC/OS-II: The Real Time Kernel (Second ed.). p. 40.
- ↑ Labrosse,, Jean J. MicroC/OS-II: The Real Time Kernel (Second ed.). p. 42.
- ↑ Liu, Chung Lang; Layland, James W. (1973). "Scheduling algorithms for multiprogramming in a hard real-time environment". Journal of the ACM 20 1: 46–61. doi:10.1145/321738.321743.
- ↑ Bovet, Daniel. "Understanding The Linux Kernal".
- ↑ Labrosse,, Jean J. MicroC/OS-II: The Real Time Kernel (Second ed.). pp. 45–49.
- ↑ Labrosse,, Jean J. MicroC/OS-II: The Real Time Kernel (Second ed.). pp. 273–285.
- ↑ Labrosse,, Jean J. MicroC/OS-II: The Real Time Kernel (Second ed.). pp. 145–152.
- ↑ Micrium. "µC/OS-II and µC/OS-III Features Comparison".
- ↑ Micrium. "µC/OS-III overview".
Sources
- Official website
- Protocol Support for µC/OS-II from Fusion Embedded
- Micrium-uCOS-III-UsersManual 1st Edition
- uC/OS-III: The Real-Time Kernel for the Renesas RX62N
External links
- Summary of Commonly Used uC/OS-II Functions and Data Structures
- NiosII GCC with MicroC/OS
- µC/OS-II Reference Manual
- How to Get a µC/OS-II Application Running