This is the mail archive of the
pthreads-win32@sourceware.org
mailing list for the pthreas-win32 project.
Problem with pthread_cond_timedwait()
- From: "Fu Limin" <limin dot fu at ircc dot it>
- To: pthreads-win32 at sources dot redhat dot com
- Date: Tue, 27 Sep 2005 13:12:58 +0200 (CEST)
- Subject: Problem with pthread_cond_timedwait()
- Reply-to: limin dot fu at ircc dot it
Hello,
There is a strange problem with pthread_cond_timedwait() in my program
using pthread-win32, I found it doesn't
wait at all. Here is part of the codes,
struct timespec timeout;
timeout.tv_sec = time(NULL) + 10;
timeout.tv_nsec = 0;
pthread_cond_timedwait( & myCondVar, & mutex->myMutex, &timeout );
This part works as expected under linux. The compiler I used is gcc3.4.2,
and I used the pre-built pthread-win32, v2.7.
Am I using pthread_cond_timedwait() properly?
Another question, I saw in pthread documentations that the "timeout" is
prepare in the following way,
struct timeval now;
struct timespec timeout;
gettimeofday(&now);
timeout.tv_sec = now.tv_sec + 5;
timeout.tv_nsec = now.tv_usec * 1000;
But I found it won't work without modification, in Linux, it complain
gettimeofday() needs another parameter
(something like timezone, if I remember well), and in Windows the compiler
complain gettimeofday() is not
defined. So what is the "most" standard or correct way to prepare "timeout"?
Thanks a lot,
Limin
PS, I was trying to send this email by my gmail account,
but it didn't work with this mailling list.