All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Patrick Doyle <wpdster@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] Get current wallclock time from RT task
Date: Fri, 03 Feb 2012 22:22:57 +0100	[thread overview]
Message-ID: <4F2C5031.2080409@domain.hid> (raw)
In-Reply-To: <CAF_dkJCxiyMmQaK9w_udT-pR2vR8-rzEJDtzFD80bMh=U+entw@domain.hid>

On 02/03/2012 09:07 PM, Patrick Doyle wrote:
> What is the easiest way to determine the current wallclock time from
> within an RT task?
> 
> I see that I can call rt_timer_inquire() and get back an RT_TIMER_INFO
> structure containing an RTIME type field labeled "date" and a very
> promising comment "Current wallclock time".
> 
> But how do I convert that to e.g. something I could pass to ctime() to
> get something reasonably close to the current wallclock time?

You need to divide it by one billion. But for the result to be
reasonably accurate, you should either:
- compile xenomai as module
- or having synchronized xenomai clock with linux clock at some earlier
point in time by calling timer_settime(CLOCK_REALTIME) (from posix skin).

If your architecture supports it you may also use
clock_gettime(CLOCK_HOST_REALTIME) then you will get a result with very
good accuracy possibly without even a syscall.

-- 
                                                                Gilles.


  reply	other threads:[~2012-02-03 21:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-03 20:07 [Xenomai-help] Get current wallclock time from RT task Patrick Doyle
2012-02-03 21:22 ` Gilles Chanteperdrix [this message]
     [not found]   ` <CAF_dkJB+NeaX5QK=xHhNU7Oe0TYM8im_XFwzym22UxJBJ2KWrA@mail.gmail.com>
2012-02-03 21:39     ` Gilles Chanteperdrix

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=4F2C5031.2080409@domain.hid \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=wpdster@domain.hid \
    --cc=xenomai@xenomai.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.