News for hackers. Stuff that matters.
Re:Ntpd won't save you from one particular rogue bit by userbinator on Thursday September 28, 2017 @06:19AM (#15356021)
This means you can't actually persist the bad time to your RTC.

I wonder where that limit comes from, since the RTC in a standard PC stores both the year(00-99) and century(also 00-99) in BCD, so a date in 2153 should be representable.

This reminds me, one interesting thing I've noticed over the years is that early PC's RTCs were pretty accurate, but the most recent ones, as in the past few years, are horrible (as much as +/- several seconds per day), and the ones in smartphones even worse. Maybe because they're assuming NTP, so have cut costs by using less accurate crystals? I've had systems in storage for many years, and the RTC was within a few seconds of the current time when turned on again.

Re:Ntpd won't save you from one particular rogue bit by JdeBP on Thursday September 28, 2017 @12:21PM (#15358361)
A "standard PC" is not in fact required to have a century register. One can obtain from ACPI information where it is if the hardware has one but this is an optional feature and PCs are not required to have a valid register number in their where-the-century-register-is fields. Indeed, the entire MC146818 compatibility system is optional as far as modern ACPI is concerned. There's an FADT flag that signals that it is not there.
Re:Ntpd won't save you from one particular rogue bit by dspillett on Thursday September 28, 2017 @07:21AM (#15356274)
I can't say I've ever had a PC with a particularly accurate RTC, though in recent years I've run NTP on everything I can so not noticed any effects.

Anecdotally clocks in small mobile devices like phones do seem less accurate though, at least when they don't have access to the network to update themselves. I've not looked into it but assumed temperature variances, which a device like a phone will experience to a larger extent, were part of the problem.

Of course phones syncing with the network relies on their clocks agreeing with the rest of the world - for some months my provider seemed to be a minute or so behind which meant I had to adjust a little when gauging if I was just going to make train I was rushing towards or if I'd likely missed it leaving already...

Re:Ntpd won't save you from one particular rogue bit by jofer on Thursday September 28, 2017 @08:32AM (#15356604)
I've noticed the same thing, but I'm always surprised by it. Particularly with smartphones.

A GPS is basically just a very, very precise clock and a radio receiver.

Why don't smartphones use the GPS clock?

I'm sure there's a good reason (and some probably do), but it sill surprises me. (Presumably it's battery related -- the GPS clock can't be used unless GPS is fully enabled or something similar.)

Re:Ntpd won't save you from one particular rogue bit by Lx1oG-AWb6h_ZG0 on Thursday September 28, 2017 @09:26AM (#15356920)
The precise clock is located on the satellites, not receivers. The receivers figure out the correct time by listening for the signals from multiple satellites and matching them against each other and it’s own internal tables. This is the expensive part.
Re:Ntpd won't save you from one particular rogue bit by Piskvorrr on Thursday September 28, 2017 @10:15AM (#15357236)
Indeed, but the GPS fix you're getting is 4-dimensional: if you have position, you also have precise time. Therefore - listening for the GPS time is not necessary all the time, just update when a precise-enough fix is achieved.
Re:Ntpd won't save you from one particular rogue bit by monochromatic on Thursday September 28, 2017 @12:19PM (#15358335)
Probably cheaper in terms of battery life to just use NTP than to periodically get a GPS fix.
Re:Ntpd won't save you from one particular rogue bit by Dylan16807 on Thursday September 28, 2017 @02:48PM (#15359751)
It's worth noting that to get time with .1s accuracy you don't actually need a GPS fix, just to pick up the 50-bit-per-second navigation signal for a couple seconds, from one satellite.
Re:Ntpd won't save you from one particular rogue bit by monochromatic on Thursday September 28, 2017 @05:26PM (#15360875)
How would that work unless you know the distance to the satellite?
Re:Ntpd won't save you from one particular rogue bit by nucleardog on Thursday September 28, 2017 @06:26PM (#15361301)
Based off of some quick and dirty calculations for a GPS satellite at approximately 20,000km above sea level, the difference in distance between a satellite directly overhead and one straight out over the horizon is around 5500km.

That's actually only about 18ms difference in delay. Unless there's something I'm failing to account for here, you should be able to get more than 0.1s precision based off of a single satellite's signal.

Subtract a flat ~75ms to account for the minimum delay (~66ms @ 20,000km) and half of the variable delay, and you shouldn't really be more than about 9ms out.

Re:Ntpd won't save you from one particular rogue bit by Dylan16807 on Thursday September 28, 2017 @06:18PM (#15361233)
The distance to an overhead GPS satellite is somewhere in the range of .07-.09 light-seconds. The planet's width is basically irrelevant when your goal is .1 second accuracy.
Re:Ntpd won't save you from one particular rogue bit by p1mrx on Thursday September 28, 2017 @06:16PM (#15361219)
If you're on Earth, you can assume that the satellite is closer than 30000 km or so. Light takes 0.1s to cross that distance.
Re:Ntpd won't save you from one particular rogue bit by Piskvorrr on Thursday September 28, 2017 @12:37PM (#15358551)
Of course. I was thinking "when another app is requesting a GPS fix anyway, might as well use the temporal part, as you're getting it for free."
Re:Ntpd won't save you from one particular rogue bit by lucaspiller on Thursday September 28, 2017 @06:57AM (#15356182)
I have a heating thermostat that has optional ‘smart’ features that allow you to control it via your phone. I tried it when I first got it, but it seemed a bit pointless, so I turned off the feature and the wifi connection. That was a month ago, and the onboard clock has now drifted by around 15 minutes...
Re:Ntpd won't save you from one particular rogue bit by wruza on Thursday September 28, 2017 @08:47AM (#15356663)
>and the ones in smartphones even worse

