Get state binary semaphore

Nick Withers nick.withers at
Sat Jul 11 04:25:49 UTC 2015

Hello Evgeniy,

On Thu, 2015-07-09 at 13:05 +0300, Suprunenko Evgeniy wrote:
> Hello.
> I am trying to get state of my binary semaphore. I need state, because I release semaphore at my interrupt handler (If semaphore didn't obtained, I must print error).
> I found similar sample in testsuites (sptests/spincritical06).

I'm not sure I'm understanding your scenario.

You say you release the semaphore in the interrupt handler (which is
fine) then if the semaphore isn't obtained you must error... What's
obtaining the semaphore? A user task, right? So error there if there's
some reason the semaphore obtain fails?

But it shouldn't be possible for it to fail... It should either block
because the interrupt hasn't happened or succeed and return because it

Is it that you want to error if the interrupt happens again without the
user-space task having handled it? If so, I'd say that's a bad idea in
general, because you simply can't guarantee that the user-space task
will run between two interrupts.

Can you design things such that the interrupt source is not reenabled
until the user-space task has been woken and done its thing? Yes, you
may miss interrupts. The alternative is that you may never be *not*
servicing the interrupt.
Nick Withers
email: nick at

More information about the users mailing list