public inbox for
 help / color / mirror / Atom feed
From: gabbo <>
Subject: use of pthread_cond_timedwait
Date: Fri, 10 Aug 2007 02:33:00 -0000	[thread overview]
Message-ID: <1185302125.3276.5.camel@localhost> (raw)

I would use pthread_cond_timedwait in windows ce.
I have just compiled and linked the library for windows ce.
I create a routine that calc timespec struct. The routine increase 1 sec
Routine blocks on this function (pthread_cond_timedwait) and don't
Routine is from tests/condvar2.c
Compiler: visual studio for ARM.

#include "test.h"

#define TIMESPEC_TO_FILETIME_OFFSET (((LONGLONG)27111902 << 32) +

    FILE *fp;
    char output[] = "results.txt";

void filetime_to_timespec(const FILETIME *ft, struct timespec *ts)
    ts->tv_sec = (int)((*(LONGLONG *)ft - TIMESPEC_TO_FILETIME_OFFSET) /
    ts->tv_nsec = (int)((*(LONGLONG *)ft - TIMESPEC_TO_FILETIME_OFFSET -
((LONGLONG)ts->tv_sec * (LONGLONG)10000000)) * 100);

void add_nano_second (struct timespec *t1, unsigned long nsec)
    t1->tv_sec += 1;

int main()
  struct timespec abstime = { 0, 0 };

    FILETIME ft;


    if( (fp=fopen(output, "w"))==NULL){
        fprintf(fp, "Cannot open file %d\n", output);

  assert(pthread_cond_init(&cv, NULL) == 0);

  assert(pthread_mutex_init(&mutex, NULL) == 0);

  assert(pthread_mutex_lock(&mutex) == 0);
    SystemTimeToFileTime(&st, &ft);
    filetime_to_timespec(&ft, &abstime);
    add_nano_second(&abstime, 200*1000000);

  assert(pthread_cond_timedwait(&cv, &mutex, &abstime) == ETIMEDOUT);
assert(pthread_mutex_unlock(&mutex) == 0);

gabriele novelli

                 reply	other threads:[~2007-07-24 18:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1185302125.3276.5.camel@localhost \ \ \

* 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).