Update 10/01/2002: Getha pointed out that the O'Reilly reference has moved. Thanks!
Take a look at http://linux.oreillynet.com/lpt/a/linux/excerpts/linux_kernel/how_computer_boots.html for more on PC architecture from the Linux viewpoint. It highlights the similarities with the Mac description by ccunning.

Update 31/05/2001: Take a look at http://www.howstuffworks.com/operating-system2.htm (and the other pages in the article) for almost exactly what this node is about, sort of :-).

Booting is the process of a computer becoming operable when power is applied.

There are a number of stages.

First, all the hardware must be reset into a sane state. This is handled by low-level hardware design and is beyond the scope of this write-up.

Then the CPU must be given some instructions to execute. Usually this is called "bootstrap" code. It's just enough to get the next stage underway. The 6502 processor, for example, always starts execution at the same memory location. Putting ROM at this point in the address space provides the initial CPU instructions. I imagine other systems follow a similar mechanism.

On some systems (e.g. ZX81, BBC Micro, Acorn Archimedes), the operating system is held in ROM and can be started directly. However, on PCs, as the OS needs to be loaded (either from fixed (hard disk) or removable (tape, floppy, CD-ROM, etc) media), the bootstrap code must access these external devices. The code to load the OS is part of the BIOS. (Note, even on ROM-based systems, a division between "BIOS-like" layer and a higher Operating System layer can exist, allowing alternative operating systems to be loaded.)

Beyond this point generalisations become less useful. However, the following is a reasonable effort:

  • the OS will install "handlers" for all the hardware devices it can identify.
  • any OS-specific initialisations will be performed.
  • usually some administrative shell is executed.
  • processes are then executed to put the computer in a mode suitable for normal use.

On a PC, the BIOS loads and executes code from a "known location" on the boot media, called the Master Boot Record. This is also known as "second stage bootstrap", as this area isn't large enough to hold a complete operating system for the PC. The second stage bootstrap is more complex than the BIOS routines that loaded it, and can - for example - provide a choice of operating systems to load.

This process also occurs in some mainframe systems. The "BIOS" knows how to read a paper tape (a simple serial input device), for example (maybe having had the routine entered from the panel). The routine on paper tape is then general enough to load the operating system from disk.