From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10886 invoked by alias); 28 Sep 2005 08:38:58 -0000 Mailing-List: contact pthreads-win32-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: pthreads-win32-owner@sources.redhat.com Received: (qmail 10727 invoked by uid 22791); 28 Sep 2005 08:38:49 -0000 Received: from opterone.unito.it (HELO mail-out.unito.it) (130.192.119.88) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Wed, 28 Sep 2005 08:38:49 +0000 Received: (from root@localhost) by mail-out.unito.it (8.12.3/8.12.3/Debian -4) id j8S8clVF021253 for ; Wed, 28 Sep 2005 10:38:47 +0200 Received: from webservices.unito.it (webservices.unito.it [130.192.119.81]) by mail-out.unito.it (8.12.3/8.12.3/Debian -4) with ESMTP id j8S8chSL021206; Wed, 28 Sep 2005 10:38:43 +0200 Received: from 130.192.136.198 (SquirrelMail authenticated user lfu); by webservices.unito.it with HTTP; Wed, 28 Sep 2005 10:38:42 +0200 (CEST) Message-ID: <1062.130.192.136.198.1127896722.squirrel@130.192.136.198> In-Reply-To: <277109545.20050927184845@gmail.com> References: <1402.130.192.136.198.1127819578.squirrel@130.192.136.198> <731315850.20050927161549@gmail.com> <1130.130.192.136.198.1127830895.squirrel@130.192.136.198> <277109545.20050927184845@gmail.com> Date: Wed, 28 Sep 2005 08:38:00 -0000 Subject: Re: Problem with pthread_cond_timedwait() From: "Fu Limin" To: "Dmitrii Sernii" Cc: pthreads-win32@sources.redhat.com Reply-To: limin.fu@ircc.it User-Agent: SquirrelMail/1.4.3a MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Inrete-Amavisjob-Virus-Scanned: PDAmail Multiple Antivirus with ClamAv X-Inrete-Amavisjob-Service-Runned: 6 (j8S8chSL021206) X-Inrete-Amavisjob-Service-Disabled: No Service disabled (j8S8chSL021206) X-SW-Source: 2005/txt/msg00122.txt.bz2 Hi Dmitrii, Thank you very much! The problem is solved after locking the mutex before calling the function. I was trying to implement a sleep() function using pthread_cond_timedwait(), so the thread calling this function will never be signaled. I thought the using mutex is necessary only if pthread_cond_timedwait() is used together with pthread_cond_signal/broadcast(). In fact, it works in Linux without locking the mutex, so I thought it must be a problem of something else. Best regards, Limin > Hello, > > for me this timeout makes cond_timedwait wait for 10 seconds: > timespec timeout; > timeout.tv_sec = time(0)+10; > timeout.tv_nsec = 0; > > Try to check return code of the pthread_cond_timedwait. Probably you > forgot to initialize mutex, or lock it before calling this function. > > FL> SYSTEMTIME now; > FL> GetLocalTime( &now ); > FL> timeout.tv_sec = now.wSecond + sec; > FL> timeout.tv_nsec = now.wMilliseconds*1E6 + nsec; > this code will not work, because wSeconds - maximum value is 59. To > use GetLocalTime you'll need to use all values starting from wYear.. > multiply them on number of seconds they have and add to each other. > > > -- > Best regards, > Dmitrii Sernii > >