FreeBSD Device Drivers by Joseph Kong (No Starch Press)
The Introduction says the goal of the book is “to help you improve your understanding of device drivers under FreeBSD”. OK, that is exactly what I wanted to do as I am currently working on several projects that use FreeBSD at deeper levels of understanding.
This book is a no nonsense, straight to the point document that helps you get to the content quickly. This is not a work for the casual reader.
At times readers may wish there was more explanation of topics as the writer is very much to the point. But the scarcity of text is compensated with by excellent examples which talk for themselves. Here is the outline of the book which demonstrates the direction and focus of the writer.
Chapter 1: Building and Running Modules
Chapter 2: Allocating Memory
Chapter 3: Device Communication and Control
Chapter 4: Thread Synchronization
Chapter 5: Delaying Execution
Chapter 6: Case Study: Virtual Null Modem
Chapter 7: Newbus and Resource Allocation
Chapter 8: Interrupt Handling
Chapter 9: Case Study: Parallel Port Printer Driver
Chapter 10: Managing and Using Resources
Chapter 11: Case Study: Intelligent Platform Management Interface Driver
Chapter 12: Direct Memory Access
Chapter 13: Storage Drivers
Chapter 14: Common Access Method
Chapter 15: USB Drivers
Chapter 16: Network Drivers, Part 1: Data Structures
Chapter 17: Network Drivers, Part 2: Packet Reception and Transmission
Key points in each of the examples are highlighted and explained to help the reader understand the importance of the overall example and the specific issue illustrated. The reader will do well to focus on these numbered highlights which are the crux of understanding the importance in the example.
Having taught C programming, many years ago, I found that experience with C was certainly an aide in understanding what the author was trying to do. When the author starts the book in chapter one he does an excellent job in describing how loadable kernel modules (KLD) work. The specifics in the explanation are clear and understandable throughout the whole process. The author uses the right amount of explanation combined with excellent examples. Those who choose this book will want to grasp these basic principles found in this first chapter before moving forward.
Each chapter will have different implications for the reader depending upon reader knowledge and reader projects. For example, one of the chapters which provided a lot of valuable information for a project I was working on was Thread Synchronization which describes issues related to using multiple threads and multiple CPUs. In this chapter illustrates several synchronization problems starting with simple examples to more complex examples. Then the author provides examples of how to prevent race conditions using spin mutexes or simple spin locks and sleep mutexes the most common solution. The “General Guidelines” at the end of the chapter help understand some of the problems related to recursive and exclusive locks.
Overall the author does a great job with examples and the limited explanations that go with it. However, the reader would be well served to have some experience before taking on this book.