dc and date numerology

norman at nose.cita.utoronto.ca norman at nose.cita.utoronto.ca
Thu Oct 28 09:48:50 AEST 1999


Greg Lehey wondered about the date in

> There's a binary of dc from either 1st or 2nd Edition in the PUPS Archive:
>
> 	-r---wxrw- 0/0            6846 Apr 14 06:50 1973 bin/dc

1973 is indeed post-Second-Edition.  But it's not the right date; just as
the permission flags were different in the early years, so was the date
representation.  Here are some gleanings from old manuals that tell the
story.

The relatively recent ls or tar or whatnot that printed the line above
presumably interpreted the date as if it were in modern form: seconds since
1 Jan 1970 UTC.  So the raw number stored in the i-node was probably about
105000000 decimal (30 Apr 1973 in my time zone), or about 1200 days into the
epoch.

But the file system described in the First Edition manual takes the date
as a count of clock ticks since 1 Jan 1971.  The clock ticked at 60Hz,
so the date is really about 1200/60 = 20 days into the epoch; if this file
came from a 1e file system, it was written on 21 Jan 1971.

The trouble with keeping a 60Hz clock in a 32-bit number is that it takes just
a couple of years before it overflows.  A band-aid had been stuck on by the time
the Third Edition manual was printed: the base date changed to 1 Jan 1972.  So
maybe bin/dc was written on 21 Jan 1972 instead.  There's no way to tell just
from the bits in the i-node.

The modern time format (1-second resolution) appeared in the Fourth Edition manual.
It is probably not a coincidence that the file system format changed a lot at
the same time; groups appeared, permission modes changed to approximately their
current form, directory entries changed, and so on.

The 60Hz scheme seems to have come from the PDP-7, on which it made more sense;
the -7 has 36-bit words, so a 60Hz counter lasts 16 times longer.  I bet the
base date changed at least once between the original PDP-7 system and the PDP-11
as well, since 1 Jan 1971 seems too recent for the PDP-7 system.

See http://www.cita.utoronto.ca/~norman/old-unix/old-fs.html for many more such
grotty details, collected in an insomniac night with a stack of old manuals some
months ago.

Norman Wilson

Received: (from major at localhost)
	by minnie.cs.adfa.edu.au (8.9.3/8.9.3) id KAA42069
	for pups-liszt; Thu, 28 Oct 1999 10:02:33 +1000 (EST)


More information about the TUHS mailing list