From: Colin Plumb <colin@nyx.net>
To: andrejp@luz.fe.uni-lj.si
Cc: linux-kernel@vger.rutgers.edu
Subject: Re: GPS Leap Second Scheduled!
Date: Tue, 8 Sep 1998 22:46:25 -0600 (MDT) [thread overview]
Message-ID: <199809090446.WAA25923@nyx10.nyx.net> (raw)
Ulrich Windl wrote:
> The time in the kernel is seconds since the epoch. To insert a second
> means that we'll have to delay the next second for another second.
> The other solution seems to be a clib -> kernel interface that knows
> that a leap second is active now. Then the clib could possibly
> convert the seconds to xx:yy:60. (I hope I did not overlook something
> obvious).
And Andrej Presern replied:
>> Have you considered simply not scheduling any processes for one second and
>> adjusting the time accordingly? (if one second chunk is too big, you can do
>> it in several steps)
The problem is that POSIX is schizophrenic on the subject of leap seconds.
On the one hand, time() returns UTC time. On the other,
t = time();
sec = t % 60;
t /= 60;
min = t % 60;
t /= 60;
hr = t % 24;
t /= 24;
printf("UTC time is %lu days, %02u:%02u:%02u\n", (unsigned long)t, gr, min, sec);
is required to work (since so much code does it.)
Actually, I think Ulrich was present when I proposed a similar solution:
gettimeofday() will not return during 23:59:60. If a process calls
gettimeofday() during a leap second, then the call will sleep until 0:00:00
when it can return the correct result.
This horrified the real-time people. It is, however, strictly speaking,
completely correct.
The real-world solution (a.k.a kludge), is to stretch some number of
seconds to cover the n+1 seconds including the leap second. During
those seconds, gettimeofday() is incorrect, but the error is
well-defined, so two "good" implementations will return "close" values
and you can undo the fudging afterwards if desired.
The only trick is to define the number of seconds n, their position
relative to the leap second, and they type of stretching. Linear is
obvious, making the 60 seconds leading up to a leap second take 61/60
of the usual time, but you could define a polynomial with higher-order
continuity.
--
-Colin
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/faq.html
next reply other threads:[~1998-09-09 5:16 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-09-09 4:46 Colin Plumb [this message]
1998-09-09 19:08 ` Theodore Y. Ts'o
[not found] <299BBE59294E@rkdvmks1.ngate.uni-regensburg.de>
[not found] ` <98090822315400.00819@soda>
1998-09-09 0:59 ` H. Peter Anvin
1998-09-09 8:00 ` Chris Wedgwood
[not found] ` <199809092149.RAA06993@hilfy.ece.cmu.edu>
1998-09-10 1:37 ` H. Peter Anvin
1998-09-10 15:05 ` Theodore Y. Ts'o
1998-09-12 19:57 ` Feuer
1998-09-09 16:35 ` David Lang
1998-09-09 20:13 Colin Plumb
1998-09-09 23:45 ` Chris Wedgwood
1998-09-09 23:55 ` Chris Wedgwood
1998-09-10 8:36 ` Rogier Wolff
1998-09-10 17:05 ` Oliver Xymoron
1998-09-10 22:02 ` Ryan Moore
[not found] <no.id>
1998-09-10 6:34 ` Jamie Lokier
1998-09-11 6:18 ` Michael Shields
1998-09-11 22:49 Ethan O'Connor
[not found] <19980914165757.A17479@tantalophile.demon.co.uk>
[not found] ` <199809150603.XAA29073@cesium.transmeta.com>
[not found] ` <19980915100729.02790@albireo.ucw.cz>
[not found] ` <35FF1838.6E247F0C@his.com>
1998-09-17 11:51 ` Jan Echternach
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=199809090446.WAA25923@nyx10.nyx.net \
--to=colin@nyx.net \
--cc=andrejp@luz.fe.uni-lj.si \
--cc=linux-kernel@vger.rutgers.edu \
/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
all inboxes | Powered by JetHome®