MadSci Network: Computer Science
Query:

Re: How is an operating system built?

Date: Fri Sep 25 21:39:17 1998
Posted By: Madhu Siddalingaiah, Physicist, author, consultant
Area of science: Computer Science
ID: 906362887.Cs
Message:

Hi Joe.

Fantastic question!!

There are two basic techniques that can be used to develop an operating system: cross development and bootstrapping. Cross development exploits existing operating systems and development tools like cross compilers. Bootstrapping is a more fundamental approach requiring nothing more than the ability to program machine code into memory, typically read-only memory (ROM).

The first commercially successful operating system was developed in 1964 by International Business Machines (IBM) for their 360 series computers. The operating system was called OS/360. OS/360 pioneered many of the basic principles of OS design by providing application program loading, uniform application program interfaces (APIs), device drivers, and even multitasking. The UNIX operating system was developed by AT&T in the late 1960's. Other systems existed before OS/360, but they lacked many of the features we have come to expect in an operating system. In older systems, application programmers typically wrote much of the hardware interface code and loaded their programs directly into specific locations in memory. Early systems exposed the underlying hardware to the programmer, device abstraction simply did not exist.

If you wanted to develop your own operating system today, the fastest way to do it is to use cross development tools. Let's say that you have a 80x86 PC running DOS or Windows and you want to develop an operating system for a PowerPC machine. The first piece of software you would need is a cross compiler. A cross compiler is just like any other compiler, but it generates code for a processor different from the one that it runs on. The GNU organization has developed freely available cross compilers for a number of processors. You can write C or C++ code on a PC and generate PowerPC machine code, for example. This development strategy is routinely used by embedded system developers.

The typical development process is as follows:

This is enough to get things going. Of course, modern operating systems include lots of additional services and utilities.

If you don't have the luxury of a cross development system, the task is much more challenging, but not impossible. The OS must be built up iteratively from small pieces. The initialization and first order I/O routines must be programmed into memory directly. A hardware programmer as simple as a hex keypad can be used. Initially, machine code must be explicitly stored into memory until a rudimentary assembler can be built. High level languages such as LISP or FORTH can be readily developed in assembly alone. More sophisticated development environments can be built given a LISP or FORTH interpreter. Once a high level programming environment is available, the steps are similar to those of the cross development cycle.

The bootstrap procedure described above was used by the very first operating system developers. In modern times, the cross development approach is used to save time and cost. Windows 95 and Windows NT were actually developed using DOS machines and compilers. Most of this code is written in C and C++ with some assembly code at the lowest layers.

Bootstrapping is a very interesting concept which is often applied to a number of large systems, not just operating systems. Electric power plants themselves need electricity to start and run. Once a plant is running, it can sustain it's own power needs. Starting requires outside power which can be obtained from the power grid. This is analagous to cross development of an operating system. If no power is available from the grid, a black start must be initiated. The procedure is as follows:

This procedure is very similar to that used by large jet aircraft to start their main engines. Jet aircraft do not carry enough battery power to start the main engines, so the pilots start an auxilliary power unit (APU) using battery power. The APU is a gas powered generator usually located in the tail, you can can find the exhaust pipe at the very tip of the tail. The APU supplies most of the aircraft power when the main engines are not running. APU power is also used to spool up the first main engine and light its fire. Once one main engine is up and running, its power is used to fire up remaining engines.

The best way to really learn about operating system development is to do it yourself. There are lots of good books on the subject. I used many of the principles descibed in Douglas Comer's book "Operating System Design, the XINU approach" to write a real time OS for a satellite control system. You can download the source code for the Linux operating system here. You might want to look at the earliest versions first as they are much smaller and easier to understand. A very curious and well written microkernel called uC/OS for embedded systems can be found here.

I hope I have answered your questions. If you have more questions, please feel free to contact me at madhu@madhu.com


Current Queue | Current Queue for Computer Science | Computer Science archives

Try the links in the MadSci Library for more information on Computer Science.



MadSci Home | Information | Search | Random Knowledge Generator | MadSci Archives | Mad Library | MAD Labs | MAD FAQs | Ask a ? | Join Us! | Help Support MadSci


MadSci Network, webadmin@www.madsci.org
© 1995-1998. All rights reserved.