Books for learning kernel development

Although very, very dated, I have (without much search) not found anything that teaches one as much about the overall internal architecture of Unix better than the original Lions set (based on V6 Unix). It is a line-by-line description of just what is going on inside Unix. FreeBSD has of course expanded and mutated a lot in the intervening 40 years, but the overall architecture at least for the basics is still largely the same -- kind of like biology and evolution. And it is certainly more relevant for FreeBSD than Linux books.

http://www.lemis.com/grog/Documentation/Lions/book.pdf
http://v6.cuzuco.com/v6.pdf
 
GroupInode said:
Can anyone please suggest me any books for learning kernel development especially for FreeBSD kernel development.
Besides the FreeBSD developers guide, there are preciously few books about FreeBSD kernel hacking specifically.

First, you'll need to know about C. K&R2 (Kernighan & Ritchie, "The ANSI C Programming Language, 2nd ed.", a.k.a. the White Book) is by many considered to be sort of a bible (no capital), although personally I think it's more of a reference work than a learning book. Peter van der Linden (formerly of Sun Microsystems) wrote the ultimate second book on C: it's called "Expert C Programming - Deep C Secrets" and I recommend it to anyone serious about C programming. The book is informative, balances bare knowledge with humour/anecdotes/folklore ("light relief", as the author calls it) and discusses some topics that are rarely touched by others. For example, there's an entire chapter on how arrays and pointers are NOT the same thing in C. It also explains why not every C program is valid C++ (many people mistakenly think it is, but you are encouraged to find out for yourself that it really isn't) as well as many other common misconceptions, bad practices, useful heuristics, clever tricks etc. The book assumes you already have some knowledge of C (which is why I said second book) but if you're serious about the (not always obvious) nooks and crannies of C, this is a truly brilliant (and more than once entertaining) read and I wholehartedly recommend it to everyone who's serious about becoming a better C programmer. Moreover, if you can do the exercises in that book, you really are a competent C programmer who knows his sh*t.

Second, if you wish to do kernel programming (be it Linux or FreeBSD or MacOS or even Windows) you need some knowledge of operating systems and the underlying principles and algorithms in general. Several good books have been written on this subject. I recommend "Operating System Concepts" by Silbershatz et al (a.k.a. the Dinosaur book) but other people such as Andrew Tanenbaum and William Stallings have also written good books on the subject. These books don't go into much detail about any specific operating system, but they do explain an awful lot about operating systems in general and about the principles and algorithms behind them. It's background knowledge that I can only say is very useful, if not essential. Think of memory management, device management, disk allocation, resource allocation, CPU scheduling etc. If you intend to hack the kernel, you most likely need to know this stuff.

Lastly, about (Free)BSD itself. Some may have already mentioned "The Design and Implementation of the 4.4-BSD Operating System" (title might be slightly off, but you get the idea). It's an old book and not specific to FreeBSD but it may get you started. It's not a cheap book either, though. Another good choice is "Designing BSD Rootkits" by Joseph Kong. It doesn't attempt to explain everything there is to understand about BSD-like kernels, but it does provide quite a bit of insight into how BSD-like kernels work and how to hack these kernels. And it's a relatively cheap book.

To repeat what I started this post with, there are preciously few books specifically about FreeBSD. But hopefully the above can help you get started. Happy hacking!

Fonz
 
Back
Top