Get state binary semaphore

Suprunenko Evgeniy suprunenko at
Thu Jul 9 10:05:00 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).

uint32_t getState(rtems_id Semaphore)
            Objects_Locations  location;
            Semaphore_Control *sem;
            CORE_mutex_Control           *the_mutex;

            sem = (Semaphore_Control *)_Objects_Get(
              &_Semaphore_Information, Semaphore, &location );

            if ( location != OBJECTS_LOCAL ) {
                        printf( "Bad object lookup", location);

the_mutex = &sem->Core_control.mutex;
Print("lock %x\n", the_mutex->lock);
At my interrupt handler I print elements of structure CORE_mutex_Control:
typedef struct {
uint32_t                lock;
  uint32_t                nest_count;
  uint32_t                blocked_count;
}   CORE_mutex_Control;

At all variants:
nest_count = 1
lock = 0
blocked count increase after every rtems_semaphore_send.

Elements don't change after rtems_semaphore_release

Please, help me. How to get real state?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the users mailing list