SlideShare ist ein Scribd-Unternehmen logo
1 von 16
Downloaden Sie, um offline zu lesen
Operating System
Assignment
On
Submitted To :
Sir JUBAYER AL MAHMUD
Lecturer, Bangladesh University
Department of CSE
Submitted By :
MD. SADIQUR RAHMAN
ID : 201531043092
Batch No : 43
Department of CSE
BANGLADESH UNIVERSITY
15/1, Iqbal Road, Mohammadpur, Dhaka-1207
1
 What Is Kernel ?
The kernel is the central module of an operating system (OS).
It is the part of the operating system that loads first, and it
remains in main memory. Because it stays in memory, it is
important for the kernel to be as small as possible while still
providing all the essential services required by other parts of
the operating system and applications. The kernel code is
usually loaded into a protected area of memory to prevent it
from being overwritten by programs or other parts of the
operating system.
A kernel connects the application software to the hardware of a computer.
Typically, the kernel is responsible for memory management,
process and task management, and disk management. The
kernel connects the system hardware to the application
software. Every operating system has a kernel. For example
the Linux kernel is used numerous operating systems
including Linux, FreeBSD, Android and others.
2
 Types Of Kernel
Kernels may be classified mainly in two categories
1. Monolithic
2. Micro Kernel
1. Monolithic Kernel
Earlier in this type of kernel architecture, all the basic system
services like process and memory management, interrupt
handling etc were packaged into a single module in kernel
space. This type of architecture led to some serious
drawbacks like 1) Size of kernel, which was huge. 2) Poor
maintainability, which means bug fixing or addition of new
features resulted in recompilation of the whole kernel which
could consume hours.
In a modern day approach to monolithic architecture, the
kernel consists of different modules which can be
dynamically loaded and un-loaded. This modular approach
allows easy extension of OS's capabilities. With this
approach, maintainability of kernel became very easy as only
the concerned module needs to be loaded and unloaded
every time there is a change or bug fix in a particular
module. So, there is no need to bring down and recompile
the whole kernel for a smallest bit of change. Also, stripping
of kernel for various platforms (say for embedded devices
etc) became very easy as we can easily unload the module
that we do not want.
Linux follows the monolithic modular approach.
3
2. Micro Kernel
This architecture majorly caters to the problem of ever
growing size of kernel code which we could not control in
the monolithic approach. This architecture allows some basic
services like device driver management, protocol stack, file
system etc to run in user space. This reduces the kernel code
size and also increases the security and stability of OS as we
have the bare minimum code running in kernel. So, if
suppose a basic service like network service crashes due to
buffer overflow, then only the networking service's memory
would be corrupted, leaving the rest of the system still
functional.
In this architecture, all the basic OS services which are made
part of user space are made to run as servers which are used
by other programs in the system through inter process
communication (IPC). eg: we have servers for device drivers,
network protocol stacks, file systems, graphics, etc.
4
 Linux Kernel Architecture
The Linux kernel is a monolithic kernel, supporting
true preemptive multitasking (both in user mode and, since
the 2.6 series, in kernel mode), virtual memory, shared
libraries, demand loading, shared copy-on-write executables
(via KSM), memory management, the Internet protocol suite,
and threading.
Device drivers and kernel extensions run in kernel space (ring
0 in many CPU architectures), with full access to the
hardware, although some exceptions run in user space, for
example file systems based on FUSE/CUSE, and parts of
UIO. The graphics system most people use with Linux does
not run within the kernel. Unlike standard monolithic kernels,
device drivers are easily configured as modules, and loaded
or unloaded while the system is running. Also, unlike
standard monolithic kernels, device drivers can be pre-
empted under certain conditions; this feature was added to
handle hardware interrupts correctly, and to better
support symmetric multiprocessing. By choice, the Linux
kernel has no binary kernel interface.
The hardware is also incorporated into the file hierarchy.
Device drivers interface to user applications via an entry in
the /dev or /sys directories. Process information as well is
mapped to the file system through the /proc directory.
5
The following illustration shows the architecture of a
Linux system −
The architecture of a Linux System consists of the
following layers −
 Hardware layer − Hardware consists of all peripheral
devices (RAM/ HDD/ CPU etc).
 Kernel − It is the core component of Operating System,
interacts directly with hardware, provides low level
services to upper layer components.
 Shell − An interface to kernel, hiding complexity of
kernel's functions from users. The shell takes
commands from the user and executes kernel's
functions.
6
 Utilities − Utility programs that provide the user most
of the functionalities of an operating systems.
 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
7
as those that provide no MMU. The uClinux port of the
Linux kernel provides for non-MMU support.
 Major subsystems of the Linux kernel
Let's look at some of the major components of the Linux
kernel using the breakdown shown in the Figure as a
guide.
 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. You can find the SCI