Oh, I bet my tooth that I can hear my phone playing music slightly faster than usual sometimes. Never experienced that on PC. Maybe it is not connected to RTC and is purely biological condition (never cared enough to test two devices side by side), but if someone experienced that too and has an explanation, it would be great to know.

Re:Ntpd won't save you from one particular rogue bit by wyldfire on Thursday September 28, 2017 @09:53AM (#15357106)
The RTC is not a factor for problems in music playback on phones or elsewhere. It's only for "wall clock" time, and generally only for when the system boots. The OS timer tick that drives the scheduler is often generated by the CPU and some operating systems don't use it anymore -- Linux has offered a tickless config for a while that I think many android configs capitalize on for the sake of conserving battery. The scheduler could be a culprit for playback discontinuity (stalls) but not problems with the tempo.

I'm wondering -- "What might cause music playback to be faster than normal?" I don't think I know enough to tell. Perhaps the clocks on the audio playback device are skewed? Most SoCs use a dedicated DSP which doesn't seem terribly different from PC's. Not sure, but we can say for certain that it's definitely immune to changes in wall clock time (whether in the RTC or its representation in the OS).

Re:Ntpd won't save you from one particular rogue bit by tonyarkles on Thursday September 28, 2017 @10:57AM (#15357533)
I had a USB sound card that, on windows, would play back at 48kHz instead of 44.1kHz. Slight pitch shift upwards, playback at 8% faster. Most apps just let the audio driver provide backpressure and don't actively try to send data at the rate the soundcard is expecting, they just feed bytes when asked.

Even more fun was that it was a dual-boot machine, and the audio worked perfectly in Linux but shifted up in Windows. I honestly thought I was losing my mind for a while. I'd listen to the same song in Spotify on both OSes and just get this "something is wrong here..." feeling in my gut.

Re:Ntpd won't save you from one particular rogue bit by etatoby on Thursday September 28, 2017 @09:19AM (#15356867)
Yes, I've definitely heard it.

Which does not prove it's a fault in the device—it could be a fault in my fried brain—but anecdotally, I've never noticed it on any other music playing device, since the time of the original walkman (and in that case the music would usually slow down due to attrition or other mechanical faults, but rarely if ever speed up.)

Re:Ntpd won't save you from one particular rogue bit by Piskvorrr on Thursday September 28, 2017 @10:17AM (#15357249)
On some (tape) devices, you could fast-forward while the reading head was still engaged, i.e. playing. This would provide the speedup effect;)
Re:Ntpd won't save you from one particular rogue bit by cellularmitosis on Friday September 29, 2017 @12:14PM (#15366583)
If the pitch sounds higher, then your phone is actually playing back the song faster. If it sounds faster without the pitch being higher, then its just a perception-of-reality thing.
Re:Ntpd won't save you from one particular rogue bit by monochromatic on Thursday September 28, 2017 @12:22PM (#15358372)
> cut costs by using less accurate crystals

Maybe... but how much money could they possibly be saving? Quartz oscillators like the ones used in cheap digital watches are plenty accurate and completely abundant. I can't imagine they cost very much.

Maybe the issue has to do with miniaturization? If you're trying to make smaller and smaller devices, there could be an acceptable tradeoff between size and precision.

Re:Ntpd won't save you from one particular rogue bit by agoetz on Thursday September 28, 2017 @02:42PM (#15359718)
Most RTCs do use the same crystals that are in wristwatches, which is actually the source of their error.

The tuning fork crystal design used in wrist watches has a parabolic temperature coefficient, which means that the clock is only really accurate at room temperature. This isn't a problem for wristwatches, because, presumably your wrist is at approximately room temperature, but it does become a problem for electronics that operate with large temperature swings. (like the inside of a phone or computer, for instance).

https://www.maximintegrated.com/en/app-notes/index.mvp/id/58

Re:Ntpd won't save you from one particular rogue bit by Florin_Andrei on Thursday September 28, 2017 @04:39PM (#15360528)
The vast majority of quartz references in consumer devices could be a lot better, but they are not fine-tuned at the factory. They're just "close enough". So they drift a lot.

A simple tuning procedure could make almost all quartz clocks you own a heck of a lot better. But in many cases this is hard to do because the manufacturer never put the tuning components (a variable capacitor or the like) on the PCB.

Re:Ntpd won't save you from one particular rogue bit by monochromatic on Thursday September 28, 2017 @05:25PM (#15360868)
That’s interesting. I’d never thought about it, but of course there’s a temperature dependence, and of course attaching it to a wrist mitigates it.
Re:Ntpd won't save you from one particular rogue bit by dragonwriter on Thursday September 28, 2017 @04:37PM (#15360513)
> This reminds me, one interesting thing I've noticed over the years is that early PC's RTCs were pretty accurate, but the most recent ones, as in the past few years, are horrible

Insofar as sensitivity to thermal conditions is an issue, early PCs tended to be big, airy, ventilated boxes and have less bits that would ramp up to high temperature under load but drop down in other operating regimes. So that may be a factor.

Re:Ntpd won't save you from one particular rogue bit by LinuxBender on Thursday September 28, 2017 @11:54AM (#15358097)
Try disabling the power management features for a bit and see if your drift is the same. On NTP servers, I always have to disable cpuspeed, c-states, intel power mgmt, etc.
Re:Ntpd won't save you from one particular rogue bit by jandrese on Thursday September 28, 2017 @04:30PM (#15360461)
This would also explain why phone hardware is worse off than PC hardware, it is much more aggressive about managing power.