I will provide a hands on guide on dissecting and learning the Linux kernel . But I am busy with work and so forth and It may not be able to post in regular way. I however will not spoon feed and I will just be providing general guidelines. Also I will covering the linux kernel specific to the ia-32 platform .
Getting Started — Compiling the Linux Kernel
Download the newest linux kernel from http://www.kernel.org.make sure that you have newer version of gcc. To find out the current gcc version ,type
To extract do ,
tar -xvf linux-2.6xx.tar
and make your choices and save and exit.
If do not have ncurses library installed
if present type
For a qt based utility type
for gtk based type
if(kernel series is 2.4 )
Now finally build the kernel
make modules (for building modules)
Thus your kernel is made.Installation of newer kernel is bootloader specific grub has a different way,lilo has a different way.But the basic idea is same.For older kernel’s 2.2 vesrions etc we can put this kernel image directly into floppy for testing
Files and Directories to peek at
After extracting and compiling the kernel code, it’s time to peek at the different directories.
Lets discuss them
1)arch -Architecture dependent code
2)cryto -crypto API
4)fs -The Virtual File System Implementation
5)init -the boot process and initialization
6)ipc-Inter process Communication
8)kernel -core systems
Brief on gcc inline assembly
The basic gcc inline assembly format is as follows
<IA 32 instructions >:
<output > :
you can search the net in detail on how to use inline assembly with gcc.
Frequently used data structures in kernel
- Linked Lists :- See /include/linux/list.h.The C language does not enforce type safety, Linux kernel provides set of macros for CRUD operations on a linked list
- Trees :- Linux kernel uses balanced trees ( RED BLACK TREE) in memory management . We will see this later
In Part2 we will focus more on the x86 architecture