Use Gnu make on DOS. That alone gives enough cutoff since it rounds dates to the nearest 2 second boundary, which make can trivially outpace in using the file again.Brendan wrote: Simply getting correct behaviour is hard enough. For an example, try "make foo", then reboot your computer and use the BIOS to set the time to last week, then do "touch somefile" and then try "make foo" again. What if you're doing incremental backups? For some OSs, you get the same problems even when you use the OS to change the current time.
Thought I'd heard it somewhere but I wasn't sure.Brendan wrote:Unfortunately, (according to Wikipedia) systems with strict POSIX compliance do have the same times twice when leap seconds are added. This means you can get the time and 500 ms later get an earlier time.
I'm not going for accurate time (as in second-accurate, subsecond-accurate or better. I'm going for a time thatOne problem with this is accurately calculating times 6 months or more ahead without knowing if a leap second will be added to UTC in advance, which could lead to calculations being incorrect by a maximum of one second per year. IMHO this isn't a huge problem as these long range calculations rarely need so much accuracy, and it's possible to postpone the calculation until just before it's needed to avoid the inaccuracy
The other problem is informing the OS when a leap second will be added - I assumed there'd be some sort of software updates happening every few months (which may be a bad assumption for some people).
The other main hurdle for accurate time keeping is handling large corrections. If the user notices that the time is wrong and wants to increase or decrease it by 10 minutes, then do you allow a sudden change (and mess up running software), or do you gradually compensate (e.g. increase the time counter at a rate of 1.01 Hz or 0.99 Hz instead of 1 Hz until the time is correct again) to avoid the sudden change. What if the user reboots and changes the RTC time using the BIOS? A file saved 5 minutes ago could look like it was saved a long time in the past or a long time in the future. For me, this becomes much more difficult because there's also the added problem of keeping all computers in the cluster synchronized. To be honest, I haven't really found a solution for these problems that I like...
- Only increments
- Is unique everytime you request it
- Is meaningful to the user (within bounds)
The first requires a few things. One, you can't adjust the time to before the current time - ever. Adjusting in the BIOS means that the computer should internally ignore the BIOS time and rather count for itself using its own last timestamp without overwriting the RTC values. After a few times turning off the computer the time will gradually shift closer to the "real" time. The actual time that's world-wide valid is irrelevant - the user defines the world of the computer.
The second means that the time kept is actually a number that is incremented regularly. The times given out (as opposed to the time kept) are the time kept plus a counter value that is reduced by as much as possible (preferably to 0 every time). This within the bounds of the first, so you can't decrement the counter by more than the time interval that's added to the time that's kept.
The third just means that the user must be able to set the time initially (and check whether it's valid) and indicate the relevant timezone / DST settings. The times given out should match the set value where not in conflict with the 1st or 2nd rule.
As far as I can see, this gives a good time clock for desktop systems that fulfills a number of cryptographically and system-integrity wise important characteristics. I can not find a flaw except that the time could drift a minute or more in 30 years (UTC allows 2 leap second per year). That would be compensated by the lack of quality in RTC's (I expect) and the user's inability to expect the time to remain correct for a longer period of time. Also, when the time values are retrieved at an astronomical speed, the time values given out might run past the actual time. This is not much of a problem and mainly the reason why I'm thinking of a 64-bit subsecond counter (try getting 18 billion billion values in a second - good luck).