Why I Like BSD – It’s About Time…

BSD is Berkeley Software Distribution; a family of Unix flavors.

A short digression:

In the way back time, Unix was issued in ‘Versions’ by Bell Labs. As THE Telephone company was not allowed to make money from computing, only from their telephone monopoly, many licenses were essentially given away to schools. Along the way, the Seventh Version was licensed to U. of California at Berkeley or UCB. They got a ‘special deal’ that let them re-license their changed version on a similar free basis. Thus began BSD based on Version 7. Over a few years, a huge number of these licenses spread over the entire world of Education, and eventually leaked out into the commercial world. The original Sun O/S for example, was “BSD Based”.

Then AT&T got broken up and was free to make money from computing. Try as they might to break the V7 license, they couldn’t. So they did the next best thing. They loaded a bunch of capricious changes into Unix, broke a lot of things in new and different ways, and began touting “System V – Consider it Standard”. Painting BSD and anything V7 based as out of date.

Well, that history didn’t end well of The Telco. Eventually Unix license and I.P. was sold to SCO and on to Novel and I think it is now part of Suse? But not many people really care. Along the way, the Government got P.O.ed at the changes and started the POSIX standard movement.

Linux came along (and despite The Telco and others all trying to sue them out of existence too) the river just flowed around the lawyers… Sue on some detail of some command, it mutated into a different command. Folks went into various bits of code rooting out anything tied to System V or Unix. Eventually the whole waste of time and effort ran down along with the value of the Unix I.P. (Intellectual Property), and thus the sales and re-sales of the ownership.

Through It All, BSD soldiered on. THEY had an indestructible position. They also had millions of university students globally polishing on the product on one side, and doing their damnedest to break it on the other. Makes for a very sturdy and secure product.

Now the Linux world has gotten most of the recent fame and glory. BSD being more staid and not liking to take on new stuff too fast ( like Gnome or KDE or …) lest some bright student find out he can get into the grades on line using some new hack. So it is harder to install. More things done “the old way” and longhand; much less GUI (Graphical User Interface) and hand-holding. So while I really really like BSD, most of my machines have been Linux the last few years as it is quick to install, easy to play with, and had lots of goodies. But I’ve always thought I ought to get back to my BSD roots someday.

“Someday” bringing up the issue of time…

On Time

I’ve been collecting some Temperature Data, including daily data, and I’ve been looking at things like TOBS Time Of Observation Bias. Temperatures need times to be valuable. I’ve been looking at model codes, and that maybe they need a time of day factor and sun rise / fall daily as they are run foward predicting the next couple of decades. And I’ve been looking at File Systems and archiving and coping with some of the particularly lousy things done with metadata, such as time stamps, in some file systems (FAT32 is horrid, NTFS only a little better). But sad to say, Linux and Unix “have a time issue on their hands”. Their file systems do keep time correctly; but not for long.

Back in the 1970s, when Unix was a new idea, the lab rats didn’t think much about 2038. Most likely would not be alive then themselves, and computers would be worlds different. Heck, they had no idea Unix would dominate servers, and Linux would sprout from it to own the entire embedded systems and cell phone markets (that also didn’t exist then). So they decided that a nice fat giant sized time number could be used to code for all time. That is why Unix uses the ‘start of time’ as the start of Unix. And time is just stored as a 32 bit integer. Negative numbers being ‘before Unix’ and positive numbers being after Unix. A whole lot easier than that whole Julian / Gregorian / daylight savings time etc. etc. junk. Just an INT. Increment and move on. Zero at the 0:00 on 1 January 1970. On all Unix, in all places, everywhere. OOoooohhhhommmmm……..

In 1970 an 8 bit machine was big enough, 16 bits was big, and 32 bits was a mainframe. There were a few with larger words, but not much. Just doing a 32 bit INT on many machines was more than one computer word. Using 64 bits for every scrap of time would just be nuts. Now not so much. Now even desktop machines are 64 bits.

Why Does This Matter?

Because it breaks on dates in 2038, or 23 years from now.


Such implementations cannot encode times after 03:14:07 UTC on 19 January 2038, a problem similar to but not entirely analogous to the “Y2K problem” (also known as the “Millennium Bug”), in which 2-digit values representing the number of years since 1900 could not encode the year 2000 or later. Most 32-bit Unix-like systems store and manipulate time in this “Unix time” format, so the year 2038 problem is sometimes referred to as the “Unix Millennium Bug” by association.

Why worry? Heck, my computer will likely be long gone to the binary graveyard well before 23 years…

Well, because maybe before then you will want to USE a date and time after then. Like, oh, if you were running a simulation and date stamping files and data for a few decades into the future as part of your process…

