The book uses a hands-on approach in a nontraditional sense. In the traditional hands-on approach to operating systems, programmers implement a simple operating system or modify an existing operating system to add functionality. The hands-on approach provides an in-depth understanding of basic operating system design, but it is hard for programmers to pursue independently in the field. When this approach is used at the average university, instructors spend considerable class time covering implementation details---leaving less time to cover a full range of topics. Also, the traditional hands-on approach usually does not provide practical programming experience with advanced synchronization and communication constructs. An alternative to the hands-on approach is a theoretical presentation. Such a hands-off course covers more material but does not give the reader an in-depth understanding of the concepts in practice.
Practical UNIX Programming: A Guide to Concurrency, Communication, and Multithreading bridges the gap between the hands-on and hands-off approaches to operating systems by covering programming under standard UNIX. The professional programmer can use the book independently or as a companion to a reference book such as Stevens' Advanced Programming in the UNIX Environment and thereby obtain a better understanding of operating systems and of systems programming. A student can use this book as a companion to a traditional textbook, such as Silbershatz and Galvin's Operating Systems Concepts or Tanenbaum's Modern Operating Systems, to learn about operating systems by doing.
The exercises and projects make this book unique. In fact, the book began as a project workbook. It became clear after preliminary development that the material needed to do the projects was scattered in many places---often found in reference books that provide many details but little conceptual overview. The book has since evolved into a self-contained reference which relies on the latest UNIX standards.
The book is organized into four parts, each of which contains topic chapters and project chapters. A topic chapter covers the specified material in a work-along fashion. The topic chapters have many examples and short exercises of the form "try this" or "what happens if." The topic chapters close with one or more exercise sections. The book provides programming exercises for many fundamental concepts in process management, concurrency, and communication. These programming exercises satisfy the same need as do laboratory experiments in a traditional science course. It is necessary to use the concepts in order to understand them fully. Exercises are specified for step-by-step development and most can be implemented in under 100 lines of code.
Project chapters integrate material from several topic chapters by developing a more extensive application. The projects work on two levels. In addition to illustrating the programming ideas, the projects lead to an understanding of an advanced topic related to the application. These projects are designed in stages and most full implementations are a few hundred lines long. Since a large amount of code does not need to be written, the programmer can concentrate on understanding concepts rather than debugging code. In order to simplify the programming, we make libraries available for network communication.
The table below summarizes the organization of the book---fifteen chapters grouped into four parts. The nine topic chapters do not rely on the six project chapters, and a reader can skip the projects on the first pass through the book.
There are many paths through this book. The three topic chapters in Part I are prerequisite for the rest of the book. Readers can cover Parts II through IV in any order after the topic chapters of Part I. The exception is the discussion at the end of later chapters about interactions (e.g., how threads interact with signals).
We have assumed that the readers of this book are good C programmers though not necessarily UNIX C programmers. The reader should be familiar with C programming and basic data structures. Appendix A covers the bare essentials of program development for readers who are new to UNIX. UNIX programmers probably know much of the material found in Chapters 2 and 3, but the coverage here is detailed and later projects rely heavily on it.
A reader should not assume that reading a chapter bestows understanding unless he or she has successfully developed some programs that use the concepts. For a professional programmer, the exercises at the end of the topic chapters provide a minimal hands-on introduction to the material. Typically, an instructor using this text for an operating systems course would select several exercises plus one of the major projects for implementation during a semester course. Each project has a number of variations, so the projects can be used in multiple semesters.
This book includes a synopsis for many of the standard functions. The relevant standards that specify the function appear in the lower right corner of the synopsis box. In general, ISO C is a subset of POSIX.1 and Spec 1170. In some cases the list of required header files differs between standards, with some of the header files being optional for some standards. In these cases the synopsis box lists all relevant header files.
A book like this is never done, but we had to stop somewhere. We welcome your comments and suggestions. You can send email to us at pup@vip.cs.utsa.edu. Information on the book is available on WWW site /pup. All of the code included in the book can be obtained from the WWW site or by anonymous ftp to vip.cs.utsa.edu in the directory pub/pup.
Our second acknowledgment goes to the dozen or so undergraduate and graduate operating systems classes we taught in the years from 1988 and 1995 when we were developing this material. We are grateful to the students in these courses for suffering through drafts in various stages of development and for field-testing emerging projects. Their program bugs, comments, complaints, and suggestions made the book a lot better and gave us insight into how these topics interrelate.
We would also like to acknowledge many other people who read the book and made suggestions for improvement or correction or helped in other ways. Dennis Cadena read an entire draft and made many suggestions. Other people who have commented or helped include Jeff Adamek, Laura Connor, Sandy Dykes, Richard Hatch, Philip Helsel, Bob Hiromoto, Clint Jeffery, George Leach, C. Ed Nicol, Richard Rybacki, Devang Shah, Dennis Wenzel, and Andrea Whitlock.
We are grateful to Greg Doench, our editor at Prentice Hall, and Meg Cowen, his assistant, for guiding us through the process. They helped us improve the book by gentle suggestions and support without pressure. We would also like to thank Jane Bonnell, our production editor, for all of her help in bringing the book to publication. It was a pleasure to work with these professionals. A number of anonymous reviewers made excellent suggestions which greatly helped in our revision for final publication. We typeset the book using LaTeX2e, and we would like to express our appreciation to its producers for making this software freely available.
Special thanks go to our spouses and children for enduring with us the arduous trek that preparing this book turned out to be. Finally, we would like to acknowledge the National Science Foundation for providing support through the NSF-ILI grant USE-0950497 to build a laboratory so that we had the opportunity to develop the original curriculum upon which this book is based.