# Books for learning kernel development



## GroupInode (Jan 27, 2012)

Can anyone please suggest me any books for learning kernel development especially for FreeBSD kernel development.

Thank you


----------



## wblock@ (Jan 27, 2012)

Developers' Handbook, Architecture Handbook, other articles and PDFs at the documentation page will get you started: http://www.freebsd.org/docs/books.html


----------



## SirDice (Jan 27, 2012)

I think "The Design and Implementation of the 4.4BSD Operating System" would be a good place to start.

You can read chapter two here: http://www.freebsd.org/doc/en/books/design-44bsd/


----------



## doena (Jan 27, 2012)

@SirDice:
Didn't you mean the newer version "The Design and Implementation of the FreeBSD
Operating System"?


----------



## SirDice (Jan 27, 2012)

Newer version would probably be better, yes.


----------



## DutchDaemon (Jan 27, 2012)

We have a sticky topic: http://forums.freebsd.org/showthread.php?t=1566


----------



## monkeyboy (Jan 27, 2012)

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


----------



## fonz (Jan 28, 2012)

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 _Free_BSD 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


----------