implementation in ./linux/kernel, as well as architecture-
dependent portions in ./linux/arch.
8
 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 MultiProcessing,
or SMP). You can find the process management sources
in ./linux/kernel and architecture-dependent sources in
./linux/arch).
9
 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.
You can find the memory management sources in
./linux/mm.
10
 File Systems
The term filesystem has two somewhat different
meanings, both of which are commonly used. This can be
confusing to novices, but after a while the meaning is
usually clear from the context.
One meaning is the entire hierarchy of directories (also
referred to as the directory tree) that is used to organize
files on a computer system. On Linux and Unix, the
directories start with the root directory (designated by a
forward slash), which contains a series of subdirectories,
each of which, in turn, contains further subdirectories,
etc.
A variant of this definition is the part of the entire
hierarchy of directories or of the directory tree that is
located on a single partition or disk. (A partition is a
section of a hard disk that contains a single type of
filesystem.)
The second meaning is the type of filesystem, that is,
]how the storage of data (i.e., files, folders, etc.) is
organized on a computer disk (hard disk, floppy disk,
CDROM, etc.) or on a partition on a hard disk. Each type
of filesystem has its own set of rules for controlling the
allocation of disk space to files and for associating data
about each file (referred to as meta data) with that file,
11
such as its filename, the directory in which it is located,
its permissions and its creation date.
An example of a sentence using the word filesystem in
the first sense is: "Alice installed Linux with the filesystem
spread over two hard disks rather than on a single hard
disk." This refers to the fact that [ the entire hierarchy of
directories of ] Linux can be installed on a single disk or
spread over multiple disks, including disks on different
computers (or even disks on computers at different
locations).
An example of a sentence using the second meaning is:
"Bob installed Linux using only the ext3 filesystem
instead of using both the ext2 and ext3 filesystems." This
refers to the fact that a single Linux installation can
contain one or multiple types of filesystems. One hard
disk can contain one or multiple types of filesystems
(each z can be spread across multiple hard disks.
 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 the Figure).
12
Figure. 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). You can find the file system sources in
./linux/fs.
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.
13
 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. You can find the networking sources
in the kernel at ./linux/net.
 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. You can find the device driver sources in
./linux/drivers.
14
 Conclusion
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.
15
Source links:
https://www.webopedia.com/TERM/K/kernel.html
https://github.com/nu11secur1ty/Kernel-and-Types-of-
kernels/blob/master/Kernel%20and%20Types%20of%20kernels.md
https://en.wikipedia.org/wiki/Linux_kernel
https://www.ibm.com/developerworks/library/l-linux-kernel/index.html
http://docs.huihoo.com/linux/kernel/a1/index.html

Weitere ähnliche Inhalte

Was ist angesagt?

Linux internal
Linux internalLinux internal
Linux internal
mcganesh
 
Linux presentation
Linux presentationLinux presentation
Linux presentation
Nikhil Jain
 

Was ist angesagt? (20)

Linux OS presentation
Linux OS presentationLinux OS presentation
Linux OS presentation
 
Linux Administration
Linux AdministrationLinux Administration
Linux Administration
 
Linux internal
Linux internalLinux internal
Linux internal
 
Linux file system
Linux file systemLinux file system
Linux file system
 
Architecture Of The Linux Kernel
Architecture Of The Linux KernelArchitecture Of The Linux Kernel
Architecture Of The Linux Kernel
 
Linux file system
Linux file systemLinux file system
Linux file system
 
Linux Internals - Kernel/Core
Linux Internals - Kernel/CoreLinux Internals - Kernel/Core
Linux Internals - Kernel/Core
 
Linux basics
Linux basicsLinux basics
Linux basics
 
Introduction To Linux Kernel Modules
Introduction To Linux Kernel ModulesIntroduction To Linux Kernel Modules
Introduction To Linux Kernel Modules
 
linux device driver
linux device driverlinux device driver
linux device driver
 
Introduction to System Calls
Introduction to System CallsIntroduction to System Calls
Introduction to System Calls
 
KERNAL ARCHITECTURE
KERNAL ARCHITECTUREKERNAL ARCHITECTURE
KERNAL ARCHITECTURE
 
Basic Linux Internals
Basic Linux InternalsBasic Linux Internals
Basic Linux Internals
 
comparing windows and linux ppt
comparing windows and linux pptcomparing windows and linux ppt
comparing windows and linux ppt
 
Introduction to char device driver
Introduction to char device driverIntroduction to char device driver
Introduction to char device driver
 
Introduction 2 linux
Introduction 2 linuxIntroduction 2 linux
Introduction 2 linux
 
Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)
 
Embedded Linux Kernel - Build your custom kernel
Embedded Linux Kernel - Build your custom kernelEmbedded Linux Kernel - Build your custom kernel
Embedded Linux Kernel - Build your custom kernel
 
