Blogs | Technical Articles | Videos

Application developers are not always responsible for the kernel-specific code needed to properly handle interrupts under µC/OS-II, µC/OS-III, Cs/OS2, and Cs/OS3.

Real-time kernels can be viewed as task managers – software modules that allow application developers to write their code as a collection of different tasks. Most kernel-based applications, though, do not consist of tasks alone. Oftentimes, developers of kernel-based applications mix tasks with interrupt service routines, or ISRs, to meet their systems' requirements.

The proper format for an ISR within a kernel-based application varies somewhat according to the kernel being used. Developers who consult the books describing Micrium's µC/OS-II and µC/OS-III kernels learn that ISRs under these kernels should at least roughly resemble the example shown below. The function called near the midpoint of this routine, App_ISR(), represents the application's portion of the ISR, while the rest of the example's pseudo-code can be considered kernel-related.

In a multi-task application based on Micrium's µC/OS-II, µC/OS-III, or Cesium's Cs/OS2, Cs/OS3, the C stack is used in main() and task stacks are used thereafter.

When writing application code for one of Micrium or Cesium's real-time kernels, developers must declare a stack for each of their tasks. These task stacks are used by the kernel to save context (CPU registers) when passing control of the CPU from one task to another, and they are also ultimately used by the tasks' own code during function calls, in place of the C stack. Does the presence of these stacks, then, mean that the C stack is not needed in a system that incorporates Micrium or Cesium kernels? In the following post, we will answer this question and, in doing so, we will examine some important consequences that the kernels' stack usage holds for application code.

A Real-Time Operating System (RTOS) is software that manages the time of a microprocessor or microcontroller. Real-time systems are characterized by the fact that severe consequences can result if logical and timing correctness properties of the system are not met. A real-time multitasking application is a system in which several time-critical activities must be processed simultaneously. A real-time multitasking kernel (also called a real-time operating system, RTOS) is software that ensures that time-critical events are processed as efficiently as possible. The use of an RTOS generally simplifies the design process of a system by allowing the application to be divided into multiple independent elements called tasks.

Jean J. Labrosse, the founder of Micrium and author of the well-known µC/OS series of software and books, presents during the 2021 Embedded Online Conference. In his presentation, Jean demystifies Memory Protection Units, also known as MPUs. He talks about an RTOS without a Memory Protection Unit, an RTOS with process separation using an MPU, inter-process communications, and organizing memory in sections or segments using the IAR tools. Furthermore, a sample linker script is shown and explained to aid in further organizing memory for use with an MPU. As usual, a lengthy list of recommendations is given at the end of the presentation.