My aim is to learn how Linux works. I know there are smaller kernels out there- I have the Minix book but the problem is that whilst teaching the concepts is ok- I really want to learn the specifics of the linux kernel.
I have a copy of linux kernel source code. Is there any technique so that I could "launch" this source code and somehow step-through the code so I can see what is happening?
If not, what is the next best technique to learn exactly what is happening (including recommended books, blogs, tech docs etc)?
EDIT
Does the source code have good documentation for particular OS areas?
You can build the kernel in the "User Mode Linux" architecture, and run it as a normal process within another (Linux) OS. (Hint: RTFM, "make ARCH=um" )
Then you can run it under the debugger, set breakpoints anywhere or anything, it is just as a normal userspace task.
http://www.amazon.com/Professional-Linux-Kernel-Architecture-Programmer/dp/0470343435/ref=sr_1_1?ie=UTF8&qid=1358373427&sr=8-1&keywords=professional+linux+kernel+architecture
I recommend this book over any other. This will explain pretty much how everything works and is still quite accurate.
The concepts are really what's important and this book will point you to the key functions inside the kernel so that you can get the details yourself. Simple things to read are some system calls, or just open up some core files and read through the functions and try and figure out what they do or just manually trace stuff.
If you want to single step a kernel you can use a virtualization software like QEMU and load up the kernel inside under debugging mode (QEMU has remote GDB support) and you can load the symbol table for the kernel kernel.syms
(IIRC) into GDB and you can see exactly what is executing. This can be very slow though for the kernel running inside and is really only useful for debugging a development kernel but if you're willing to accept the slowdown then go for it.
As mentioned the best is to read the source, at least that's how I learned. Find the key functions for whatever functionality you want to see and it's not hard to step through the code and just see what happens (use something like TAGS or CSCOPE to make this easier).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With