Timer callbacks

paulgcoleman wrote on Monday, March 12, 2012:

If I give a semaphore from within a software timer callback do I need to use xSemaphoreGiveFromISR() version?

Thanks, Paul.

rtel wrote on Monday, March 12, 2012:

No.  Timer callbacks run in the context of a task, so the non ISR version can be used.  If the function is being called from a timer callback then the block time must be set to 0.

Regards.

paulgcoleman wrote on Monday, March 12, 2012:

I’m not sure which function you’re referring to and xSemaphoreGive doesn’t have a block time?

Thanks, Paul.

richard_damon wrote on Monday, March 12, 2012:

I think Richard was just making a general comment so that if, for example, a timer function wanted to put or get data from a queue that it should use a zero block time.

I would use the word should rather than must here, as unlike in the idle hook, where blocking will likely cause a kernel crash (as suddenly NO task is ready to run), a block in a timer function doesn’t cause this level of problem, the user just needs to realize that if one timer function blocks, it block the whole timer task, so no other timer functions will run, nor will the program be  able to process any new timer requests (they can be queued up in the timer queue until full, but the timer task won’t be removing them).  There may be special conditions where this is acceptable.

paulgcoleman wrote on Monday, March 12, 2012:

Okay I see, thanks for the clarification :o)