Some folks have already started to run into things, though only a few small cases so far. This WILL get worse as time goes by. For example, how about folks who want to restore and preserve “antique” cars in 2038? A car computer built today will not work right then if it uses dates. (Almost all embedded systems are like this and are NOT 64 bit systems…)

In May 2006, reports surfaced of an early manifestation of the Y2038 problem in the AOLserver software. The software was designed with a kludge to handle a database request that should “never” time out. Rather than specifically handling this special case, the initial design simply specified an arbitrary time-out date in the future. The default configuration for the server specified that the request should time out after one billion seconds. One billion seconds (approximately thirty-two years) after 9:27.28 pm on 12 May 2006 is beyond the 2038 cutoff date. Thus, after this time, the time-out calculation overflowed and returned a date that was actually in the past, causing the software to crash. When the problem was discovered, AOL server managers had to edit the configuration file and set the time-out to a lower value.

Players of games or apps which are programmed to impose waiting periods are running into this problem when they attempt to work around the waiting period on devices which harbor the coding, by manually setting their devices (such as the Nexus 7) to a date past 19 January 2038.

Vulnerable systems

Embedded systems that use dates for either computation or diagnostic logging are most likely to be affected by the 2038 bug.

Many transportation systems from flight to automobiles use embedded systems extensively. In automotive systems, this may include anti-lock braking system (ABS), electronic stability control (ESC/ESP), traction control (TCS) and automatic four-wheel drive; aircraft may use inertial guidance systems and GPS receivers. However this does not imply that all these systems will suffer from the bug. Many such systems will not require access to dates. For those that do, those systems which only track the difference between times/dates and not absolute times/dates will, by the nature of the calculation, not experience a problem. This is the case for automotive diagnostics based on legislative standards such as CARB.

Another major use of embedded systems is in communications devices, including cell phones and Internet appliances (routers, wireless access points, etc.) which rely on storing an accurate time and date and are increasingly based on UNIX-like operating systems. For example, the bug makes some Android devices crash and not restart when the time is changed to that date.

As of 2012, most embedded systems use 8-bit or 16-bit microprocessors, even as desktop systems are transitioning to 64-bit systems.

Despite the modern 18–24-month generational update in computer systems technology, embedded systems are designed to last the lifetime of the machine in which they are a component. It is conceivable that some of these systems may still be in use in 2038. It may be impractical or, in some cases, impossible to upgrade the software running these systems, ultimately requiring replacement if 32-bit time_t limitations are to be corrected.

The use of 32-bit time_t has also been encoded into some file formats, which means it can live on well beyond the life of the machines on which such file formats were originally supported.

MySQL database’s inbuilt functions like UNIX_TIMESTAMP() will return 0 after 03:14:07 UTC on 19 January 2038.

It was that MySQL item that caught my attention as I was contemplating Temperature Database design and extending it into the future for model run outputs… Then that next to last bit about file formats has implications for data archival and restore operations.

BSD To The Rescue!

Just about when I was thinking forlornly that this was Not Good for me and my goals, once again, BSD is way ahead of all the rest. Note that in the following quote DVB is Digital Video Broadcasting and ATSC is your new Advanced Television standard… yeah, almost brand new and they didn’t think 20 years ahead…

But look just a little further down at BSD… (I’ve bolded it a bit) Also, honorable mention for Linux on 64 Bit hardware.


There is no universal solution for the Year 2038 . Any change to the definition of the time_t data type would result in code compatibility problems in any application in which date and time representations are dependent on the nature of the signed 32-bit time_t integer. For example, changing time_t to an unsigned 32-bit integer, which would extend the range to the year 2106, would adversely affect programs that store, retrieve, or manipulate dates prior to 1970, as such dates are represented by negative numbers. Increasing the size of the time_t type to 64-bit in an existing system would cause incompatible changes to the layout of structures and the binary interface of functions.

There is also no universal solution for the issue with DVB and ATSC real time transmitted dates due to issues with legacy receivers. Also the issue has yet to be acknowledged or resolved by either organization.
The only work around would be to discontinue all time related metadata services such as programming guides and automatic date synchronization after the affected dates. One possible option would be to create new table types for the affected part of the specifications and use ISO 8601 date strings rather than fixed integers as is used in ISO 9660 and ISO 13346 filesystems.

Most operating systems designed to run on 64-bit hardware already use signed 64-bit time_t integers. Using a signed 64-bit value introduces a new wraparound date that is over twenty times greater than the estimated age of the universe: approximately 292 billion years from now, at 15:30:08 on Sunday, 4 December 292,277,026,596. The ability to make computations on dates is limited by the fact that tm_year uses a signed 32 bit int value starting at 1900 for the year. This limits the year to a maximum of 2,147,485,547 (2,147,483,647 + 1900).

