How Computers Work  


Computer Components

A computer is a complex electronic machine, but its operations can be understood sufficiently in terms of a few interconnected components:

  • The Central Processing Unit (used to be called the "brain" in the popular press). Since none of these words mean anything except the middle one, this is also called the processor. The processor is responsible for all the "intelligence" we associate with the computer. Its role is to follow a set of instructions written by the programmer and perform basic arithmetic calculations (like addition and number comparison).
  • The Memory Unit where the data and the instructions are temporarily stored.
  • The Input/Output Unit allows the processor to communicate with the outside world, such as output to monitors or input from keyboard.
  • The clock, a component that gives tempo (rhythm) to the operations. When all else is equal, the faster the clock, the faster the computer. Usually, all else is not equal, and the clock speed is more about marketing than computational speed.

The processor is further divided into two smaller components

  • The Arithmetic-Logic Unit (ALU) performs the basic arithmetic calculations (think of it as a very simple "calculator")
  • The Control Unit that follows the program's instructions and gives directions to the "calculator".

In the picture note that the components are connected through a set of wires called the bus.

computer model comprising processor, memory and I/O devices
A computer model showing the processor, memory, and I/O devices.

Watch and Learn

The article What's inside my Computer by Strickland, Jonathan, from HowStuffWorks.com, has videos that explain the internal parts of a computer.

The operations of any computer are as follows ad infinitum ("forever"):

  1. fetch instruction from memory
  2. decode the instruction. What is the processor supposed to do? Add? Subtract? Move some data to/from memory?
  3. execute the instruction. This may involve such things as telling the processor to add two numbers, getting some data from memory, storing some data to memory, or telling some I/O device to do something.
  4. REPEAT!

This is called the fetch/execute cycle. Note that the processor is so much faster than the I/O devices, that I/O doesn't appear prominently here. A modern processor is able to execute millions of instructions while waiting for an I/O device, even a fast device like the disk or the network.

The main point here is that the computer doesn't know how to do anything "automatically": there's always some program code (set of instructions) telling it how to do something.

The input/output unit is connected with the usual peripherals such as keyboard, mouse, the various "drives" (such as hard drives, floppy drives, zip drives, DVD drives, CDROM drives, etc), monitors, printers etc. So, the components and operations of a computer are remarkably simple. Complication enters only for performance reasons, but any computer that you are likely to see these days contains the above components.

Kinds of Memory

Looking at the picture above, you see a big yellow box labeled Memory, but you'll also see, if you look closely, hard drive attached to the bus. What's the difference? Does it matter?

Yes, it does. The memory we describe there is super-fast memory chips that are right on the circuit board, just a few inches from the processor, what is sometimes called RAM or Random Access Memory. The most important properties of RAM are

  • It's super fast, so it's almost fast enough to keep up with the processor, and
  • it's volatile, which means that the information in it is lost if the power is removed.

If you've ever lost a document you were working on using your computer because the power went out or your battery ran out, that's because the stuff you were working on was in volatile memory. The files that are saved on the hard drive weren't lost.

The hard drive of your computer is (usually) a spinning disk with magnetic coating that stores the zeros and ones of your files as a pattern of magnetization. The exact representation isn't important, but two properties of hard drives are crucial:

  • They are slow. Even though the disks spin really fast and they can read and write bits faster than you can blink your eyes, they are glacial compared to the speed of the RAM. They're at least a million times slower.
  • They are non-volatile or permanent. Removing the power from a hard drive doesn't lose any information, and when the power is restored, you can get the information back.

There are other kinds of drives, such as solid-state drives, but the same properties appear. These properties mean that your computer mostly works by copying information (both programs and data, such as your files) from long-term storage on the hard drive into fast memory in the RAM, and that's where it stays while the computer is running. But you should save your stuff in RAM to hard disk on occasion, in order to avoid losing your work should someone trip on your power cord and pull the plug, or your battery unexpectedly die.

Finally, the most recent technology (invented in the past 15 years) is the USB flash drive , which has become the ubiquitous choice for transferring information between devices.