Heap usage in ThreadX cortex-m ports

HugPeter-9392 246 Reputation points
2022-07-22T09:37:27.46+00:00

Hello
I observe when calling tx_thread_create() use of the IAR c library malloc function from within the file tx_iar.c. See [tx_iar.c][1] and other ports as well.

The function malloc relate to the general purpose heap. ThreadX comes with a feature called memory byte pool. In my understanding, memory byte pools reduce the limitations of the general purpose heap to some degree and are therefore favored. See [chapter3][2]

Questions:

  • Why does the port use the general purpose heap?
  • In my understanding, the general purpose heap is implemented within dl6M_tln.a/dlmalloc.o. According to the map file dl6M_tln.a requires 5744 bytes ROM. This is quite large in our applications. How can I reduce this?
  • Are there options to remove use of the general purpose heap completely?
  • Is it intended to redefine the macro TX_THREAD_CREATE_EXTENSION and TX_THREAD_DELETE_EXTENSION? How would I do that?
  • Other approaches?

Thanks for your help
Peter

Azure RTOS
Azure RTOS
An Azure embedded development suite including a small but powerful operating system for resource-constrained devices.
341 questions
{count} votes

Accepted answer
  1. Scott Azure RTOS 4,051 Reputation points
    2022-07-25T17:36:37.427+00:00
    1. The ThreadX IAR ports only use the heap when TX_ENABLE_IAR_LIBRARY_SUPPORT is defined. This is because the IAR libraries use the heap.
    2. You would have to contact IAR support for how to reduce their heap implementation.
    3. It may be possible to use a ThreadX byte pool instead of the IAR heap; you would need to create a byte pool, redefine the malloc and free functions to tx_byte_allocate and tx_byte_release, and possibly redefine other functions as well. We have not tried to implement this.
    4. To use the IAR libraries, these extensions need to be defined - this is already done in tx_port.h, e.g. https://github.com/azure-rtos/threadx/blob/54cda6ee9e68cd9701d759df13e3f6e41429b9bc/ports/cortex_m4/iar/inc/tx_port.h#L267-L285

    Do you need to use the IAR libraries? If not, then you don't need to do any of the above.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.