Re: [vox-tech] pthread_cond_timedwait and timespec struct
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [vox-tech] pthread_cond_timedwait and timespec struct
Ricardo Anguiano wrote:
>
> 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 tried it with a 10 second value in theTimeSpec, and saw no
difference. I check for return values less than zero and also check
errno every time and errno is always zero. BTW, checking the return
value for ETIMEDOUT was wrong, I should have been checking errno.
> 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.
The args should be ok. It's not a locks/cond var problem; I have
similar working code in other places. My question is specifically about
this function's normal behavior. It's weird that it doesn't block,
although it is true that cond_wait's can be spuriously woken up under
pthreads standard behavior.
> 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.
Hmm, strange, I would think a small class size would make it EASIER to
get in...? Thanks for the tip.
--
opinions expressed here are not those of my employer!
email: rcook@llnl.gov Rich Cook, Mail Stop L-551 Bldg-3577
Rm-1000
http://www.llnl.gov/graphics Lawrence Livermore National Laboratory
phone (925) 423-9605 (work) 7000 East Avenue
fax (925) 423-9338 Livermore, CA 94550, USA
|