Linux presentation
Linux presentationLinux presentation
Linux presentation
 
Architecture Of The Linux Kernel
Architecture Of The Linux KernelArchitecture Of The Linux Kernel
Architecture Of The Linux Kernel
 

Ähnlich wie Linux kernel Architecture and Properties

Ap 06 4_10_simek
Ap 06 4_10_simekAp 06 4_10_simek
Ap 06 4_10_simek
Nguyen Vinh
 
Linux architecture
Linux architectureLinux architecture
Linux architecture
mcganesh
 

Ähnlich wie Linux kernel Architecture and Properties (20)

In a monolithic kerne1
In a monolithic kerne1In a monolithic kerne1
In a monolithic kerne1
 
In a monolithic kerne1
In a monolithic kerne1In a monolithic kerne1
In a monolithic kerne1
 
Kernel (computing)
Kernel (computing)Kernel (computing)
Kernel (computing)
 
Kernel (computing)
Kernel (computing)Kernel (computing)
Kernel (computing)
 
In a monolithic kernel
In a monolithic kernelIn a monolithic kernel
In a monolithic kernel
 
Walking around linux kernel
Walking around linux kernelWalking around linux kernel
Walking around linux kernel
 
MIcrokernel
MIcrokernelMIcrokernel
MIcrokernel
 
ITT Project Information Technology Basic
ITT Project Information Technology BasicITT Project Information Technology Basic
ITT Project Information Technology Basic
 
Kernel. Operating System
Kernel. Operating SystemKernel. Operating System
Kernel. Operating System
 
Os Ds Arch
Os Ds ArchOs Ds Arch
Os Ds Arch
 
Ap 06 4_10_simek
Ap 06 4_10_simekAp 06 4_10_simek
Ap 06 4_10_simek
 
Linux architecture
Linux architectureLinux architecture
Linux architecture
 
Operating system 15 micro kernel based os
Operating system 15 micro kernel based osOperating system 15 micro kernel based os
Operating system 15 micro kernel based os
 
KERNEL.pptx
KERNEL.pptxKERNEL.pptx
KERNEL.pptx
 
Studies
StudiesStudies
Studies
 
UNIX INTERNALS UNIT-I
UNIX INTERNALS UNIT-IUNIX INTERNALS UNIT-I
UNIX INTERNALS UNIT-I
 
Symmetric multiprocessing and Microkernel
Symmetric multiprocessing and MicrokernelSymmetric multiprocessing and Microkernel
Symmetric multiprocessing and Microkernel
 
Ubuntu
UbuntuUbuntu
Ubuntu
 
Hybrid kernel
Hybrid kernelHybrid kernel
Hybrid kernel
 
