You are on page 1of 17

LIST OF FIGURES

FIGURE NO TITLE PAGE NO

Figure 1. The fundamental architecture of the GNU/Linux operating system..1

Figure 2. One architectural perspective of the Linux kernel ..............................6

Figure 3. One architectural perspective of the Linux kernel ..............................8

Figure 4. Linux Kernel Structure (General Diagram) .......................................10


TABLE OF CONTENT

S. NO TITLE PAGE NO

LIST OF FIGURES

HISTORY OF LINUX

1. Introduction ............................................................................................................................... 1
2. What is Kernel?......................................................................................................................... 2
2.1. Definition .2
2.2. Categories of Kernel ...2
2.2.1. Monolithic ...2
2.2.2. Microkernel 2
2.2.3. Hybrid Kernel 3
2.2.4. Exo Kernel ..........3
3. Properties of the Linux kernel ................................................................................................. 4
4. Features of Linux Kernel ......................................................................................................... 5
5. Major subsystems of the Linux kernel .................................................................................... 6
5.1. System Call Interface ...6
5.2. Process Management ...7
5.3. Memory Management .7
5.4. Virtual File System ..8
5.5. Network Stack ..9
5.6. Device Drivers ..9
5.7. Architecture Dependent Code 9
6. Linux Kernel System Data Structures .................................................................................. 10
6.1. Task List ..10
6.2. Memory Map ..10
6.3. I-nodes .11
6.4. Data Connection .11
7. Conclusion ...12
References 13
OVERVIEW OF LINUX KERNEL STRUCTURE

HISTORY OF LINUX

While Linux is arguably the most popular open source operating system, its history is actually
quite short considering the timeline of operating systems. In the early days of computing,
programmers developed on the bare hardware in the hardware's language. The lack of an operating
system meant that only one application (and one user) could use the large and expensive device at
a time. Early operating systems were developed in the 1950s to provide a simpler development
experience. Examples include the General Motors Operating System (GMOS) developed for the
IBM 701 and the FORTRAN Monitor System (FMS) developed by North American Aviation for
the IBM 709. Twenty years later, Andrew Tanenbaum created a microkernel version of UNIX,
called MINIX (for minimal UNIX), that ran on small personal computers. This open source
operating system inspired Linus Torvalds' initial development of Linux in the early 1990s

Linux is one of the most widely used Open Source operating system in the world. It meets the
current demands like Multi-tasking, Multi-User Process, Architecture independence, Paging,
Different file systems etc., with the 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 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.Introduction

Figure 1. The fundamental architecture of the GNU/Linux operating system

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 compatible personal
computers based on the Intel 80386 microprocessor. Linus remains deeply involved with
improving Linux, keeping it up-to-date with various hardware developments and coordinating the
activity of hundreds of Linux developers around the world. Over the years, developers have
worked to make Linux available on other architectures, including Alpha, SPARC, Motorola
MC680x0, 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 file system
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 supported by Linux.

Since Linux is a kernel, many Linux users prefer to rely on commercial distributions, available on
CD-ROM, to get the code included in a standard Unix system. Alternatively, the code may be
obtained from several different FTP sites.

1
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 while still providing all the 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 systems, feature the ability to load modules at runtime, thereby
allowing easy extension of the kernel's capabilities as required, while helping to minimize 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,
inter process communication (IPC) and process management. All other functions, such as
hardware management, are implemented as processes running independently of the kernel.
Examples of microkernel operating systems are AIX, BeOS, Hurd, Mach, Mac OS X, MINIX and
QNX.
2
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 kernels, including Microsoft Windows NT, 2000 and XP. Dragonfly BSD, a
recent fork (i.e., variant) of Free BSD, is the first non-Mach based BSD operating system to employ
a hybrid kernel architecture.

2.2.4. Exo Kernel

Exo type kernel is not yet stabilized. It's under design and research. The user mode processes
running in this type of kernel has the ability to access kernel resources like process tables, etc.
directly.

3
3. Properties of the Linux kernel

When discussing architecture of a large and complex system, you can view the system from many
perspectives. One goal of an architectural decomposition is to provide a way to better understand
the source, and that's what we'll do here.

The Linux kernel implements a number of important architectural attributes. At a high level, and
at lower levels, the kernel is layered into a number of distinct subsystems. Linux can also be
considered monolithic because it lumps all of the basic services into the kernel. This differs from
a microkernel architecture where the kernel provides basic services such as communication, I/O,
and memory and process management, and more specific services are plugged in to the
microkernel layer. Each has its own advantages, but I'll steer clear of that debate.

Over time, the Linux kernel has become efficient in terms of both memory and CPU usage, as well
as extremely stable. But the most interesting aspect of Linux, given its size and complexity, is its
portability. Linux can be compiled to run on a huge number of processors and platforms with
different architectural constraints and needs. One example is the ability for Linux to run on a
process with a memory management unit (MMU), as well as those that provide no MMU. The
uClinux port of the Linux kernel provides for non-MMU support.

4
4. Features of Linux Kernel

By itself, the Linux kernel is not very innovative. When Linus Torvalds wrote the first kernel, he
referred to some classical books on UNIX 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.

