Resource sem issue

Steven Seeger steve at stellartec.com
Fri Oct 29 16:16:48 CEST 2004


 Ok fellas. 

I have two threads and a resource semaphore. One thread locks the semaphore
with an rt_sem_wait() and then sleeps for 500 ms, and then releases it. The
other thread runs every 40 ms and tries to get the semaphore with
rt_sem_wait_if.

I call rt_sem_wait_if 3 times each time that thread runs, and print the
result. I then signal the sem 3 times and wait for its period.

The output looks like this:

1 0 0
1 0 0 
1 0 0
1 0 0
1 0 0
1 0 0
1 0 0
0 0 0

Etc

So the question is: why do I get a return value of one and then get a zero
on subsequent calls when I do not, in fact, own the semaphore? When the
semaphore is released (0 0 0) I get 0 all the way around. What is the
purpose of this?

Steve
 





More information about the Rtai mailing list