14

I recently read about how even the non-RTC-equipped Amiga computers has some sort of "clever trick" in them which caused the timestamps for saved files and whatnot to still be "internally consistent".

What exactly does this mean?

My only guess is that the Amiga would regularly, or perhaps every time it performed a file operation, also save the current timestamp to some sort of minimal persistent memory chip, just big enough to hold this minimal data, and then would fetch and auto-set the clock to this timestamp whenever the Amiga was powered on the next time. That way, at least timestamps would not "go backwards in time", even though they still would not be accurate since the Amiga would have no idea how long the computer had been powered off.

Is this what they meant? Or did they assume that the average user would power on their Amiga once a day after roughly 16 hours, so they added 16 hours to the last timestamp when setting the clock on boot?

Or did this mechanism work in some completely different manner? What does "internally consistent" mean anyway? And what's so clever about simply storing the "last known time"? I think I must have misunderstood this.

6
  • 3
    I'm not an Amiga owner, but I believe that it saved the timestamp onto the disk, so not needing any extra circuitry for this. Someone more informed will probably answer with the full details - or perhaps the answers to Why did the stock Amigas not have a battery for keeping the time/date? explain this for you? Mar 9 at 11:11
  • 6
    "Internally consistent" means that time as known internally to the system does not go backwards. Contrast that with being consistent with the external idea of what time it is; clearly it's not externally consistent. Mar 9 at 17:32
  • 1
    @dai In that era a network was not standard, nor was a phone line. So maybe technically feaseable, but not practical.
    – Hennes
    Mar 10 at 12:12
  • 1
    @another-dave. In other words, the transformation preserves order, but not interval. Mar 10 at 14:12
  • 5
    Does this answer your question? Why did the stock Amigas not have a battery for keeping the time/date?
    – Raffzahn
    Mar 10 at 14:58

3 Answers 3

21

If there is no RTC in the system, the date/time defaults to the date/time of file that was last saved on the boot disk.

3
  • 6
    That does seem like the obvious solution, rather than hypothesizing 'minimal persistent memory chips' which likely have no cost advantage over a clock. We want future timestamps to be greater than existing timestamps: very well, let's use the existing timestamps as the value to start time from. Mar 9 at 13:45
  • 8
    I don't know an Amiga file system from a hole in the ground, but a quick search reveals the root block (for certain file system types, I don't know which one we're talking about here) has a timestamp field DiskAltered with the appropriate semantics. Mar 9 at 20:20
  • 1
    The RTC-less Amiga models were probably most commonly booted from floppies, so you might have multiple OS boot disks: you would typically use boot disk A, but if it failed or you needed a different OS configuration, you might use a different boot disk B. Each of those would have their own last-changed timestamps, and so a data disk X you might use with both boot disks (or with different computers) could experience inconsistent time regardless. But any software designed to be usable on floppy-only Amigas probably didn't depend on file timestamp consistency in any non-optional way.
    – telcoM
    Mar 10 at 8:31
9

The general solution, which was used in a specific way by Amigas, is to use a timestamp on the system disk to record either the shutdown time (simpler, but not as reliable) or the last modification time of anything on the disk (more complicated, but more reliable). If done correctly, this allows the OS to ensure that disk timestamps are properly sequential relative to each other (which is usually what most software that cares about timestamps cares about), but not that they are ‘correct’ from a user perspective.

On historical Amiga systems, this was done by saving a last modified time in the filesystem metadata of the boot disk. Whenever a file was updated, this timestamp got updated as well, and when the system started up the system clock would be initialized to that time (if there was no RTC).

A similar approach is actually used on some more modern systems. For example, the official OSes for the Raspberry Pi all initialize the system time based on a file timestamp on the root volume on startup so that they have consistent timestamps before NTP synchronization kicks in. Some other Linux distributions (for example, anything that uses OpenRC as it’s init system, such as Gentoo or Alpine Linux) even support this out of the box generically, without having to be purpose built for the hardware.

2
  • 1
    Virtually all embedded Linux systems use this approach. Other embedded systems probably would, too, except that most of these embedded systems have no concept of a file system. :-)
    – Cody Gray
    Mar 10 at 8:07
  • IIRC systemd uses its build timestamp if the time it reads from the system clock is in the past.
    – muru
    Mar 11 at 5:58
9

@Justme's answer is correct, but there is more to the Amiga's implementation of this and that's necessary to work when floppy disks are the main media.

In the early years of the Amiga (1985-88), hard disks were very expensive and quite rare. Almost all Amiga users relied on floppy disks at the time. As with other floppy-based home computers of the time, two drives was a common setup (Amiga supported up to four), and you'd normally use some combination of boot disk, application program disk, and data disk if you were doing "real work" on the Amiga (as opposed to just booting a game floppy). Because of this, disk swapping was very routine during a session. If you launched multiple programs, you may alternately insert many disks over the course of the session. So, simply setting the clock at boot time, from whichever floppy disk that happened to be, is insufficient.

So, the actual implementation of the clock setting functionality was hooked into the floppy disk validation routine. This routine ran for every new floppy inserted into any of the drives during the session. The filesystem was checked for errors, and the last modified timestamp was noted. Occasionally, the validation would fail, and you'd get a popup telling you to run "DiskDoctor".

If the newly inserted floppy had a later timestamp than the current system time, then the system time would be updated, unless the system time had been set explicitly by the user or by RTC. Therefore, you were always assured that any disk file writes would have timestamps greater than the latest time for ANY of the floppies you'd inserted in any drive.

5
  • 4
    So, could you prank your friends by giving them a floppy whose timestamp you had manually set to a value far in the future, or one that was about to overflow? Mar 10 at 15:02
  • 1
    What happened if you manually set time and date? Did the system still use timestamps form diskettes if they were in the future?
    – UncleBod
    Mar 10 at 18:18
  • 3
    @UncleBod Good question. AmigaDOS keeps track of that and will respect a system date/time set either manually or from RTC.
    – Brian H
    Mar 10 at 19:24
  • 1
    This is how it works on Amigas. I came here from the hot questions list to give a basically identical answer, but you already did it. AmigaOS maintains a software clock while running. If set by RTC or manual input the software clock just keeps running and ignores file-system times. If no RTC or manual input the clock is bumped up whenever a file "newer" than "now" is encountered. (PS. Manual input will also sync the RTC with the newly set time. Filesystem time is completely ignored with RTC or time set manually even if its newer than current time. This can lead to backdating files on disk.)
    – Tonny
    Mar 11 at 13:06
  • @NateEldredge Been there, done that. Only works if the Amiga doesn't have a RTC. And is immediately remedied by manually resetting the time.
    – Tonny
    Mar 11 at 13:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.