Get state binary semaphore

Suprunenko Evgeniy suprunenko at
Mon Jul 13 09:37:14 UTC 2015


> >> 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?
> >

if the semaphore isn't obtained, I don't get error, because in code:

CORE_mutex_Status _CORE_mutex_Surrender(...)
  /* XXX already unlocked -- not right status */

  if ( !the_mutex->nest_count )



I see, that function returns SUCCESSFUL at all variants.

> >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
> >has.
> >
> >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.

My device waits for new packets from UART. Some packets is not for my device.
If receiving packet is not waiting, my user task doesn't must to get it.


More information about the users mailing list