Starting with NetBSD version 6.0 (released in October 2012), the NetBSD operating system uses a 64-bit time_t for both 32-bit and 64-bit architectures.
Applications that were compiled for an older NetBSD release with 32-bit time_t are supported via a binary compatibility layer, but such older applications will still suffer from the Year 2038 problem.

OpenBSD since version 5.5, released in May 2014, also uses a 64-bit time_t for both 32-bit and 64-bit architectures.
In contrast to NetBSD, there is no binary compatibility layer. Therefore, applications expecting a 32-bit time_t and applications using anything different from time_t to store time values may break.

The x32 ABI for Linux (which defines an environment for programs with 32-bit addresses but running the processor in 64-bit mode) also uses a 64-bit time_t. Since it was a new environment, there was no need for special compatibility precautions.

Alternative proposals have been made (some of which are in use), such as storing either milliseconds or microseconds since an epoch (typically either 1 January 1970 or 1 January 2000) in a signed 64-bit integer, providing a minimum range of 300,000 years. Other proposals for new time representations provide different precisions, ranges, and sizes (almost always wider than 32 bits), as well as solving other related problems, such as the handling of leap seconds. In particular, TAI64 is an implementation of the Temps Atomique International standard, the current international real-time standard for defining a second and frame of reference.

So now I can confidently proceed secure in knowing Linux on my 64 bit hardware will work for dates more than 20 years in the future, and that on my 32 bit boxes, worst case, I need to run a BSD release (that I already have stored in archives).

I’m also even more justified in my desire to avoid any car with a computer in it (successful so far and not planning to buy anything newer) and not have my home appliances know the time, nor talk to the internet. (“Smart Grid”? When it all breaks 20 ish years out?)

Yeah, yeah, I know, we’ll just buy everything all over again in 2020 to 2025…

But I like old things and I like to have them still work.

Besides, I’m looking at doing things using times measured in centuries…

In Conclusion

So there you go. Reason to migrate toward 64 bit hardware for new boxes. Reason to use BSD for ‘Scientific’ things with deep time into the future. And comfort in knowing some folks actually look at such things.

But I’d start being very cautious about buying things that have embedded systems in them that are ‘date aware’ and that you expect to know about any times/dates after 2037 or so…

Though do remember that if it doesn’t have a clock in it or “do time” this is unlikely to matter. During the Y2k hysteria I’d ask folks: “Does the gas pump have a clock in it? Do you set the time?” and then explain to them that “IF it doesn’t know what time it is, it will continue to work Just Fine.”

Subscribe to feed


About E.M.Smith

A technical managerial sort interested in things from Stonehenge to computer science. My present "hot buttons' are the mythology of Climate Change and ancient metrology; but things change...
This entry was posted in Tech Bits and tagged , , , , . Bookmark the permalink.

