Half a second is pretty short. Are you sure you are just not noticing
the wait? :) Write a small test program using the same code that waits
for 5 seconds with printf("go/stop\n")/fflush around the call, or in a
debugger.
anguiano@home:/usr/include$ grep ETIMEDOUT *
errno.h:#define ETIMEDOUT 60 /* Operation timed out */
I don't know pthreads, but checking your arguments would be a good thing
to do. What does a debugger tell you about the values of your
arguments? Do they match the man page? I don't see where
pcbReadyForSorter_cond and sortWaiting_lock are defined or initialized
or what they should be in order for your code to "block" for .5 seconds.
BTW are you taking Ron Olson's 244? I highly recomend it if you like
parallel programming and do not have an aversion to program correctness
proofs. I think the class size is small, around 15 so if you aren't
already there you probably won't get in.
-Ricardo
Richard Cook <[EMAIL PROTECTED]> writes:
> Anyone know why pthread_cond_timedwait doesn't seem to wait at all
> (noone sends a cond_signal) for the following snippet? I guess maybe
> I'm doing something wrong with TIA
>
> struct timespec theTimeSpec = {0};
> theTimeSpec.tv_sec = 0;
> theTimeSpec.tv_nsec = 500000000;/* 500.0 milliseconds */
> err = pthread_cond_timedwait(&pcbReadyForSorter_cond,
> &sortWaiting_lock,
> &theTimeSpec);
>
> when it returns, err = 147, which I can't seem to find the meaning of.
> When I try to test (err == ETIMEDOUT), my compiler complains that
> ETIMEDOUT is not defined. Wasup?