public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [RFC] statx Timestamp Test case
Date: Fri, 10 Aug 2018 14:42:56 +0200	[thread overview]
Message-ID: <20180810124256.GA32275@rei.lan> (raw)
In-Reply-To: <d1c5e0ca49ef02e6ca2f87a8ac524428.squirrel@pike.zilogic.com>

Hi!
> >void my_clock_gettime(struct timespec *time)
> > {
> >    int ret;
> >    struct timespec prev_time;
> 
> 
> >    ret = clock_gettime(CLOCK_REALTIME_COARSE, &prev_time);
> >    if (ret == -1)
> >	tst_brk(TINFO | TERRNO, "clock_gettime failed");
> 
> >    do {
> >	ret = clock_gettime(CLOCK_REALTIME_COARSE, time);
> >	if (ret == -1)
> >	    tst_brk(TINFO | TERRNO, "clock_gettime failed");
> >    } while (time == prev_time);
> >}
> 
> Is this approach fine or is there any other better way of doing it?

You can use clock_getres() to query the lenght of the timer tick then
usleep a bit more than that, e.g. multiply that by 1.5.

-- 
Cyril Hrubis
chrubis@suse.cz

      reply	other threads:[~2018-08-10 12:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-09 13:30 [LTP] [RFC] statx Timestamp Test case vaishnavi.d
2018-08-10 12:42 ` Cyril Hrubis [this message]

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=20180810124256.GA32275@rei.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /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