From: "Steve Croall (TIBCO)" <tibco.croall@btinternet.com>
To: Allan Comar <acomar@commodity.com.br>
Cc: pthreads-win32@sources.redhat.com
Subject: Re: pthread_cond_timedwait
Date: Fri, 10 Jun 2005 20:23:00 -0000 [thread overview]
Message-ID: <42A9F6CB.9070304@btinternet.com> (raw)
In-Reply-To: <9F29CF63398CDA4E8F98170E30D4230727C1D7@cs01i00388.commodity.com.br>
Hi,
The timeout parameter you pass to pthread_cond_timedwait() is a struct
timespec type, which is defined in pthread.h, if HAVE_STRUCT_TIMESPEC is
not defined at build time.
struct timespec {
long tv_sec;
long tv_nsec;
};
Just set the tv_nsec to the amount of nanoseconds required. The pthread
source on Windows uses the following calculation to convert the above
structure to milliseconds:
tmpAbsMilliseconds = (int64_t)abstime->tv_sec * MILLISEC_PER_SEC;
tmpAbsMilliseconds += ((int64_t)abstime->tv_nsec +
(NANOSEC_PER_MILLISEC/2)) / NANOSEC_PER_MILLISEC;
Using the following defines:
const int64_t NANOSEC_PER_MILLISEC = 1000000;
const int64_t MILLISEC_PER_SEC = 1000;
Steve.
Allan Comar wrote:
> Hi all, I am needing something that I couldn't find in nowhere else, I am trying to use pthread_cond_timedwait but I want that the time that I need to wait is setted im milliseconds, I already could do in seconds and i am having a real hard time trying it in milliseconds. Any Ideas ? I am using MSVC6.0 with pthreads.
>
--
J. Senior Software Engineer, Tibco Software Ltd.
T. +44 (0) 1792 360773
M. +44 (0) 7788 971394
E. scroall@tibco.com
W. www.tibco.com
next prev parent reply other threads:[~2005-06-10 20:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-10 18:07 pthread_cond_timedwait Allan Comar
2005-06-10 20:23 ` Steve Croall (TIBCO) [this message]
2005-06-11 0:56 ` pthread_cond_timedwait Ross Johnson
-- strict thread matches above, loose matches on Subject: below --
1999-09-09 10:51 pthread_cond_timedwait Bossom, John
1999-09-09 9:39 pthread_cond_timedwait Medina, Aurelio
1999-09-09 8:51 pthread_cond_timedwait Mikael.Ambrus
1999-09-09 9:21 ` pthread_cond_timedwait Scott Lightner
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=42A9F6CB.9070304@btinternet.com \
--to=tibco.croall@btinternet.com \
--cc=acomar@commodity.com.br \
--cc=pthreads-win32@sources.redhat.com \
--cc=scroall@tibco.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).