This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C1294NCPDT: malloc / new executiton level

Part Number: TM4C1294NCPDT

Hi Folks,

I develop some applications in C++, where I don't use an RTOS, just the C++ standard library and the TivaWare libraries. I !!!assume!!!, when I call some C++ container operation, that needs to reallocate chunks of memory, it will disable the interrupts (e.g.: cpsid). These operation are in the main function only, and beside of this, I need to serve some real time tasks from the interrupt functions (like PWM).

My question is, can I adjust the execution level of a memory allocation, e.g.: set it to interrupt priority 0xE0, while my real time interrupts happen on priority 0x00. I'm open for any idea.

Regards,

Norbert

  • Norbert Toth said:
    I !!!assume!!!, when I call some C++ container operation, that needs to reallocate chunks of memory, it will disable the interrupts (e.g.: cpsid).

    The TI compiler RTS (run-time support library) consider the memory allocation functions as non-reentrant, and non-reentrant functions should not be called from interrupt routines. See the Non-reentrant functions in the RTS (run-time support library) Wiki entry.

    By default the RTS function don't disable interrupts, and they assume a single-threaded mode of operation. As explained in the Handling Reentrancy (_register_lock() and _register_unlock() Functions) section of the compiler user's guide, the RTS provides functions which can be used to install some sort of semaphore protection around critical sections of the RTS to use in a multi-thread environment such as SYS/BIOS.

    If you are using a single-thread program, i.e. without any RTOS, then when the main performs dynamic memory allocation interrupts won't be disabled.

    If you look at the <ccs_install_root>\ccsv7\tools\compiler\ti-cgt-arm_<compiler_version>\lib\src\_lock.c source file the default lock/unlock operation called to protect critical sections of RTS is an empty _nop function.

  • Hi,

    thanks for your reply. I have another applications, where I have to use FreeRTOS (from the TI provided TivaWare example collection). Just for interest: how they solve the reentrant problem in that case? Until now, I didn't faced any hook installation, the links above mentioned.

    Regards,
    Norbert