I'm need to know the status of a binary semaphore (i.e. full or empty)
but there doesn't seem to be a function to call that returns such a
value. semShow displays it to stdout and semInfo returns everything
except the status.
Is the semaphore structure documented anywhere such that I can just
check the status myself or has anyone written code which can return the
status?
Thanks,
John Komp
Medtronic
Minneapolis
--
****************************************************
This morning I shot six holes in my freezer
I think I've got cabin fever
Somebody sound the alarm
- J. Buffett
****************************************************
if state.owner != NULL then it's EMPTY, otherwise it's FULL.
= Minh =
If you don't want to muck around in VxWorks semaphore implementation, you can
also perform semTake() with NO_WAIT for the timeout. If semTake() returns
ERROR, the semaphore was empty. If it returns OK, the semaphore was full and is
now empty. Calling semGive() will return it to full.
Admittedly, this approach is most useful in situations where you would want to
take the semaphore, anyway. If you want true status without the overhead of the
semaphore operations, you'll want to muck around in VxWorks semaphore
implementation. Just be forewarned that that implementation could change.
--
Charlie Grames
The Boeing Company
Charles.R.Grames @ boeing.com
Looks like smart reuse of some code.
Again, thanks for the help,
-John Komp
Minh...@jpl.nasa.gov wrote:
> Take a look at target/h/private/semLibP.h for the definition of
> structure "semaphore". SEM_ID is a pointer to this structure, which
> you have accessed once you created a semaphore. Look at
> the structure element "state", which is a union of "count"
> and "owner". As you use binary semaphore, the following
> test tells you either it's empty of full:
>
> if state.owner != NULL then it's EMPTY, otherwise it's FULL.
>
> = Minh =
>
> On Thu, 06 Apr 2000 10:51:33 -0500, "John W. Komp"