OS History--DOS and Windows

CS 321 2007 Lecture, Dr. Lawlor

Operating systems for personal computers are extremely important, but quite new, and something of a historical accident.

Back in the late 1970's, many hobbyists were building strange personal computers (PCs), often with homemade wooden cases like the Apple 1

DOS is born from CP/M

At the time, the operating system of choice for PCs was either "none" (write bare-metal programs in assembly language) or "CP/M", a commercial OS from a tiny (almost one-man) company called Digital Research. 

As the 1980's began, IBM was preparing a very quick "skunkworks" project to capitalize on the hobbyist interest in small personal computers.  IBM approached Digital Research to have them port CP/M onto their new 8086 machine, but IBM did not receive a warm welcome--reportedly Gary Kildall, the lead programmer and CEO, went golfing instead of meeting with the IBM representative.  So IBM shopped around, and found a willing entrepneur, Bill Gates, who sold IBM an operating system he didn't actually have yet.

Bill Gates, at the time a star programmer but college dropout, found a little one-man company working on a project called "QDOS" (reportedly, "Quick and Dirty Operating System").  QDOS was similar to the popular CP/M, but Bill felt he could easily port the small OS to IBM's 8086 PC, so Bill bought the rights to QDOS so he could build an operating system to sell to IBM.  Bill called his new OS "DOS", or "Disk Operating System". 

IBM purchased the rights to distribute DOS from Bill gates, and sold his OS as "PC-DOS" along with every IBM PC.  The IBM PC was a huge, extraordinary commercial success, bought in large numbers by hobbyists, corporations, scientists, and all and sundry.  Hence PC-DOS instantly became a very popular product.

Curiously, Bill Gates did not sell all the rights to DOS to IBM--Bill Gates, and his tiny 70's startup company Microsoft, kept the right to sell their own separate copy of DOS, "MS-DOS".  This wouldn't have mattered if everybody bought their IBM PC's from IBM, but the IBM PC's BIOS was cloned almost immediately, and "IBM Compatible PCs" began entering the market.  So if you built an IBM Compatible PC, you needed an OS, and IBM wasn't going to sell it to the clone manufacturers, but Microsoft would!

Hence via a series of rather unlikely historical accidents, and some extremely shrewd business decisions, Microsoft became the de-facto world provider of operating systems.

All through the 1980's, several companies sold DOS-compatible operating systems:

Software Architecture of DOS

When an IBM PC starts up, the BIOS loads the "master boot record" (or "boot sector") from the first 512 bytes of the disk.  This consists of 16-bit x86 PC code.  From this "boot sector code", you can make interrupt calls (exactly like system calls) to call the "Basic Input/Output System" or BIOS, whose code is stored in ROM.  Every PC's BIOS, even today, is software-compatible with the original IBM PC's BIOS.

The BIOS provides a very primitive programming interface:
It is possible to write programs that call only BIOS routines, but it's ugly.

On top of the BIOS, for programmers DOS mostly provides a filesystem interface, with directories and files.  For users, DOS provides a command line interface.

At startup, the DOS boot sector loads up "MSDOS.SYS" and "IO.SYS", which stay in memory and provides programmer services.   For programmers, DOS mostly provides a filesystem interface, with directories and files.  This "terminate and stay resident" (TSR) software could be controlled by the "config.sys" file.

For users, DOS provides a command line interface, via a little program called "COMMAND.COM".  This program reads command-line commands such as "DIR" from the user, and then executes them.  COMMAND.COM has a small number of such commands built in, but can also read in the code for new commands from files called "executables".  DOS comes with a bunch of built-in executables.  Once COMMAND.COM starts up, it reads  "AUTOEXEC.BAT", a "batch file" of ordinary DOS command lines.

Unlike with modern operating systems, a DOS executable does NOT run in a process, alongside DOS and any other running programs.  Instead, a DOS executable basically takes over the entire machine, and can perform direct hardware access if desired.  When the program exits, the MSDOS.SYS code (still in memory) reloads COMMAND.COM.

A DOS executable can directly access:
This means you generally have to reboot when a DOS program hangs or crashes.  DOS loads almost instantly, so this is no big deal.

DOS has no virtual memory, only one user can run the computer at a time, one program can be loaded at a time, and graphics handling or any specialized hardware handling is entirely up to the application--DOS only provided text-mode interface functions.

The Rise of Windows

As the 1980's rolled around to the 1990's, the shortcomings of DOS were becoming more and more evident.  Microsoft worked and worked on "Microsoft Windows", a program to add a graphical user interface (GUI) on top of the DOS command line.

The first even moderately successful version of Windows was Windows 3.1.  It ran directly on top of DOS, in the sense that you had to first install DOS, then install Windows.  Once you booted to a DOS prompt, you could then type "win" to start up Windows.  When you exited Windows 3.1, you got back to a DOS prompt.

While Windows 3.1 was running, it provided many OS-like features far beyond DOS.  It had a decent graphical user interface interface, supporting overlapping windows and a mouse.  It allowed multiple programs to run at the same time (multitasking).  It did not provide any particular hardware protection, however, and it was common for one crashing program to bring down the entire machine.  In response to an unimportant program causing an illegal instruction, Windows 3.1 prints "A program has encountered an error.  Please close the program, close all other applications, and shut down windows."  The idea is that if a program crashed, it probably screwed up lots of other stuff in Windows too, so you should try to save your work and reboot as soon as possible.

Like DOS, all of Windows 3.1 was written and ran in 16-bit mode, even though all processors starting with the 386 could run 32-bit code.

Windows 95

The first consumer version of Windows with protected memory was Windows 95.  Windows 95 could run 16-bit or 32-bit programs well, could (mostly) protect the machine from runaway and crashing programs, although malicious programs could still easily circumvent Windows' limited hardware protection.

Windows 95 also had a dramatically revamped user interface, with the "Start" menu, taskbar, right-clicking, and a nicer beveled 3D look.

Windows 98 and Millenium Edition both followed in this same vein, adding little beyond new hardware drivers to the original Windows 95.  All were written in a mix of 16-bit (DOS style) and 32-bit code.  Even Windows Millenium could be exited back to a DOS prompt, and restarted with the "win" command exactly like Windows 3.1.

Windows NT

Even prior to the release of Windows 95, Microsoft had been working on a new version of Windows called Windows NT, built using modern operating system principles--with a fully 32-bit kernel, multiple users, multiple programs, and real protected memory. 

Windows NT 4.0 was released alongside Windows 95, with a very similar GUI interface.  Windows NT 4.0 actually ran on non-x86 hardware, including the PowerPC, MIPS, and DEC Alpha chips, although this capability was dropped in later commercial versions.

Windows XP, 2000, and Vista are actually the modern versions of Windows NT.