From: Jan Kiszka <jan.kiszka@domain.hid>
To: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
Cc: Wolfgang Mauerer <wm@domain.hid>,
"xenomai@xenomai.org" <xenomai@xenomai.org>
Subject: Re: [Xenomai-core] Realtime gettimeofday()
Date: Wed, 02 Dec 2009 15:31:49 +0100 [thread overview]
Message-ID: <4B167A55.8080407@domain.hid> (raw)
In-Reply-To: <4B16769A.9060700@domain.hid>
Gilles Chanteperdrix wrote:
> Jan Kiszka wrote:
>> Gilles Chanteperdrix wrote:
>>> Wolfgang Mauerer wrote:
>>>> Hi,
>>>>
>>>> we'd like to implement a gettimeofday() mechanism that works
>>>> in realtime context, both from user- and kernelland. Most importantly,
>>>> the correctins made to the wall time by the NTP protcol on Linux
>>>> must be transferred into the Xenomai domain.
>>> Yes, the real issue is NTP, because other than that, you can simply
>>> implement gettimeofday in terms of clock_gettime(CLOCK_REALTIME).
>> Not truly as Linux processes that tune the host clock do not affect the
>> Xenomai world.
>>
>>> This issue has been discussed several times, but never a lot. We have a
>>> simple solution: starting with 2.4 (if I remember correctly) xenomai
>>> provides clock_settime, so you can simply rely on clock_gettime, and
>>> call clock_settime from time to time to resync the Xenomai clock with
>>> Linux NTP-enhanced clock. This is not pretty, you get a drift increasing
>>> over time, then suddenly been reset. But I guess this has been enough
>>> for current users, until now. You control the maximum drift by how often
>>> you call clock_settime.
>>>
>>> Would not it be enough for your use of xenomai?
>> Nope for the reasons you mentioned.
>>
>> Moreover, reading the Xenomai real-time clock requires a syscall,
>> gettimeofday can work without that penalty (given non-broken TSC).
>>
>> Next issue is that the different clock bases of
>> clock_gettime(CLOCK_REALTIME) and (real) gettimeofday + the switch-back
>> or even lock-up side-effects of the latter have been quite a PITA in our
>> project.
>>
>> And finally, the vision is to have NTP-accurate (or whatever the sync
>> source is, eg. IEEE1588) absolute timing also for the nucleus one day.
>> Having an RT-safe way to obtain the NTP parameters from any context is
>> the first step.
>
> clock_gettime(CLOCK_MONOTONIC) works without syscall too. And note that
> the real-time clock could work without a syscall for the current scheme,
> but you were the one to explicitly refuse this.
Yes, because we need a scheme like Wolfgang suggests to ensure
consistent states during updates. And we didn't had such thing back then.
>
> My opinion with regard to these issues is that the I-pipe patch should
> send us an event when the parameters are adjusted (the wall clock time
> changed by Linux, or the slow down/acceleration caused by the NTP
> daemon). And that we should duplicate the processing done by the Linux
> kernel for the Xenomai clock.
That may be a solution for only half of the problem.
> Doing this in user-space without a syscall
> is another issue that will be possible to handle when we have solved the
> kernel-space clock issue. Of course, it supposes that Xenomai should use
> the same clocksource as Linux, so, that we should implement the HPET
> clock source for x86 (on other architectures, we already use the same
> clock source).
Solving the user space transfer automatically includes a solution for
the Linux-to-Xenomai transfer. I really suggest that we discuss a
complete solution to avoid leaving design issues behind that require
another ABI change later on.
>
> Another possibility is to implement syscalls to allow adjusting the
> nucleus real-time clock parameters the same way ntp does, and to require
> a special ntp daemon that would use these syscalls instead of the linux
> kernel syscalls. After all, if we adjust Xenomai clock, Linux clock will
> follow without any adjustment. On an embedded system, requiring a
> recompiled NTP is not much of an issue.
>
> So, to summarize, here is what I think we should do:
> - implement the HPET clock source
What for? The days of HPET are counted (both as clock and event source),
modern systems provide proper TSCs.
> - implement the I-pipe events signalling wall clock adjustment and NTP
> related adjustments
> - or implement syscalls to allow NTP related adjustments (we already
> have the syscall allowing to change wall clock)
> - rework the nucleus real-time clock to use these adjustements
> - implement the user-space syscall-less version of the real-time clock read.
>
> Trying to go directly to the last point looks premature to me.
Why? It delivers us the core mechanism we need for the rest as well -
and it does not require fancy I-pipe hooks.
Jan
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
next prev parent reply other threads:[~2009-12-02 14:31 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-02 12:55 [Xenomai-core] Realtime gettimeofday() Wolfgang Mauerer
2009-12-02 13:23 ` Gilles Chanteperdrix
2009-12-02 13:43 ` Jan Kiszka
2009-12-02 14:15 ` Gilles Chanteperdrix
2009-12-02 14:31 ` Jan Kiszka [this message]
2009-12-02 14:35 ` Gilles Chanteperdrix
2009-12-02 14:55 ` Jan Kiszka
2009-12-02 15:03 ` Gilles Chanteperdrix
2009-12-02 15:16 ` Jan Kiszka
2009-12-02 16:08 ` Gilles Chanteperdrix
2009-12-02 16:23 ` Jan Kiszka
2009-12-02 16:59 ` Gilles Chanteperdrix
2009-12-02 20:54 ` Gilles Chanteperdrix
2009-12-02 22:03 ` Wolfgang Mauerer
2009-12-02 22:20 ` Gilles Chanteperdrix
2009-12-02 22:33 ` Gilles Chanteperdrix
2009-12-03 9:36 ` Wolfgang Mauerer
2009-12-03 10:50 ` Gilles Chanteperdrix
2009-12-03 13:11 ` Wolfgang Mauerer
2009-12-03 13:14 ` Gilles Chanteperdrix
2009-12-03 13:32 ` Wolfgang Mauerer
2009-12-03 13:38 ` Gilles Chanteperdrix
2009-12-03 20:31 ` Wolfgang Mauerer
2009-12-03 21:42 ` Gilles Chanteperdrix
2009-12-05 16:11 ` Philippe Gerum
2009-12-07 9:14 ` Jan Kiszka
2009-12-07 13:43 ` Gilles Chanteperdrix
2009-12-07 13:50 ` Jan Kiszka
2009-12-07 14:07 ` Philippe Gerum
2009-12-07 14:21 ` Wolfgang Mauerer
2009-12-15 15:00 ` Richard Cochran
2009-12-15 15:07 ` 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=4B167A55.8080407@domain.hid \
--to=jan.kiszka@domain.hid \
--cc=gilles.chanteperdrix@xenomai.org \
--cc=wm@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.