Sunday, July 13, 2008

Wannabe a kernel hacker?

This post is for an absolute beginner... :)

Linux kernel can be very intimidating and I am still struggling to catchup with the code. I was fascinated by list.h that gives an implementation of a generic linked list merely using macros! :) I was helped through the process management by a colleague - a good place to start. I loved the bit on scheduling and the neat tricks used there. A lot of people wud advise u to join the lkml mailing list but it would be good to know something so that u can understand the exchanges there. kernelnewbies is a better place to be.

I can recommend a lot of stuff but will do it in an order that will help. For those who love crash courses here is a nice one - http://www.freesoftwaremagazine.com/articles/drivers_linux. Can download the PDF and try the module quickly. The 2nd example requires a hardware. If u can get that it wud be help greatly in understanding.

You should get yourself a copy of Linux Kernel Development by Robert Love. It is a very good place to start and will briefly discuss code snippets to get you started and clears the concepts very well.

You can start working on Linux Device Drivers (LDD) by Alessandro Rubini (available online and helps since u can use while coding) soon after or in parallel. The coding examples in this book are a must!!! I am not sure I can this book enuf!!! :) I got a hard copy of the same despite the free soft copy. I lost it and I m getting another copy. Trust me it is worth it - don't take a print - get the book!!!

Recently I tried Understanding the Linux Kernel by Bovet - the latest edition and it is pretty detailed if you are interested to that level.

The most important link I found was -

http://free-electrons.com/training/drivers (Best link to get started off! A good site for other stuff as well)

This single presentation has very good pointers and is pretty up to date unlike other links.

A good link to begin from:

http://www.ibm.com/developerworks/linux/library/l-linux-kernel

Mind the resource section of any IBM link - they are pretty neat!!! :)

Also recently I bumped into the following link:

http://www.ibm.com/developerworks/linux/library/l-linuxboot/

This has the boot process discussed very well.

Also a friend who has written a 32 bit OS had posted the following :

http://www.freeos.com/articles/4536

This is dated but he gives tips on how to get started! I would have advised to go thru the following link and start from main.c

http://www.ibm.com/developerworks/linux/library/l-initrd.html (briefly mentions the first few api invoked)

but then it is very difficult. Like Karthick mentions it will be good start with isolated bits like ipc and then move to process management, etc.

I have my bookmarks available on Linux Kernel Internels at -

http://del.icio.us/mynk/lki

Finally I wud like to share the most interesting link on this subject - not useful technically but just to know that a Doctor turned into a hacker merely looking at Kernel code (he did not know C!!!) and also delivered patches!!!

http://kerneltrap.org/node/465
http://apcmag.com/why_i_quit_kernel_developer_con_kolivas.htm

I have found it hard to remember the changes between 2.4 and 2.6 so recommend u to stick to 2.6 as far as possible. The following link is good on the changes b/n the two:

http://kniggit.net/wwol26.html

I shall try and keep updating this post. If you do have some good pointers as well please share in the comments. Spammers please excuse! :)