semaphore decremented to -1

Using QNX 4.25, Watcom compiler 10.6 patch B.
I have been using semaphores and threads in my program, I created the
semaphores before the threads in most cases. I have notice that some of the
semaphores have value -1 and I am not sure when it happens and why. I have
about 20 semaphores created.
Please help.

thanks,
Mariola

Kevin Warkentin <kevin.p.warkentin@ca.abb.com> wrote:

Using QNX 4.25, Watcom compiler 10.6 patch B.
I have been using semaphores and threads in my program, I created the
semaphores before the threads in most cases. I have notice that some of the
semaphores have value -1 and I am not sure when it happens and why. I have
about 20 semaphores created.

In most semaphore implementations, negative values of the semaphore are
used to represent the number of processes blocked on a sem_wait(). This
is not specified by Posix – but at least one book on Posix programming
I have notes that this is a common implementation behaviour.

-David

QNX Training Services
dagibbs@qnx.com