11 Responses to Why I Like BSD – It’s About Time…

  1. BobN says:

    Thanks E. M. Very useful information to have!

    Some time if you get time, it would be great to get your perspective on why windows seems to never get better and why they have never ending updates that are huge. To a low level programmer like myself it is not obvious why they can’t progress.

  2. Ron House says:

    Hi E.M. Great article. One small nitpick: BSD stands for “Berkeley Software Distribution”.

  3. E.M.Smith says:

    Well, when things constantly change and always need updates you get to sell the same product to the same people a dozen times. A kind of planned obsolescence. So the machine of today does about 10x as much as the machine of 1990, but Windows is just as slow, so you need to buy a new box with a new copy of windows… and a new license fee to Microsoft.

    All increase in machine speed belongs to them, not you, so they can use it to write worse code cheaper with automated fat tools and cheaper less skilled programmers.

    Compare Unix where all that speed is mine and my old Pentium2 ar 400 MHz is still fine. Why do I need to buy anything to replace it?

    I am now living about 1/2 time on a $60 Raspberry Pi and it is fine for most things. Software fee of zero. Why? Because the software was written first for 16 bit computers in 1980 and never thrown out or junked up, so still fast and efficient. (Though lately some Linux releases have started into the code bloat and sloth methods… it is still reversible).

    In short: Attitude.

    The *NIX way cares about machine efficiency and doing it right or your peers will razz you.

    The MS way is minimal cost, maximal profit, the box is theirs to consume, and you are too stupid to care about, just have Marketing convince you that you need it.

  4. beng135 says:

    Thanks. If BSD can run Firefox, I’ll give it a try. Disappointingly, my Linux Mint 17 can’t run the latest Firefox revision (crashes) and Opera is a bit buggy & slow. Interestingly, my Puppy Linux (yeah, unsupported now) is subject to far more tinkering than Mint, but has proven very resilient (just undo what I just did to screw it up, and it’s fine) — perhaps because it is relatively simple.

  5. Graeme No.3 says:

    Each release of Windows required more machine power, so you were expected to buy a new machine. That meant the machine manufacturers were pleased and sold their machines with Windows pre-installed. (Especially as MS ‘locked them in’). Anybody who wanted something else faced a financial penalty as they had already purchased an O/S, and who wanted to pay more in time and money? The other boost came from all the software suppliers, all of whom would release new ‘improved’ versions. The whole choir say the Windows anthem.

    It took monumental incompetence by Microsoft to lose their leading position, with a series of dud versions. Windows 2000? Vista? Windows 8? There is a small local computer retailer who refuses to install either 8 or 10 on those they sell. They are doing reasonable business (I got them to strip Win8 off a new computer because it drove me batty. Then I dumped it cheaply and switched to Mac. Likewise with another I donated to a Club, which had to have Windows to run the Financial package – which is now going to a cloud based approach because of all the troubles from Windows ). They aren’t getting much traction on the phone or tablet market either.

    More companies and people are discovering that they don’t need Windows (I’m talking ordinary computer illiterate users like me) so soon the bloated carcass of Windows will no longer fill the landscape.
    Speaking of Win 2000 I knew a chap managing a network of 1500 machines who tried out 2000 when it first became available. He knew there were 4 known problems by then, but he found a fifth when he accidentally hacked into the kernel – his words and he claimed he wasn’t even trying to do so, just trying various commands. Needless to say, that was one company that never bought Win 2000.

  6. BobN says:

    Windows 10 can delete files it doesn’t like. I assume this is unlicensed copies of software, but I bet they delete other things. This to me is reason enough to never use it.

  7. E.M.Smith says:

    @Ron House:

    Yeah.. I’ll fix that when I’m back at a real computer w/kb. Brain tends to run ahead of fingers and was already thinking about Sys V when the S-word hit the type buffers…. A common errormode for me. “Proximity capture on later word during I/o dump”…


    UPDATE: I’ve changed “Standard” to “Software” in the article. Also requested OttoPilot to be more careful about typing when I’ve gone off to think about other sentences in the future ;-)

  8. Chuck Bradley says:

    Sometimes the system time is used as the seed for random number generators in applications that do not use time as time. Depending on what the time is set to after the rollover, those applications might become a lot less useful because less variable.

  9. E.M.Smith says:

    @Chuck Bradley:

    The INT just rolls over to a very large negative number, so the date is very far in the past. But if they just chop off the time bits and skip the date portion, it ought to still be a good enough random seed. Then again, getting anything like a random number is fraught with perils anyway and needs a lot of careful thinking and testing to not screw things up. Suddenly having a negative seed if the code just assumes the current date will always be a positive number could very well cause some code to barf.

    (Vague memories of making a random number generator in FORTRAN 40+ years ago and the difficulty involved stirring in the memory box… IIRC it was ring shifted so low order bits became high order so more random, then some math done on it to make bits more random, then another round of shift and ‘form loaf’ of size needed… Something with using DOUBLES and then chopping out the low half as INT… depending on how it was done that negative bit signed value could be problematic… wouldn’t want your random numbers to start being all negative values…)

  10. Another Ian says:


    Just sent this to a bloke I know that was in the Y2K panic as a program checker.

    Feedback might be interesting.

    He says in his training they were taught such that Y2K wasn’t an issue if you did time properly.

  11. E.M.Smith says:

    @Another Ian:

    Back in about 1982 I was writing a database schema for some biz app for Amdahl… My boss complained at me that I was wasting space as I had a 4 digit year field. Try as I might to convince him that it was only 18 years away and we needed to start building For That Day, I had to shrink the year field to 2 digits.

    About a decade later Amdahl was being consumed by a Japanese company and at this point is no more. My app died well before y2k .. proving my boss right and me wrong.

    During the Y2K Hysteria… I and most of my team was paid nicely to be ‘available’ for whatever happened, despite our repeated protests that Nothing Will Happen… But we booked the over time pay, had some pizza and after midnight everyone went home or to a bar for beer… A nice party was had by all the hacker sorts working graveyard for no good reason…

    As the saying goes “Oh Well, sign here and I’ll cash the check”…

    IMHO this particular date issue IS an issue, but only for forward looking apps. By about 2020 everything and their cousin will be running on 64 bits or have 64 bit time. The only reason I’m paying any attention, really, is because I’m looking to do century scale model stuff with dates and at least 20 years into the future; and I’m fond of my collection of 32 bit hardware.

    So “for now” I’m OK, and I do have one 64 bit machine (where I was going to do the work anyway) and I can always stick BSD on the smaller boxes if I need it. I can work with that.

    But it makes for a nice “heads up” for anyone else doing ‘future oriented’ stuff…

Comments are closed.