Linux Kernel Programming (LKP)
LKP New sub-course New sub-course We will learn together We will learn together Evaluation of this part of course will be based on VIVA VOCE at the end of the course So do make notes about what you learn
Groups Form 4 Groups Each student to copy files from Some may use Fedora 7 on VMware Some may run native Fedora 7 (not as VM) VIVA VOCE will be group-wise but questions will be directed at each student So don’t relax because you are in a group
LKP Why?? Customizing kernel for embedded devices –LK customization for Embedded … paper Customizing kernel for optimized performance –LK specialization for App Performance paper –PS3 Kernel patch to use Huge TLB pages Writing Device Drivers for new devices O/S Development itself ??
Boot Process BIOS selects boot device BIOS loads first sector (master boot record) from boot device MBR typically has a boot loader (GRUB or LILO). Grub gives user option to choose the kernels configured to boot /boot/grub/grub.conf
Boot Process … ‘man bootparam’ gives info on kernel boot parameters. Selected kernel is picked up from file system on disk and loaded into memory Usually /boot/vmlinuz- file –Compressed –Uncompressed file is vmlinux –Statically linked executable file containing the linux kernel ‘uname –r’ gives version of running kernel
Boot Process … Then GRUB places Initial RAM disk image into memory –Initrd-.img –Used by kernel to load drivers necessary to boot system –Particularly important if SCSI hard drives are present
System.map System.map- file Is a symbol table used by kernel Has symbol names and their addresses for kernel New System.map created for each kernel rebuild
Kernel Modules Kernel Modules Code which can be dynamically (as against statically) linked to the kernel Can be loaded even after bootup Can be unloaded from kernel when not required Typically device drivers and pseudo- device drivers like network drivers or file system are modules
Kernel modules … When kernel module is loaded: –Becomes a part of the linux kernel –Has same rights as kernel code (runs at kernel level) –Easy to crash kernel with bad device driver
Kernel modules … /lib/modules/ directory has modules of the kernel lsmod lists loaded modules modinfo gives details about a module lsmod followed by modinfo can be a very useful combo insmod, modprobe are other useful module commands
Misc commands ‘du.’ will give the disk usage of current directory in KB ‘free’ shows free physical memory ‘top’ gives this info and more – like task manager in Windows. ‘arch’ gives processor architecture ‘cat /proc/cpuinfo’ gives more details ‘dmesg | more’ shows boot messages.