#70 patch: generalise the stack checking functions


Generalise the stack checking functions so in the future not only one but additional stacks can be checked.

This is against V7.3.0.


  • addon patch:
    move stack overflow callback function prototypes from tasks.c to StackMacros.h
    to be able to use these macros during FreeRTOS bootup for system stack
    overflow checking in the port layer

  • Richard

    I don't want to introduce inline function.

    I could add in API functions that call the existing macros so they are accessed externally, but there is already a "get stack high water mark" function, so would there be a benefit?

  • Christenson

    I'm using 8.2.1, and remark that the CPU I am using has hardware stack overflow protection. Remarks in the source state that the methods used for stack overflow protection aren't 100% reliable because events, like accesses to invalid pointers, might prevent the protection code from being reached after an overflow.
    I would like to see the hooks so I could turn on the port/CPU-specific hardware overflow protection (basically, a stack pointer limit register and a hardware trap) in the configuration file,
    Apologies for the necropost!

  • I think supporting the stack limit registers on the Microblaze is on the roadmap, but I'm not sure about other parts. Not a generic solution, and a bit DIY, but it should be possible for you to use the trace macros to add support for the stack limit registers into your application without changing the core kernel code. The traceTASK_SWITCHING_IN() macro can be defined to read the stack limits from the TCB (pxCurrentTCB is accessible in the file from which traceTASK_SWITCHED_IN() is called) and then program the stack limit registers accordingly.