Sei sulla pagina 1di 10

BRIEF DOCUMENTATION ABOUT 1. 2. 3. 4. 5. 6. What is kernel. What are the components of kernel. Integration design technique.

User mode vs Kernel mode. Different kernel context. Building Linux kernel. 6.1 Kernel configuration 6.2 Kernel compilation 6.3 Kernel Installation 6.4 Packaging.

What Is Kernel
Kernel is the core of OS. OS receives the request from users and processes it on user behalf. Request are received by command shell or some other kind of UI and are processed by the kernel. So kernel acts as the engine of OS which enables a user to use a computer system. Shell is the outer part of OS that provides the interface to user to interact with kernel.

Linux Kernel Component 1. Low level drivers:- They are architecture specific drivers and responsible for CPU, MMU and OnBoard device initialization. 2. Process Scheduler:- It is responsible for allocation of fair time slices to different processes. 3. Memory management:- It is responsible for managing memory(allocating and sharing memory) for different process. 4. File System: - Linux provides a single interface virtual file system so that users dont have to think about the complexity of underlying file system type. Using a single vfs a user can use the services of different underlying file systems. The complexities of different file systems are abstracted from the users. 5. Network interface:- This interface of kernel provides access and control of different network specific devices. 6. Device drivers:- These are high level drivers. 7. IPC: - Inter process communication, It allows different process to share their data among themselves.

Linux Kernel Integration design Linux kernel is made up of number of components so to integrate all the components and create kernel binary image is a key. There are mainly two integration design used for OS kernel 1. Monolithic: - Here all the kernel components are integrated together to build a static binary image. At boot up time all the kernel components are loaded and then run as a single process inside single memory address space. All the kernel components exist in that single memory space and all services are running and available all the time. Since all the components and services are inside the same address space , so no IPC required for communicating between kernel services. These are the reason of why monolithic kernel is good in performance and used in most number of UNIX os kernel. Problem with this type of kernel is as all the components are loaded at a time and all the services are running continuously so resource consumption is higher. As its image is static, we cannot add or remove services according to our needs. 2. Microkernel: - Here kernel image is broken into number of pieces of small services. At boot up time core kernel services are loaded, they run in privileged mode. Whenever any services are required it has to get loaded for running. Unlike monolithic kernel , different spaces are allocated to different services, so it required IPC call to communicate with kernel services. It also requires fewer resources to run. Linux kernel takes the benefit of both the process. It loads the complete kernel image at single address space and it also has capability to add/remove kernel services at run time in the form of modules.

USER MODE vs Kernel Mode In a system, Linux kernel runs in special privileged mode as compared to user applications. Kernel runs in protected memory space and it has access of all the hardware. The memory space and privileged access is collectively known as kernel space or kernel mode. User application has user space and has limited access of hardware User application cant access kernel space memory directly but kernel has access of the entire memory. DIFFERENT KERNEL CONTEXT:Entire kernel code can be divided into three categories:1. Process context:- User application cannt access the kernel space directly but there is an interface through which it can call the function defined in kernel space .. that interface is system call. A user application can call read/write system call which in turn invokes sys_read/sys_write codes in kernel space. In this case kernel space is used in behalf of user space application. So the kernel code that executes on the behalf of user space applications is process context code. All system calls like read, write etc fall in this categories.

2. Interrupt context:- Whenever a device wants to communicate with kernel , it sends an interrupt signal to kernel. The moment kernel receives the interrupt signal from hardware it starts executing some routine in the response of that. The response routine is called ISR or interrupt handler. ISR executes in interrupt context. 3. Kernel context:- There is some code in kernel space which is neither invoked by user space application nor by any hardware interrupt. This code is integral to kernel and always keeps on running. Memory management, Process management, I/O scheduler all are coming in this category. This code is said to execute in kernel space.

LINUX kernel version numbering :- To know about the kernel version use r with command uname # uname r 2.6.18-1.798.fc6 LINUX KERNEL SOURCES:For building a linux kernel we need a stable and recent version of kernel sources (let 2.6.33.). Kernel sources are zipped into tarball, something like linux-2.6.33.tar.gz. Put this tarball into the directory /usr/src. And use #tar xvzf linux-2.6.33.tar.gz to untar the kernel source and save it into new directory linux-2.6.33. Exploring kernel sources:-

