This book is about "threads" and how to use them. Thread" is just a name for
a basic software "thing" that can do work on a computer. A thread is smaller,
faster, and more maneuverable than a traditional process. In fact, once threads
have been added to an operating system, a "process" becomes just data—address
space, files, and so forth—plus one or more threads that do something with all
that data.
With threads, you can build applications that utilize system resources more
efficiently, that are more friendly to users, that run blazingly fast on multiproces
sors, and that may even be easier to maintain. To accomplish all this, you need
only add some relatively simple function calls to your code, adjust to a new way of
thinking about programming, and leap over a few yawning chasms. Reading this
book carefully will, I hope, help you to accomplish all that without losing your
sense of humor.
The threads model used in this book is commonly called "Pthreads," or
"POSIX threads." Or, more formally (since you haven't yet been properly intro
duced), the POSIX 1003.1c-1995 standard. I'll give you a few other names later—
but for now, "Pthreads" is all you need to worry about.
As I write this, Sun's Solaris, Digital's Digital UNIX, and SGI*s IRIX already
support Pthreads. The other major commercial UNIX operating systems will soon
have Pthreads as well, maybe even by the time you read this, including IBM's AIX
and Hewlett-Packard's HP-UX. Pthreads implementations are also available for
Linux and other UNIX operating systems.
In the personal computer market. Microsoft's Win32 API (the primary pro
gramming interface to both Windows NT and Windows 95) supports threaded
programming, as does IBM's OS/2. These threaded programming models are
quite different from Pthreads, but the important first step toward using them pro
ductively is understanding concurrency, synchronization, and scheduling. The
rest is (more or less) a matter of syntax and style, and an experienced thread pro
grammer can adapt to any of these models.