From: "Fu Limin" <limin.fu@ircc.it>
To: "Dmitrii Sernii" <bogolt@gmail.com>
Cc: pthreads-win32@sources.redhat.com
Subject: Re: Problem with pthread_cond_timedwait()
Date: Wed, 28 Sep 2005 08:38:00 -0000 [thread overview]
Message-ID: <1062.130.192.136.198.1127896722.squirrel@130.192.136.198> (raw)
In-Reply-To: <277109545.20050927184845@gmail.com>
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
>
>
next prev parent reply other threads:[~2005-09-28 8:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-27 11:13 Fu Limin
2005-09-27 13:16 ` Dmitrii Sernii
[not found] ` <1130.130.192.136.198.1127830895.squirrel@130.192.136.198>
2005-09-27 15:49 ` Dmitrii Sernii
2005-09-28 8:38 ` Fu Limin [this message]
-- strict thread matches above, loose matches on Subject: below --
2002-07-22 21:19 Nir Nizry
2002-07-24 0:31 ` Ross Johnson
2002-07-31 0:13 ` Ross Johnson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1062.130.192.136.198.1127896722.squirrel@130.192.136.198 \
--to=limin.fu@ircc.it \
--cc=bogolt@gmail.com \
--cc=pthreads-win32@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).