OVERVIEW OF LINUX KERNEL STRUCTURE
Naveenraja S II MCA “A” 08MCR057
CONTENTS
Abstract 1. Introduction 2. What is Kernel? 2.1. Definition 2.2. Categories of Kernel 2.2.1. Monolithic 2.2.2. Microkernel 2.2.3. Hybrid Kernel 2.2.4. Exo Kernel 3. Features of Linux Kernel 4. Linux Kernel Structure 5. Linux Kernel System Data Structures 5.1 Task List 5.2 Memory Map 5.3 I-nodes 5.4 Data Connection 6. Conclusion
OVERVIEW OF LINUX KERNEL STRUCTURE Abstract
Linux is one of the most widely used Open Source operating system in the world world.. It meets meets the curr curren entt dema demand ndss like like Multi Multi taski tasking ng,, Multi Multi-U -Use serr Proc Proces ess, s, Archite Architectu cture re indepe independe ndence nce,, Paging Paging,, Differe Different nt file system systemss etc., etc., with with the best best architecture of the kernel, Linux has been successfully adopted by many users. This paper describes the general outline of the Linux kernel Architecture. Linux kernel is monolithic and it consists of more than 5 million lines of codes. Linux kernel is designed in a manner manner that every function of the kernel has been repeatedly altered and expanded. Linux kernel source consists of more than ten directories and it can be loaded in any architecture computers. These directories are factors of success behind the overall system. 1. Intr ntrodu duct ctio ion n
Linux is a member of the large family of Unix-like operating systems. Linux was initially developed by Linus Torvalds in 1991 as an operating system for IBM compat compatibl iblee person personal al comput computers ers based based on the Intel Intel 80386 80386 microp microproce rocesso ssorr. Linus Linus remains deeply involved with improving Linux, keeping it up-to-date with various hardware developments and coordinating the activit y of hundreds of Linux developers around the world. Over the years, developers have worked to make Linux available on other architectures architectures,, including including Alpha, SPARC, SPARC, Motorola Motorola MC680x0, MC680x0, PowerPC, PowerPC, and IBM System/390. One of the more appealing benefits to Linux is that it isn't a commercial operating system: its source code under the GNU Public License is open and available to anyone to study. Technically speaking, Linux is a true UNIX kernel, although it is not a full UNIX operating system, because it does not include all the applications such as filesystem utilities, windowing systems and graphical desktops, system administrator commands, text editors, compilers, and so on. However, since most of these programs are freely available under the GNU General Public License, they can be installed into one of the filesystems files ystems supported by Linux.
Since Linux is a kernel, many Linux users prefer to rely on commercial distributions, avail availab able le on CD-R CD-ROM OM,, to get get the the code code inclu include ded d in a stan standa dard rd Unix Unix syst system em.. Alternatively, Alternatively, the code may ma y be obtained from several different FTP sites. 2. What is Kernel? 2.1. Definition
The kernel is
a
program
that
constitutes
the
central
core
of
a
computer operating system. It has complete control over everything that occurs in the system. The kernel is the first part of the operating system to load into memory during booting (i.e., system startup), and it remains there for the entire duration of the computer session because its services are required continuously. Thus it is important for it to be as small as possible possible while still providing all the essential essential services needed by the other parts of the operating system and by the various application programs. However, larger kernels can provide more functionality. 2.2. Categories of Kernel
Kernels can be classified into four broad categories:: 2.2.1. Monolithic
Monolithic kernels, which have traditionally been used by Unix-like operating systems, contain all the operating system core functions and the device drivers (small programs that allow the operating system to interact with hardware devices, such as disk drives, video cards and printers). Modern monolithic kernels, such as those of Linux and FreeBSD, both of which fall into the category of Unix-like operating system systems, s, feature feature the ability ability to load load modules modules at runtim runtime, e, thereb thereby y allowi allowing ng easy extens extension ion of the kernel kernel's 's capabi capabiliti lities es as requir required, ed, while while helpin helping g to minimi minimize ze the amount of code running in kernel space. 2.2.2. Microkernel
A microkernel usually provides only minimal services, such as defining memory address spaces, interprocess communication (IPC) and process management. All other functio functions, ns, such such as hardwa hardware re managem management ent,, are impleme implemente nted d as proces processes ses runnin running g independently of the kernel. Examples of microkernel operating systems are AIX, BeOS, Hurd, Mach, Mac OS X, MINIX and QNX. 2.2.3. Hybrid Kernel
Hybrid kernels are similar to microkernels, except that they include additional code in kernel space so that such code can run more swiftly than it would were it in user space. Most modern operating systems use hybrid hybrid kernels, kernels, including including Microsoft
Windows NT, 2000 and XP. Dragonfly BSD, a recentfork (i.e., variant) of FreeBSD, is the the firs firstt nonnon-Ma Mach ch base based d BSD BSD opera operatin ting g syst system em to emplo employ y a hybr hybrid id kern kernel el architecture. 2.2.4. Exo Kernel
Exo type kernel is not yet stabilized. stabilized. It's under design and research. research. The user mode mode proc proces esse sess runn runnin ing g in this this type type of kern kernel el has has the the abili ability ty to acces accesss kern kernel el resources like process tables, etc et c directly. 3. Features of Linux Kernel
By itself, the Linux kernel is not very innovative. When Linus Torvalds wrote the first kernel, kernel, he referred to some classical classical books on UNIX internals, internals, like Maurice Bach's The Design of the Unix Operating System (Prentice Hall, 1986). Actually, Linux still has some bias toward the UNIX baseline described in Bach's book (i.e., SVR4). However, Linux doesn't stick to any particular variant. Instead, it tries to adopt good features and design choices of several different UNIX kernels. Linux kernel consists of following features. 1. The Linux Linux kernel kernel is monolit monolithic hic. It is a large, complex do-it-yourself program, composed of several logically different components. In this, it is quite conventional; most commercial UNIX variants are monolithic. 2. Linux Linux Kernel Kernel Support Supportss Modules Modules,, since it is able to automatic automatically ally load and unload modules on demand. 3. Linux Linux uses uses kernel kernel thread threadss in a very limite limited d way to execut executee a few kernel functions periodically; since Linux kernel threads cannot execute user programs, they do not represent the basic execution context abstraction. 4. Multith Multithread readed ed appli applicat cation ion supp support ort.. 5. Linux Linux is a non-pr non-preemp eemptiv tivee kernel. kernel. This This means that that Linux cannot cannot arbitrarily interleave execution flows while they are in privileged mode. Several sections of kernel code assume they can run and modify data structures without fear of being interrupted and having another thread alter those data structures. 6. Linux Linux kernel kernel support supportss most of the availab available le file systems systems.Eg .Eg:: VFS, JFS etc.
4. Linux Kernel Structure
1. Proc Proces esss manag managem emen entt The scheduler handles all the active, waiting, and blocked processes. 2. Memo Memory ry mana manage geme ment nt It is resp respon onsi sibl blee for for allo allocat catin ing g memo memory ry to each each proc proces esss and and for for protecting allocated memory against access by other processes. 3. File system In UNIX, almost everything is handled over the file system interface. Device drivers can be addressed as files. /proc file system allows us to access data and parameters in the kernel 4. Devic evicee dri driv vers ers Abstract from the underlying hardware and allow us to access the hardware with well-defined APIs 5. Networks Incoming packets are asynchronous events and have o be collected and identified, before a process can handle them. Most network operations cannot be allocated to a specific process. The given below illustration shows that the above described kernel structure.
Kernel Applications and tools
User Space
S stem Calls Process Management
Multitaskin
Memory Management
Virtual Memory
Files,Directories
Device Drivers Device Access
File System
Scheduler Architecture
Memory
Specific
Manager
Code
CPU
File Systems
Component
RAM
Network Network
Functionalit
Network
Software Support
Network
Hardware support
Character Block Devices
Hard disk, CD,floppy
Devices
Terminals
Network Adapter
Hardware
Figure 1: Linux Kernel Structure (General Diagram) 5. Linux Kernel System Data Structures 5.1 Task List
The process scheduler maintains a block of data for each process that is active. These blocks of data are stored in a linked list called the task list; the process scheduler always maintains a current pointer that indicates the current process that is active. 5.2 Memory Map
The memory manager stores a mapping of virtual to physical addresses on a per-process basis, and also stores additional information on how to fetch and replace particular pages. This information is stored in a memory-map data structure that is stored in the process scheduler's task list. 5.3 I-nodes
The Virtual File System uses index-nodes (i-nodes) to represent files on a logical file system. The I-node data structure stores the mapping of file block numbers to physical device addresses. I-node data structures can be shared across processes if two processes have the same file open. This sharing is accomplished by both task data blocks pointing to the same I-node. 5.4 Data Connection
All of the data structures are rooted at the task list of the process scheduler. Each process on the system has a data structure containing a pointer to its memory mapping mapping information, information, and also pointers to the I-nodes representing representing all of the opened opened files files.. Final Finally ly,, the the task task data data stru structu cture re also also cont contai ains ns poin pointer terss to data data stru structu ctures res representing the entire opened network connections associated with each task. 6. Conclusion
Linux is a modular, UNIX-like monolithic kernel. Kernel is the heart of the OS that executes with special hardware permission (kernel mode). “Core kernel” provides framework, data structures, and support for drivers, modules, subsystems. Kernel designers must consider many competing goals. Linux source tree mirrors kernel structure. All the architecture dependent source sub trees live in /arch. The “main” source of kernel lives in /kernel/init.c. lxr.linux.no lxr.linux.no is a nice web-based source browser. browser.