From: george anzinger <george@mvista.com>
To: high-res-timers-discourse@lists.sourceforge.net,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Is CLOCK_REALTIME the same as the clock under gettimeofday()
Date: Wed, 27 Mar 2002 12:50:43 -0800 [thread overview]
Message-ID: <3CA230A3.7F5CD1D4@mvista.com> (raw)
A re-reading of the standard (dammed nuisance), to get the man pages
right, uncovered the information that clock_nanosleep() with the
absolute
option is supposed to wake up at the specified time, regardless of
intervening calls to clock_settime() (all on CLOCK_REALTIME). In
considering how to make this happen, I assumed that this also meant that
calls to settime() and adjtime() (i.e. ntp code) should also be
covered. All this assumes that CLOCK_REALTIME and the gettimeofday()
clock are the same.
The way to do this IMHO, is to put these sleep requests in a linked list
and, each time the time is changed, run thru the list and cancel each
sleep and redo it. The problem with this is the ntp stuff which makes
small adjustments each tick (10 ms). I think this is too much overhead
for each tick so I am trying to come up with a new way that has less
overhead.
One possible solution is to disconnect CLOCK_REALTIME from the
gettimeofday() clock. It could be, for example, connected to the uptime
clock (CLOCK_MONOTONIC) with an offset which would be added to get to
something close to the gettimeofday() clock. The offset would be
calculated at boot time and then periodically from then on. The period
could be something that keeps ntp drifting from causing a redo of the
clock_nanosleep() calls every tick, but still keeps the clock relatively
close, say every second or so (possibly this period could be changed or
configured).
Another solution to this issue is to program the clock_nanosleep() calls
to wake up a second or so prior to the requested time and then fine tune
the wake up to happen as close as possible to the requested time. This
calculation might take into account the current ntp drift rate.
comments?
--
George george@mvista.com
High-res-timers: http://sourceforge.net/projects/high-res-timers/
Real time sched: http://sourceforge.net/projects/rtsched/
Preemption patch:http://www.kernel.org/pub/linux/kernel/people/rml
next reply other threads:[~2002-03-27 20:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-03-27 20:50 george anzinger [this message]
[not found] <014701c1db2b$d1f537f0$820314ac@fdvlegoll01>
2002-04-03 18:44 ` Is CLOCK_REALTIME the same as the clock under gettimeofday() george anzinger
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=3CA230A3.7F5CD1D4@mvista.com \
--to=george@mvista.com \
--cc=high-res-timers-discourse@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox