To Everyone Welcome to this book We hope you’ll enjoy reading it as much as we enjoyed writing it. The book is called Operating Systems: Three Easy Pieces, and the title is obviously an homage to one of the greatest sets of lecture notes ever created, by one Richard Feynman on the topic of Physics F96. While this book will undoubtedly fall short of the high standard set by that famous physicist, perhaps it will be good enough for you in your quest to understand what operating systems (and more generally, systems) are all about. The three easy pieces refer to the three major thematic elements the book is organized around: virtualization, concurrency, andpersistence. In discussing these concepts, we’ll end up discussing most of the important things an operating system does; hopefully, you’ll also have some fun along the way. Learning new things is fun, right? At least, it should be. Each major concept is divided into a set of chapters, most of which present a particular problem and then show how to solve it. The chapters are short, and try (as best as possible) to reference the source material where the ideas really came from. One of our goals in writing this book is to make the paths of history as clear as possible, as we think that helps a student understand what is, what was, and what will be more clearly. In this case, seeing how the sausage was made is nearly as important as understanding what the sausage is good for1. There are a couple devices we use throughout the book which are probably worth introducing here. The ﬁrst is the crux of the problem. Anytime we are trying to solve a problem, we ﬁrst try to state what the most important issue is; such a crux of the problem is explicitly called out in the text, and hopefully solved via the techniques, algorithms, and ideas presented in the rest of the text. In many places, we’ll explain how a system works by showing its behavior over time. These timelines are at the essence of understanding; if you know what happens, for example, when a process page faults, you are on your way to truly understandinghowvirtualmemoryoperates. Ifyoucomprehendwhattakesplace when a journaling ﬁle system writes a block to disk, you have taken the ﬁrst steps towards mastery of storage systems. There are also numerous asides and tips throughout the text, adding a little color to the mainline presentation. Asides tend to discuss something relevant (but perhaps not essential) to the main text; tips tend to be general lessons that can be applied to systems you build. An index at the end of the book lists all of these tips and asides (as well as cruces, the odd plural of crux) for your convenience. We use one of the oldest didactic methods, the dialogue, throughout the book, as a way of presenting some of the material in a different light. These are used to introduce the major thematic concepts (in a peachy way, as we will see), as well as to review material every now and then. They are also a chance to write in a more humorous style. Whether you ﬁnd them useful, or humorous, well, that’s another matter entirely. Atthebeginningofeachmajorsection, we’llﬁrstpresentanabstractionthatan operating system provides, and then work in subsequent chapters on the mechanisms, policies, and other support needed to provide the abstraction. Abstractions are fundamental to all aspects of Computer Science, so it is perhaps no surprise that they are also essential in operating systems. Throughout the chapters, we try to use real code (not pseudocode) where possible, so for virtually all examples, you should be able to type them up yourself and run them. Running real code on real systems is the best way to learn about operating systems, so we encourage you to do so when you can. In various parts of the text, we have sprinkled in a few homeworks to ensure that you are understanding what is going on. Many of these homeworks are little simulations of pieces of the operating system; you should download the homeworks, and run them to quiz yourself. The homework simulators have the following feature: by giving them a different random seed, you can generate a virtually inﬁnite set of problems; the simulators can also be told to solve the problems for you. Thus, you can test and retest yourself until you have achieved a good level of understanding. The most important addendum to this book is a set of projects in which you learn about how real systems work by designing, implementing, and testing your own code. All projects (as well as the code examples, mentioned above) are in the C programming languageKR88; C is a simple and powerful language that underlies most operating systems, and thus worth adding to your toolchest of languages. Two types of projects are available (see the online appendix for ideas). The ﬁrst are systems programming projects; these projects are great for those who are new to C and UNIX and want to learn how to do lowlevel C programming. The second type are based on a real operating system kernel developed at MIT called xv6 CK+08; these projects are great for students that already have some C andwanttogettheirhandsdirtyinsidetheOS.AtWisconsin,we’verunthecourse in three different ways: either all systems programming, all xv6 programming, or a mix of both.