The AVIX System Stack offers a substantial decrease in RAM usage and allows this RAM to be used by your application.

AVIX offers a System Stack for exclusive use by Interrupt Service Routines (ISR’s). Using this System Stack results in a substantial reduction of RAM usage. Some micro controller families (Cortex–M3) offer a second stack pointer in hardware which is always deployed by AVIX for exclusive use by ISR’s. When the hardware does not offer a second stack pointer (PIC32MX & PIC24-dsPIC) AVIX emulates the mechanism at the cost of only a few CPU cycles. In the emulated situation, use of the System Stack is optional might this performance penalty be unacceptable. Using the System Stack or not can be selected per individual Interrupt Service Routine so as a user you are in control for the optimum tradeoff between performance and RAM usage.

Why is a System Stack so important and how does this preserve RAM?

An RTOS based application uses multiple threads, each having its own private stack. Since interrupts occur at unpredictable moments, every stack has to reserve space for the context saved by the ISR which consumes a lot of RAM. When using a System Stack, whenever an interrupt occurs this System Stack is used to allow the ISR to store the context without using the stack of the currently active thread. As a result the overhead on stacks of individual threads can be as low as zero (0), a figure no competing product is capable of offering. The result of this is illustrated below with a PIC32MX based application. Tested is with an application consisting of four threads and four hardware timers generating interrupts. The threads are suspended until resumed by one of the hardware timer interrupts. The figures are screen shots of the AVIX MPLAB RTOS Viewer used to monitor the status of this application.

Without using the AVIX System Stack mechanism, stack RAM usage is
1100 bytes more than with the AVIX System Stack, an increase of over 94%.

Without the AVIX System Stack mechanism, total stack RAM usage of the application is  2260 bytes.

With the AVIX System Stack mechanism, total stack RAM usage of the same application is 1160 bytes.

Figures based on AVIX for PIC32MX version 3.6 and C32 version 1.05


When using AVIX for PIC24-dsPIC or AVIX for PIC32MX, use of the System Stack is optional. Per interrupt handler you can decide to use it or not. Furthermore it is compatible with interrupt handlers using the shadow registers offered by these controllers, a mechanism used when speed is of the utmost importance. Most competing products prevent you from using shadow register based interrupt handlers which is a waste of a very useful performance improving feature.


How does AVIX preserve many Kbytes of RAM

AVIX, like a number of competing products, offers a system stack for use by Interrupt Service Routines. This mechanism is meant to preserve RAM. The advantage of this mechanism with most RTOSes however is small. Even though a system stack is offered, still Interrupt Service Routines place a high load on the stacks of the individual threads. As a result of the unique system stack mechanism offered by AVIX, AVIX places a substantially lower load on the controllers RAM. The graphs below illustrate this. In these graphs you see the amount of RAM used by the RTOS as a function of the number of threads. These graphs are based on:

  • The controller offering 32KRAM
  • Each thread consuming 300 bytes for context saving, bookkeeping and a basic stack for local variables and function calling
  • An interrupt consuming a minimum of 104 bytes, this figure is explained below



The left graph shows the amount of RAM left to the application when using six unique interrupt priority levels, the right graph in case three unique interrupt priority levels are used. As shown, with AVIX for PIC32MX, a substantial higher amount of RAM remains for use by your application. In the case of 16 threads and six interrupt priority levels, with AVIX for PIC32MX ~27KB of RAM is available for use by the application while some competing products only leave ~18KB of RAM for use by the application.

AVIX-RT © 2006-2015, All Rights Reserved

Legal Disclaimer

Privacy Policy