The Linux kernel is monolithic. 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.
Linux Kernel Supports Modules, since it is able to automatically load and unload modules
on demand.
Linux uses kernel threads in a very limited way to execute a few kernel functions
periodically; since Linux kernel threads cannot execute user programs, they do not
represent the basic execution context abstraction.
Multithreaded application support.
Linux is a non-preemptive kernel. This means that Linux 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.
Linux kernel supports most of the available file systems. Eg: VFS, JFS etc.

5
5. Major subsystems of the Linux kernel

Now let's look at some of the major components of the Linux kernel using the breakdown shown
in Figure 2 as a guide.

Figure 2. One architectural perspective of the Linux kernel

5.1 System Call Interface

The SCI is a thin layer that provides the means to perform function calls from user space into the
kernel. As discussed previously, this interface can be architecture dependent, even within the same
processor family. The SCI is actually an interesting function-call multiplexing and demultiplexing
service.

6
5.2 Process Management

Process management is focused on the execution of processes. In the kernel, these are called
threads and represent an individual virtualization of the processor (thread code, data, stack, and
CPU registers). In user space, the term process is typically used, though the Linux implementation
does not separate the two concepts (processes and threads). The kernel provides an application
program interface (API) through the SCI to create a new process (fork, exec, or Portable Operating
System Interface [POSIX] functions), stop a process (kill, exit), and communicate and synchronize
between them (signal, or POSIX mechanisms).

Also in process management is the need to share the CPU between the active threads. The kernel
implements a novel scheduling algorithm that operates in constant time, regardless of the number
of threads vying for the CPU. This is called the O(1) scheduler, denoting that the same amount of
time is taken to schedule one thread as it is to schedule many. The O(1) scheduler also supports
multiple processors (called Symmetric Multi-Processing, or SMP).

5.3 Memory Management

Another important resource that's managed by the kernel is memory. For efficiency, given the way
that the hardware manages virtual memory, memory is managed in what are called pages (4KB in
size for most architectures). Linux includes the means to manage the available memory, as well as
the hardware mechanisms for physical and virtual mappings.

But memory management is much more than managing 4KB buffers. Linux provides abstractions
over 4KB buffers, such as the slab allocator. This memory management scheme uses 4KB buffers
as its base, but then allocates structures from within, keeping track of which pages are full, partially
used, and empty. This allows the scheme to dynamically grow and shrink based on the needs of
the greater system.

Supporting multiple users of memory, there are times when the available memory can be
exhausted. For this reason, pages can be moved out of memory and onto the disk. This process is
called swapping because the pages are swapped from memory onto the hard disk.

7
Figure 3. One architectural perspective of the Linux kernel

5.4 Virtual File System

The virtual file system (VFS) is an interesting aspect of the Linux kernel because it provides a
common interface abstraction for file systems. The VFS provides a switching layer between the
SCI and the file systems supported by the kernel (see Figure 4). Figure 4. The VFS provides a
switching fabric between users and file systems

At the top of the VFS is a common API abstraction of functions such as open, close, read, and
write. At the bottom of the VFS are the file system abstractions that define how the upper-layer
functions are implemented. These are plug-ins for the given file system (of which over 50 exist).

Below the file system layer is the buffer cache, which provides a common set of functions to the
file system layer (independent of any particular file system). This caching layer optimizes access
to the physical devices by keeping data around for a short time (or speculatively read ahead so

that the data is available when needed). Below the buffer cache are the device drivers, which
implement the interface for the particular physical device.

8
5.5 Network Stack

The network stack, by design, follows a layered architecture modeled after the protocols
themselves. Recall that the Internet Protocol (IP) is the core network layer protocol that sits below
the transport protocol (most commonly the Transmission Control Protocol, or TCP). Above TCP
is the sockets layer, which is invoked through the SCI.

The sockets layer is the standard API to the networking subsystem and provides a user interface
to a variety of networking protocols. From raw frame access to IP protocol data units (PDUs) and
up to TCP and the User Datagram Protocol (UDP), the sockets layer provides a standardized way
to manage connections and move data between endpoints.

5.6 Device Drivers

The vast majority of the source code in the Linux kernel exists in device drivers that make a
particular hardware device usable. The Linux source tree provides a drivers subdirectory that is
further divided by the various devices that are supported, such as Bluetooth, I2C, serial, and so on.

5.7 Architecture Dependent Code

While much of Linux is independent of the architecture on which it runs, there are elements that
must consider the architecture for normal operation and for efficiency. The ./linux/arch
subdirectory defines the architecture-dependent portion of the kernel source contained in a number
of subdirectories that are specific to the architecture (collectively forming the BSP). For a typical
desktop, the i386 directory is used. Each architecture subdirectory contains a number of other
subdirectories that focus on a particular aspect of the kernel, such as boot, kernel, memory
management, and others. The given below illustration shows that the above described kernel
structure.

9
6. Linux Kernel System Data Structures

Figure 4. Linux Kernel Structure (General Diagram)

6.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.

6.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.

10
6.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.

6.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 information, and also
pointers to the I-nodes representing all of the opened files. Finally, the task data structure also
contains pointers to data structures representing the entire opened network connections associated
with each task.

11
7. 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 is a nice web-based
source browser.

12
References
www.ibm.com
www.tutorialspoint.com
www.scribd.com
www.kernel.org

13

You might also like