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.

From where may Semaphore_post/pend() be called?

Other Parts Discussed in Thread: SYSBIOS

Hi,

while debugging another problem, I had to modify the SYS/BIOS sources to insert a hook for a conditional breakpoint. I activated the option to build SYS/BIOS from sources instead of using a pre-compiled library. This resulted in enabling asserts, which were previously not active.

While running my application, I got the following error:

ti.sysbios.knl.Semaphore: line 204: assertion failure: A_badContext: bad calling context. Must be called from a Task.

A quick Google search pointed me to this thread:

http://e2e.ti.com/support/embedded/bios/f/355/t/223605.aspx

According to this, semaphores may only be posted from task context. I couldn't believe that was the case, so I checked the SYS/BIOS manual. In section '3.2.5 Yielding and Preemption' it says:

"Semaphores can be posted from Hwis and Swis as well as from other tasks."

Could someone please clarify this? I have an application on which a team has been working for months and it depends on SWIs and HWIs performing post operations on semaphores to delegate work to tasks. I know that  line 204 in 'semaphore.c' is in the 'Semaphore_pend' section and I will correct my code, but I want to be absolutely sure that my application is solid and not just working by chance.

Thanks

Torben Frenzel

  • Torben,

    Semaphore_post() is designed specifically to be called from ANY thread (Hwi, Swi, Task) in order to ready a Task that may be blocked on the semaphore, waiting for some event to occur.

    Semaphore_pend() is a blocking API, and as such must only be called from a Task context.

    Alan

  • I know this is old but I just spent 2 days trying to troubleshoot an issue and the result shows that this answer is only 99% percent complete.. BIOS API calls like Semaphore_post can NOT be called from zero latency HWI's (as the dispatcher is not used) or else you will get stack overflows. Hope this helps someone.

  • CM2015 said:

    I know this is old but I just spent 2 days trying to troubleshoot an issue and the result shows that this answer is only 99% percent complete.. BIOS API calls like Semaphore_post can NOT be called from zero latency HWI's (as the dispatcher is not used) or else you will get stack overflows. Hope this helps someone.

    What HWI's are considered zero latency? For those HWI's that are zero latency how can we achieve the same effect as a semaphore post?