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.

RTOS: How use Memory_alloc in a Hwi interrupt function? And can I use Task_restore to invoke a task in an interrupt?



Tool/software: TI-RTOS

How use Memory_alloc in a Hwi interrupt function?  And can I use Task_restore to invoke a task in an interrupt?    Thanks!

BIOS 6.46.5.55  run on TMS28379D    CCS 6.2.0.00050

  • Hi,

    Memory allocation from a Hwi is generally not recommended due to non-deterministic duration and the fact that many heap implementations (especially HeapMem which is the default heap) use semaphores for synchronization. If you do, make sure the underlying heap implementation is non-blocking (e.g. HeapBuf). Take a look at the SYS/BIOS memory example to see usage of HeapBuf.

    You can use Task_restore in a Hwi . It's not the most common usage though since Task_disable disables all tasks except for the current one from running. I'm not really sure what you mean by "invoke a task". The typical setups for tasks are
    - Task blocks on a semaphore and have the Hwi (or Clock module) post the semaphore.
    - Task calls Task_sleep
    - Task blocks on Mailbox_pend and is unblocked by a thread calling Mailbox_post (along with a msg).

    Todd