Arch/:- Linux kernel can be installed on handheld device to huge server. Apart from other architectures it also support arm processor architecture. For ARM processor , code will be under arch/arm/arm64 directory. Kernel/ :- This directory Is an important subdirectory . It contains generic code for kernel subsystem,i.e. code for system calls, timers, schedulers, DMA, Interrupt handling and signal handling etc. The architecture specific code is kept under /arch/*/kernel directory.

NOTE:- Source browsing for linux kernel can be achieved by cscope(Linux kernel has built in support for that)

BUILDING LINUX KERNEL:Steps involved in building linux kernel are:Configuring, compiling, installing and packaging linux kernel. All the command must be issued at the root of kernel source. Assume the kernel source are kept in /usr/src/linux-2.6.33.1 directory. So first go to this directory... cd /usr/src/linux-2.6.33.1. At the route of kernel source there is a Makefile which contains at the top of it variable with name, version, Patchlevel, Sublevel, extraversion etc. E.g. change the value of extraversion by .1MyLinux> Effect of this will be on the image we are building with this source will 2.6.33.1MyLinux. When we boot the system after building and installing this new image, this version string will appear as a boot option. When we select this, new kernel image will run.

LINUX Kernel configuration Text based configuration:1. Interactive configuration:- make config is an interactive text based kernel config utility.

We can use #make config command This command starts an interactive kernel config script which always prompt for user input at each step in the form of yes/no etc. For more refer to http://leaarninglinuxkernel.in/linux-kernel-compilation/linux-kernel-configuration 2. Default configuration:#make defconfig

# # configuration written to .config file The utility generates default configuration for linux kernel. This is based on the configuration option preferred and used by linux kernel maintainer on their own machines. Once we create the default configuration we can add or modify it according to our need.

CONSOLE BASED CONFIGURATION:# make menuconfig This commands open a menu based console in which all kernel configuration are arranged nicely into different categories. Categories also have subcategories. Users just have to browse and select until get his desired kernel configuration.

GUI BASESD CONFIGURATION

http://leaarninglinuxkernel.in/linux-kernel-compilation/linux-kernel-configuration

Kernel Compilation Once decided which feature we have to add or remove in linux kernel configuration we have to compile it from source. Again we should have at the root of kernel sources. Now just use command #make Linux kernel source tree has a makefile , called root makefile , which is used by #make command to build the kernel. Root makefile has also submakefiles which is used to compile a particular subdirectories or separate file etc. The root makefile uses these sub makefiles. All the submakefiles are compiled to .o file and then linker link them and form vmlinux file which can be found after completion of make command. This vmlinux file is compiled image of all the services that we have chosen at configuration time but this vmlinux is not be loaded directly into memory. First the virtual address specified in vmlinux file is translated into hardware specific physical address and then startup code called bootstrap is added to

this image. After completing these things compressed, loadable, bootable kernel image bzimage is generated under /arch directory. Kernel builds is completed here. Suppose we have to add some services then we donot have to build whole kernel sources. We need to build only that file and then link that file to the image. #make file name If we have to build and link directory then use #make dir // It will build the directory #make // It will links it to the kernel image.

#make clean // cleans up all the .o file created by previous build operation. #make mrproper // cleans all the .config file build by previous build operation.

LINUX KERNEL INSTALLATION Linux kernel installation of kernel image is a two-step process. First steps deals with the installation of kernel module and vmlinuz static image which is achieved just by copy these files into specific memory location. Second steps deals with modification of bootloader configuration files.

Installing images and modules:#make module_install // command for installing the modules #make install // command for installing the image Modifying bootloader configuration:The bootloader program searches for the kernel program in /boot directory thats why bzimage is copied to this directory. After getting that program , bootloader load that image to memory and starts the boot process. Bootloader search kernel program by name which it get from its config file so we need to config its file too. Mainly the bootloader used is GRUB. For configuring GRUB just open its config file # vi /boot/grub/grub.conf In configuration file there is a section starting with title is corresponds to kernel image title. Just we need to copy this section at the end and edit it to include our new kernel image. After that save and

quit the file. The configuration of bootloader is completed. Now reboot the system , we will get our new kerenel in option for selection. Step by step process that we have done till now for building a kernel is:-

LINUX KERNEL PACKAGE If we want to install it on other target device then we have make the package and then install it on target device. For create package , at build time use #make rpm-pkg command instead of #make. This will create a bzlimage and modules and then pack them into single rpm file which is installable at any other devices.

Potrebbero piacerti anche