Hi,
Can we use "std::new" call inside HWI/SWI context for allocating memory?
Regards,
Sandhya
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.
Hi,
Can we use "std::new" call inside HWI/SWI context for allocating memory?
Regards,
Sandhya
Thanks for the response.
But I haven't get the reason why "std::new" is not allowed in HWI/SWI context.
I am working with TM4C1294KCPDT controller and using TI-RTOS 2.16 version. For the project purpose, I want to create a hardware timer and in the timer
callback need to allocate memory for updating some buffer and the same needs to be send it via Mailbox_post().
Whether this memory allocation will create any issue or not ?
Regards,
sandhya
Sandhya,
TI-RTOS by defaults supplies the "malloc" function. It calls HeapMem_alloc (again by default). HeapMem uses semaphores (actually a Gate that is based on a semaphore) by default. Since "new" calls "malloc", your Hwi (or Swi) could be calling Semaphore_pend with a non-zero timeout, which is a no-no.
You can change the behavior of malloc by supplying a different default heap that don't use a Gate (e.g. use HeapBuf or HeapMultiBuf), but then you have to have a good idea on what the bucket sizes should be for the heap.
You can use a Hwi friendly gate (e.g. GateHwi) within HeapMem, but realize this will impact interrupt latency since internal traversals of the HeapMem freelist will be done with interrupts disabled.
Todd
Thanks Todd for the details.
I would like to know from where I can get those information , like "new" internally calls HeapMem_alloc() of TI-RTOS,
so that we can avoid such usages in future.
Regards,
Sandhya
Hi,
I would like to know from where I can get those information , like "new" internally calls HeapMem_alloc() of TI-RTOS?
Regards,
Sandhya
Hi Sandhya,
Todd is currently out of office so responses may be delayed.
In the meantime, I can recommend you check the TI-RTOS (SYSBIOS) API Documentation.
Derrick