Contemporary computer architecture
After a detour through a (fairly) modern programming language (racket), we consider the
hardware components of contemporary computers. Although a variety of hardware architectures
exist, some major features are present in the overwhelming majority of computers:
1 A Central Processing Unit (CPU), which contains an Arithmetic/Logical?§ unit (ALU)
and a control unit.
2 Main memory
3 Peripheral devices, including keyboards, monitors, disc drives
We earlier considered some of the basic arithmetic and logical operations that computer circuits
can carry out on sequences of bits: addition, subtraction, multiplication, division, and the logical
operations AND, OR, and NOT. Circuits to rapidly carry out these, and other related, operations
are grouped in the ALU.
Sequencing of operations (determining what happens when) is the function of the control unit. In
the earliest computers, this sequence was "hard-wired" by physically soldering together circuits, or
connecting them with physical plugs. The circuits containing these "instructions", together with
the ALU, occupied large racks, and a hard-wired computer was dedicated to just the particular task
it was wired for.
The so-called Von Neumann architecture was the insight that the sequencing instructions could be
stored in the same device that non-program information is stored in --- main memory. What is now
"hard-wired" is a set of generic, fundamental instructions (for example, fetch some value from
memory) that every computer program can be expressed in terms of. This instruction set can be
referred to by using a number (or address) for each instructions. Once this is done, a computer
program can be stored as a list of numbers (called op codes) in main memory, together with
operands the instructions may need (more on that later). This low-level (close to the hardware),
numerical description of what instructions the computer carries out is sometimes called [Machine
The choice of instruction set is important in CPU design. One choice that must be made is whether
to use a relatively small set of simple instructions (requiring each program to use a larger number
of relatively fast instructions) or a larger set of more complex instructions (requiring fewer, but
slower, instructions to implement a program). Both approaches are used currently in reduced
instruction set computers (RISC), and complex instruction set computers (CISC), and it's not clear
that either one is superior to the other in all situations.
Today's CPU houses both the ALU and the control unit. Compared to the large racks of circuits
that the early CPUs required, Intel Pentium processors are a couple of inches square, and more
noticeable for the heat they produce (requiring a fan to dissipate it) than the space they occupy.
The CPU communicates with main memory over a set of wires (collectively called a bus) that can
pass signals consisting of bits (16-bit, 32-bit, for example). There is a trade-off between having large amounts of memory (currently many billions of bits) available, and the time necessary to
fetch memory contents to the CPU. The CPU keeps and maintains smaller amounts of memory for
immediate calculations (called registers), and intermediate amounts of memory (called cache) are
available for frequently-used instructions. The speed of accessing cache is somewhere between
that of accessing registers and main memory. (We also use the word cache for other purposes, for
example the name is used for the files on hard drives where an internet browser stores all the
recently visited web pages) [CPUs]§.
The machine cycle that the control unit of a computer continuously cycles through (unless the
power is off), can be broken into three parts:
Fetch an instruction from main memory to the instruction register.
Decode the the operand(s) for the instruction.
Execute (carry out) the instruction. (return to step 1).
To keep track of which instruction to carry out next, the control unit uses a register called the
Program counter (PC). This is used to hold addresses (locations) in the main memory. Once the
next instruction has been fetched and placed into the instruction register, it increments (increases)
the PC to the location of the next instruction. Certain instructions that can control what locations
the PC is put into (this causes branching or looping). The sort of instructions that are available can
be grouped into three broad categories are:
4 Arithmetic/logical operations.
5 Data transfer (load or store in main memory)
6 Program control (branch or halt).
It is very instructive, to work through the steps that might be required in some hypothetical
scenario such as, to add two numbers stored in main memory and store the sum in a third location.
When we start, the PC holds the address of a block in main memory that will hold the following
commands (rather than numbers for commands and operands, I use suggestive short forms):
LOAD A1 R1
LOAD A2 R2
ADD R1 R2 R3
STORE R3 A3
The machine cycle begins by loading the first command into the instruction register, decoding it
and advancing the PC to the next address, and copying the contents of main memory address A1 into register R1. Next the machine cycle loads the second command into the instruction register,
decodes it and advances the PC to the next command address, and loads the contents of main
memory A2 into register R2. Next the machine cycle loads the third command into the instruction
register, decodes it, advances the PC to the next command address, and adds the contents of R1
and R2, storing the result in R3. Next the machine cycle loads the third command into the
instruction register, decodes it, advances the PC to the address of the next command, and stores
the contents of register R3 into main memory location A3. Finally the machine cycle loads the
fifth command into the instruction register, decodes it and the machine cycle stops.
That's a lot of steps to carry out something equivalent to:
(define n3 (+ n1 n2))
However, since millions of these commands are executed in a second, such a sequence is,
Other local hardware
Other than listening to the CPU fan or feeling the heat it dissipates, you would have a hard time
detecting the activity of a computer carrying out instruction like those above, or instructing the
computer to change its activities. Devices such as keyboards, mice, drives, and monitors are
necessary to insert new content into memory (input) and see the result of changes to memory.
These, and other peripheral devices, are typically attached to the bus, and (in some architectures)
are each given a range of memory addresses that can be loaded and stored, to and from registers,
much as main memory does.
Many peripheral devices contain controllers with direct memory access (DMA) capability, that
allow them to load/store bit patterns from and to main memory, without having to make the
transfer, via a register on the CPU. This has the advantage of allowing communication between
memory and peripheral devices during the times when the CPU is otherwise occupied which
lightens the load on the CPU.
The steady trend towards smaller components (transistors and other circuitry) makes computation
faster (by reducing the distance signals have to travel on the CPU). Empirical observation (for
example, Moore's law) suggest that this leads to a doubling of computer speeds every eighteen
months, but there are limiting factors: it becomes harder to safely dissipate the heat of the circuits
as you concentrate them in a smaller space, and there is a limit photolithography's ability to
reproduce small circuits. Fast computing on the CPU must somehow be integrated with other
devices, so the speed that signals can be moved across the bus can become the bottleneck.
The contents of main memory typically disappear when the power is turned off. Longer-term storage is provided by media such as magnetic tape or disks, and compact discs. Storage on these
devices is generally cheaper (dollars per bit) than main memory (and hence larger amounts are
available), less volatile (although it is too soon to know how long the information will last on
them), and have the ability to be removed from the vicinity of a computer and stored elsewhere as
A disadvantage of mass storage compared to main memory is speed: access to information on disc
is about thousands of times slower than from random access memory (RAM). When the media is
not connected to a computer, time and human intervention are required to connect them (e.g. slide
a disc into a CD drive).
7 The first magnetic recorder was invented by Valdemar Poulsen in 1895. The read/write
heads in magnetic storage record data in the form of magnetized spots on iron oxide coatings.
Information is stored on a magnetic coating over a long spool of tape. The tape is
wound/rewound under computer control, and may be divided lengthwise into several tracks.
Random access to sectors is very slow since it is a serial access medium, and is currently used
for archives (although tapes don't last forever, aprox. 3-5 yrs). Large amounts of information
can be stored on magnetic tapes and hence the reason why they are so frequently used for
archiving and backing up data. Information can be lost on magnetic tapes due to the width of
magnetic tape changing, even when stored in a dark, dry space. Magnetic tapes are also
sensitive to the Earth's magnetic field, thus after long time periods of storage, some machines
may not be able to read the tapes.
Information is stored on in concentric circles (tracks) on magnetic disks. Each track is
subdivided into sectors, each holding a fixed amount (e.g. 1024 bytes) of information. Since
read/write "heads" move in unison between the discs on a common spindle, the combination
of tracks a fixed distance from the centre is called a cylinder. The number and location of
tracks, sectors, and cylinders is encoded when the disc is manufactured, or formatted.
Information from a single sector can be accessed separately from other sectors, so the sector is
the granularity of "random access" for this device. Data access times are typically measured in
milliseconds (compare this to nanoseconds for RAM). Linear information density on tracks
decreases as you move away from the spindle, so the rotation speed is constant (unless recent
zoned-bit recording is used). See [Wikipedia on hard disks]§.
Hard drives can fail if the read/write heads "crash" into the disk surface (drives are usually
sealed to prevent particles that might cause a crash), or due to corrosion or humidity. Mean
time between failure may be cited as five years, but your particular drive may be the one that
crashes in 5 days. Backups or even redundant disks (RAID) are used to protect against this.
Information is stored by changing the reflective coating on these discs, and read back by
shining a laser in noting changes in the reflected light. A single track is laid down in a spiral,
from the centre of the disc to the outer edge of the disc. The spiral is divided into sectors, and the linear density is uniform (so data transfer is faster near the outer edge of the spiral, if the
CD spins at a uniform rate). CDs have random access to sectors, meaning that information can
be easily read from any point on the disk, but this is slower than magnetic discs. Problems that
may arise with compact discs are: the plastic coat can change its size, the adhesive layer may
fail, and/or the ink could leak from the top layer into the layer containing all the information.
Some USB drives store memory without macroscopic moving parts by trapping electrons in
tiny chambers of silicon dioxide. These signals are kept for years without external power, and
are suitable for off-line storage. Without moving parts, flash memory is immune to physical
shock and some of the other mishaps of moving platters or disks. The drawback that prevents
flash memory from replacing current (transistor-based) RAM is that this type of memory is
best changed in large blocks (rather than at the byte or bit level), and the silicon dioxide cells
are eventually damaged by repeated re-writing of their contents.
From bits to files
The format of the information we want our computer to keep track of (that poetry we're writing,
our emails to our mother, our database of favourite tunes) is very unlikely to match the hardware
design of the computers mass storage. We're unlikely, for example, to write documents that are
some exact multiple of 1024 bytes long, just because our hard drive's sectors are that length. In
practice, the information we are interested in is spread over multiple sectors, and the same sector
may contain parts of several units of information (commonly called files). We users need to be
"protected" from the low-level details of file storage, and computers do this by reserving part of
main memory as a buffer, where files are re-assembled when we need to work on them, and then
stored in available sectors on the mass storage device when we're finished.
Rather than a soup of numerical addresses of disks, cylinders, sectors, and bytes, the computer
presents us with this information grouped into a file, usually with a name formed from a sequence
The concept of a file is general enough to include files that contain the names and locations of
other files. This is what underlies what, as computer users, we deal with as directories or folders.
And this trick can be repeated: a directory or folder can contain another directory and folder,
creating a hierarchical or tree-like structure of folders. An example is the directory where some
student accounts that begin with 'c6' "live" on cdf (directory /h/u4/c6/01. There are 208 of them
(yours might well be among them), and some of these have a subdirectories A1, A2, and (soon)
A3. A common way to conceive of this is as an upside-down tree. The root (at the top) is a
directory that contains subdirectory h (for home directories), and other fundamental directories
(such as bin, where important applications are stored). At the bottom are the leaves, individual
files that don't contain other files. To describe the path from the top to the bottom, we use some
character that isn't part of file names to show all the directories in a chain. For example
'/u/heap/pub/alice30.txt' is the path to my file called 'alice30.txt'.
Managing files in a human-intelligible form assumes that our computer runs more than one
program. Otherwise, a computer dedicated to a single computation would simply manipulate the details of a cylinder/sector/byte in a single program, and no human (other than the original
programmer) would have to deal with this level of detail. However, many computers are not
dedicated to a single computation, and this has raised the need for file management, and other
functions that we expect of anoperating syOperating Systems came after human operators
Operating system software has inherited some of