Preface
This book (CS:APP) is for computer scientists, computer engineers, and others
who want to be able to write better programs by learning what is going on “under
the hood” of a computer system.
Our aim is to explain the enduring concepts underlying all computer systems,
and to show you the concrete ways that these ideas affect the correctness, perfor-
mance, and utility of your application programs. Other systems books are written
from a builder’s perspective, describing how to implement the hardware or the sys-
tems software, including the operating system, compiler, and network interface.
This book is written from a programmer’s perspective, describing how application
programmers can use their knowledge of a system to write better programs. Of
course, learning what a system is supposed to do provides a good first step in learn-
ing how to build one, and so this book also serves as a valuable introduction to
those who go on to implement systems hardware and software.
If you study and learn the concepts in this book, you will be on your way to
becoming the rare “power programmer” who knows how things work and how
to fix them when they break. Our aim is to present the fundamental concepts in
ways that you will find useful right away. You will also be prepared to delve deeper,
studying such topics as compilers, computer architecture, operating systems, em-
bedded systems, and networking.
Assumptions about the Reader’s Background
The presentation of machine code in the book is based on two related formats
supported by Intel and its competitors, colloquially known as “x86.” IA32 is the
machine code that has become the de facto standard for a wide range of systems.
x86-64 is an extension of IA32 to enable programs to operate on larger data and to
reference a wider range of memory addresses. Since x86-64 systems are able to run
IA32 code, both of these forms of machine code will see widespread use for the
foreseeable future. We consider how these machines execute C programs on Unix
or Unix-like (such as Linux) operating systems. (To simplify our presentation,
we will use the term “Unix” as an umbrella term for systems having Unix as
their heritage, including Solaris, Mac OS, and Linux.) The text contains numerous
programming examples that have been compiled and run on Linux systems. We
assume that you have access to such a machine and are able to log in and do simple
things such as changing directories.
If your computer runs Microsoft Windows, you have two choices. First, you
can get a copy of Linux (www.ubuntu.com) and install it as a “dual boot” option,
so that your machine can run either operating system. Alternatively, by installing
a copy of the Cygwin tools (www.cygwin.com), you can run a Unix-like shell under
xix