On Fri, May 17, 2024 at 1:42 AM 吳岱儒 <tjwu1...@gmail.com> wrote:

> Hi community,
>
> Is Nuttx a hard real time RTOS or software RTOS?
> If Nuttx support hard real time, is there any documentation about this
> feature and design ?
>
> BRs,
> TaiJuWu
>

Hello,

It depends on the CPU architecture:

For example, on ARM Cortex M architecture, the hardware provides an
interrupt vector table which supports multiple interrupt vectors, and
multiple interrupt priority levels, and there is an
interrupt base priority register which allows to keep certain interrupts
enabled while most interrupts are disabled. This hardware support makes it
possible to implement what we call a "Zero Latency Interrupt" (sometimes
called a Raw Interrupt or Unmanaged Interrupt by other RTOSes).

To get a hard real time performance, you would identify the time-critical part
of your software that needs zero latency handling (usually a tiny part of
the whole software) and then design your software to run that part in a
Zero Latency Interrupt. Everything else goes in regular code.

There is a page in the NuttX documentation that explains Zero Latency
Interrupts. See [1].

It may be possible to implement Zero Latency Interrupts for other CPU
architectures besides ARM Cortex M, if the hardware provides mechanisms
that make it possible, such as a way to define a high priority interrupt
that is never disabled.

For the best possible performance, you need to choose your microcontroller
hardware carefully. Look for features like the ability to put your zero
latency interrupt handler and its variables in RAM for faster execution
(because code in FLASH may take longer to fetch). Some microcontrollers
even have a special section of RAM that is faster than the rest for this
exact purpose. For example the STmicro STM32G series has this feature and
calls it CCM SRAM. Other microcontroller vendors might have a similar thing
but call it a different name.

Fortunately NuttX supports many CPU architectures and many microcontroller
models from many hardware vendors, so you have lots of choices. Also if the
microcontroller you want to use isn't currently supported by NuttX, it is
usually not too difficult to add support, especially if there is already
support for something similar.

References:
[1]
https://nuttx.apache.org/docs/12.5.0/guides/zerolatencyinterrupts.html

Hope this helps,
Nathan

Reply via email to