System structure
System structureSystem structure
System structure
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Kürzlich hochgeladen (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 

Linux kernel Architecture and Properties

  • 1. Operating System Assignment On Submitted To : Sir JUBAYER AL MAHMUD Lecturer, Bangladesh University Department of CSE Submitted By : MD. SADIQUR RAHMAN ID : 201531043092 Batch No : 43 Department of CSE BANGLADESH UNIVERSITY 15/1, Iqbal Road, Mohammadpur, Dhaka-1207
  • 2. 1  What Is Kernel ? The kernel is the central module of an operating system (OS). It is the part of the operating system that loads first, and it remains in main memory. Because it stays in memory, it is important for the kernel to be as small as possible while still providing all the essential services required by other parts of the operating system and applications. The kernel code is usually loaded into a protected area of memory to prevent it from being overwritten by programs or other parts of the operating system. A kernel connects the application software to the hardware of a computer. Typically, the kernel is responsible for memory management, process and task management, and disk management. The kernel connects the system hardware to the application software. Every operating system has a kernel. For example the Linux kernel is used numerous operating systems including Linux, FreeBSD, Android and others.
  • 3. 2  Types Of Kernel Kernels may be classified mainly in two categories 1. Monolithic 2. Micro Kernel 1. Monolithic Kernel Earlier in this type of kernel architecture, all the basic system services like process and memory management, interrupt handling etc were packaged into a single module in kernel space. This type of architecture led to some serious drawbacks like 1) Size of kernel, which was huge. 2) Poor maintainability, which means bug fixing or addition of new features resulted in recompilation of the whole kernel which could consume hours. In a modern day approach to monolithic architecture, the kernel consists of different modules which can be dynamically loaded and un-loaded. This modular approach allows easy extension of OS's capabilities. With this approach, maintainability of kernel became very easy as only the concerned module needs to be loaded and unloaded every time there is a change or bug fix in a particular module. So, there is no need to bring down and recompile the whole kernel for a smallest bit of change. Also, stripping of kernel for various platforms (say for embedded devices etc) became very easy as we can easily unload the module that we do not want. Linux follows the monolithic modular approach.
  • 4. 3 2. Micro Kernel This architecture majorly caters to the problem of ever growing size of kernel code which we could not control in the monolithic approach. This architecture allows some basic services like device driver management, protocol stack, file system etc to run in user space. This reduces the kernel code size and also increases the security and stability of OS as we have the bare minimum code running in kernel. So, if suppose a basic service like network service crashes due to buffer overflow, then only the networking service's memory would be corrupted, leaving the rest of the system still functional. In this architecture, all the basic OS services which are made part of user space are made to run as servers which are used by other programs in the system through inter process communication (IPC). eg: we have servers for device drivers, network protocol stacks, file systems, graphics, etc.
  • 5. 4  Linux Kernel Architecture The Linux kernel is a monolithic kernel, supporting true preemptive multitasking (both in user mode and, since the 2.6 series, in kernel mode), virtual memory, shared libraries, demand loading, shared copy-on-write executables (via KSM), memory management, the Internet protocol suite, and threading. Device drivers and kernel extensions run in kernel space (ring 0 in many CPU architectures), with full access to the hardware, although some exceptions run in user space, for example file systems based on FUSE/CUSE, and parts of UIO. The graphics system most people use with Linux does not run within the kernel. Unlike standard monolithic kernels, device drivers are easily configured as modules, and loaded or unloaded while the system is running. Also, unlike standard monolithic kernels, device drivers can be pre- empted under certain conditions; this feature was added to handle hardware interrupts correctly, and to better support symmetric multiprocessing. By choice, the Linux kernel has no binary kernel interface. The hardware is also incorporated into the file hierarchy. Device drivers interface to user applications via an entry in the /dev or /sys directories. Process information as well is mapped to the file system through the /proc directory.
  • 6. 5 The following illustration shows the architecture of a Linux system − The architecture of a Linux System consists of the following layers −  Hardware layer − Hardware consists of all peripheral devices (RAM/ HDD/ CPU etc).  Kernel − It is the core component of Operating System, interacts directly with hardware, provides low level services to upper layer components.  Shell − An interface to kernel, hiding complexity of kernel's functions from users. The shell takes commands from the user and executes kernel's functions.
  • 7. 6  Utilities − Utility programs that provide the user most of the functionalities of an operating systems.  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
  • 8. 7 as those that provide no MMU. The uClinux port of the Linux kernel provides for non-MMU support.  Major subsystems of the Linux kernel Let's look at some of the major components of the Linux kernel using the breakdown shown in the Figure as a guide.  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. You can find the SCI implementation in ./linux/kernel, as well as architecture- dependent portions in ./linux/arch.
  • 9. 8  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 MultiProcessing, or SMP). You can find the process management sources in ./linux/kernel and architecture-dependent sources in ./linux/arch).
  • 10. 9  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. You can find the memory management sources in ./linux/mm.
  • 11. 10  File Systems The term filesystem has two somewhat different meanings, both of which are commonly used. This can be confusing to novices, but after a while the meaning is usually clear from the context. One meaning is the entire hierarchy of directories (also referred to as the directory tree) that is used to organize files on a computer system. On Linux and Unix, the directories start with the root directory (designated by a forward slash), which contains a series of subdirectories, each of which, in turn, contains further subdirectories, etc. A variant of this definition is the part of the entire hierarchy of directories or of the directory tree that is located on a single partition or disk. (A partition is a section of a hard disk that contains a single type of filesystem.) The second meaning is the type of filesystem, that is, ]how the storage of data (i.e., files, folders, etc.) is organized on a computer disk (hard disk, floppy disk, CDROM, etc.) or on a partition on a hard disk. Each type of filesystem has its own set of rules for controlling the allocation of disk space to files and for associating data about each file (referred to as meta data) with that file,
  • 12. 11 such as its filename, the directory in which it is located, its permissions and its creation date. An example of a sentence using the word filesystem in the first sense is: "Alice installed Linux with the filesystem spread over two hard disks rather than on a single hard disk." This refers to the fact that [ the entire hierarchy of directories of ] Linux can be installed on a single disk or spread over multiple disks, including disks on different computers (or even disks on computers at different locations). An example of a sentence using the second meaning is: "Bob installed Linux using only the ext3 filesystem instead of using both the ext2 and ext3 filesystems." This refers to the fact that a single Linux installation can contain one or multiple types of filesystems. One hard disk can contain one or multiple types of filesystems (each z can be spread across multiple hard disks.  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 the Figure).
  • 13. 12 Figure. 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). You can find the file system sources in ./linux/fs. 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.
  • 14. 13  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. You can find the networking sources in the kernel at ./linux/net.  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. You can find the device driver sources in ./linux/drivers.
  • 15. 14  Conclusion 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.