SlideShare a Scribd company logo
1 of 52
Download to read offline
Linux Kernel Architecture
Amir Hossein Payberah
payberah@yahoo.com
Contents



What is Kernel ?
Kernel Architecture Overview
 User

Space
 Kernel Space


Kernel Functional Overview
 File

System
 Process Management
 Device Driver
 Memory Management
 Networking
2
What is Kernel ?
Modules or sub-systems that
provide the operating system
functions.
 The Core of OS


3
Types of kernels
Micro kernel (Modular kernel)
 Monolithic kernel


4
Micro kernel


It includes code only necessary to
allow the system to provide major
functionality.
 IPC
 Some

memory management
 Low level process management &
scheduling
 Low level input / output


Such as Amoeba, Mach and …
5
Monolithic kernel
It includes all the necessary
functions.
 Such as Linux and …


6
Micro vs. Monolithic


Micro
 Flexible
 Modular
 Easy



to implement

Monolithic
 Performance

7
Contents



What is Kernel ?
Kernel Architecture Overview
 User

Space
 Kernel Space


Kernel Functional Overview
 File

System
 Process Management
 Device Driver
 Memory Management
 Networking
8
Kernel Architecture
Overview
User Space
 Kernel Space


User Space
System Call
Kernel Space
Hardware

9
User Space




The User Space is the space in memory
where user processes run.
This Space is protected.
 The

system prevents one process from
interfering with another process.
 Only Kernel processes can access a user
process

10
Kernel Space




The kernel Space is the space in memory
where kernel processes run.
The user has access to it only through the
system call.

11
System Call
User Space and Kernel Space are
in different spaces.
 When a System Call is executed,
the arguments to the call are
passed from
User Space to Kernel Space.
 A user process becomes a kernel
process when it executes a system
call.


12
User Space and Kernel Space
Relationship
User
Process

User
Space
Kernel Space

Data Flow

Library Routine
Syscall Dispatch

Kernel
Service
13
Contents



What is Kernel ?
Kernel Architecture Overview
 User

Space
 Kernel Space


Kernel Functional Overview
 File

System
 Process Management
 Device Driver
 Memory Management
 Networking
14
Kernel Functional
Overview
File System
 Process Management
 Device Driver
 Memory Management
 Networking


15
Kernel Functional Overview

16
Functional Layer &
Architectural Layer
User Space
System Call
MM
PM

FS
Hardware
DM

Net

17
Contents



What is Kernel ?
Kernel Architecture Overview
 User

Space
 Kernel Space


Kernel Functional Overview
 File

System
 Process Management
 Device Driver
 Memory Management
 Networking
18
File System






It is responsible for storing information on
disk and retrieving and updating this
information.
The File System is accessed through
system calls such as : open, read, write, …
Example :
 FAT16,

FAT32, NTFS
 ext2, ext3
…
19
Type of Files


The Unix system has the following types of
files:
 Ordinary


Contain information entered into them by a user, an
application or …

 Directory


Files

Manage the cataloging of the file system

 Special


Files

Files (devices)

Used to access the peripheral devices

 FIFO

Files for Pipes
20
Extended File System
/

/bin /etc
ls

/dev

… /usr

/home

ping

A
data.txt

/root
B

pic.gif
21
File System Structure
Boot Super inode Block
Block Block List
List



Boot Block : information needs to boot the system
Super Block : File System Specifications
Size
 Max. number of files
 Free blocks
 Free inodes





inode List
Block List : The files data
22
Inode
Each file has an inode structure that
is identified by an i-number.
 The inode contains the information
required to access the file.
 It doesn’t contain file name.


23
Inode

(Cont.)

24
Directories

File
Name

inode Number

25
Virtual File System
It manages all the different file
system.
 It is an abstraction layer between the
application program and the file
system implementations.


26
Virtual File System (Cont.)


It describes the system’s file in terms
of superblocks and inodes (the same
way as the Ext2).

27
Virtual File System (Cont.)
Inode cache
 Directory Cache


28
Contents



What is Kernel ?
Kernel Architecture Overview
 User

Space
 Kernel Space


Kernel Functional Overview
 File

System
 Process Management
 Device Driver
 Memory Management
 Networking
29
Process Management
The Unix OS is a time-sharing
system.
 Every process is scheduled to run for
a period of time (time slice).
 Kernel creates, manages and deletes
the processes


30
Process Management (Cont.)






Every process (except init) in the system is create
as the result of a fork system call.
The fork system call splits a process into two
processes (Parent and Child).
Each process has a unique identifier (Process ID).

31
Process Structure


Each process is represented by a
task_struct data structure.
 It

contains the specifications of each process
such as:





State
Scheduling information
Identifier
…

32
Process Structure (cont.)


The task_vector is an array of pointers to
every task_struct data structure in the
system.
 This

means that the maximum number of
processes in the system is limited by the size of
the task vector

33
Type of Processes


Running




Waiting




The process is waiting for an event or for a resource.

Stopped




The process is either running or it is ready to run.

The process has been stopped, usually by receiving a
signal.

Zombie


This is a halted process which, for some reason, still has
a task_struct data structure in the task vector.
34
Contents



What is Kernel ?
Kernel Architecture Overview
 User

Space
 Kernel Space


Kernel Functional Overview
 File

System
 Process Management
 Device Driver
 Memory Management
 Networking
35
Device Driver





On of the purpose of an OS is to hide the
system’s hardware from user.
Instead of putting code to manage the HW
controller into every application, the code
is kept in the Linux kernel.
It abstracts the handling of devices.
 All

HW devices look like regular files.

36
Type of devices


Character devices
A

character device is one that can be accessed
as a stream of bytes.
 Example : Keyboard, Mouse, …


Block devices
A

block device can be accessed only as
multiples of a block.
 Example : disk, …


Network devices
 They

are created by Linux kernel.

37
Major Number and Minor Number


Major Number
 The

major number identifies the driver
associated with the device.



Minor Number
 The

minor number is used only by the driver
specified by the major number; other parts of
the kernel don't use it.
 It is common for a driver to control several
devices, the minor number provides a way for
the driver to differentiate among them.
38
Device Driver

(Cont.)

39
Contents



What is Kernel ?
Kernel Architecture Overview
 User

Space
 Kernel Space


Kernel Functional Overview
 File

System
 Process Management
 Device Driver
 Memory Management
 Networking
40
Memory Management



Physical memory is limited.
Virtual memory is developed to overcome
this limitation.

41
Virtual memory






Large Address space
Protection
Memory mapping
Fair physical memory allocation
Shared virtual memory

42
Physical and Virtual memory

43
Swap memory


It is a configurable partition on disk
treated in a manner similar to
memory.

44
Contents



What is Kernel ?
Kernel Architecture Overview
 User

Space
 Kernel Space


Kernel Functional Overview
 File

System
 Process Management
 Device Driver
 Memory Management
 Networking
45
Network layers

46
Linux network layers

47
BSD socket layer


It is a general interface (abstract
layer).
 Used



in networking and IPC.

Socket address families:
 UNIX
 INET
 AX25
 IPX
 APPLETALK
 X25
48
What is socket?
main()
{
FILE *fd;
fd = fopen (…);
process (fd);
fclose (fd);
}

main()
{
int sockfd;
sockfd = socket (…);
process (sockfd);
close (sockfd);
}

49
INET socket layer
It supports the Internet address
family.
 Its interface with BSD socket layer is
through a set of operation which is
registered with BSD socket layer.


50
Type of sockets


Stream Socket
 Provide

a reliable, sequenced, two-way
connection (such as TCP).



Datagram Socket
A

connection-less and unreliable connection
(such as UDP).



Raw Socket
 Used

for internal network protocols.

51
Question?
52

More Related Content

What's hot

What's hot (20)

Embedded Recipes 2017 - Introduction to Yocto Project/OpenEmbedded - Mylène J...
Embedded Recipes 2017 - Introduction to Yocto Project/OpenEmbedded - Mylène J...Embedded Recipes 2017 - Introduction to Yocto Project/OpenEmbedded - Mylène J...
Embedded Recipes 2017 - Introduction to Yocto Project/OpenEmbedded - Mylène J...
 
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 Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)
 
Fun with Network Interfaces
Fun with Network InterfacesFun with Network Interfaces
Fun with Network Interfaces
 
Kernel Module Programming
Kernel Module ProgrammingKernel Module Programming
Kernel Module Programming
 
Extreme Linux Performance Monitoring and Tuning
Extreme Linux Performance Monitoring and TuningExtreme Linux Performance Monitoring and Tuning
Extreme Linux Performance Monitoring and Tuning
 
Linux scheduler
Linux schedulerLinux scheduler
Linux scheduler
 
Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021
 
DPDK In Depth
DPDK In DepthDPDK In Depth
DPDK In Depth
 
Browsing Linux Kernel Source
Browsing Linux Kernel SourceBrowsing Linux Kernel Source
Browsing Linux Kernel Source
 
BusyBox for Embedded Linux
BusyBox for Embedded LinuxBusyBox for Embedded Linux
BusyBox for Embedded Linux
 
Vmlinux: anatomy of bzimage and how x86 64 processor is booted
Vmlinux: anatomy of bzimage and how x86 64 processor is bootedVmlinux: anatomy of bzimage and how x86 64 processor is booted
Vmlinux: anatomy of bzimage and how x86 64 processor is booted
 
DMA Survival Guide
DMA Survival GuideDMA Survival Guide
DMA Survival Guide
 
semaphore & mutex.pdf
semaphore & mutex.pdfsemaphore & mutex.pdf
semaphore & mutex.pdf
 
Faster packet processing in Linux: XDP
Faster packet processing in Linux: XDPFaster packet processing in Linux: XDP
Faster packet processing in Linux: XDP
 
Static partitioning virtualization on RISC-V
Static partitioning virtualization on RISC-VStatic partitioning virtualization on RISC-V
Static partitioning virtualization on RISC-V
 
Memory management in Linux kernel
Memory management in Linux kernelMemory management in Linux kernel
Memory management in Linux kernel
 
Linux Kernel Crashdump
Linux Kernel CrashdumpLinux Kernel Crashdump
Linux Kernel Crashdump
 
Kdump and the kernel crash dump analysis
Kdump and the kernel crash dump analysisKdump and the kernel crash dump analysis
Kdump and the kernel crash dump analysis
 
Virtualization with KVM (Kernel-based Virtual Machine)
Virtualization with KVM (Kernel-based Virtual Machine)Virtualization with KVM (Kernel-based Virtual Machine)
Virtualization with KVM (Kernel-based Virtual Machine)
 

Viewers also liked

Linux architecture
Linux architectureLinux architecture
Linux architecture
mcganesh
 
The linux networking architecture
The linux networking architectureThe linux networking architecture
The linux networking architecture
hugo lu
 
Introduction to Linux OS
Introduction to Linux OSIntroduction to Linux OS
Introduction to Linux OS
Mohammed Safwat
 

Viewers also liked (20)

Linux architecture
Linux architectureLinux architecture
Linux architecture
 
The linux networking architecture
The linux networking architectureThe linux networking architecture
The linux networking architecture
 
linux software architecture
linux software architecture linux software architecture
linux software architecture
 
Basic Linux Internals
Basic Linux InternalsBasic Linux Internals
Basic Linux Internals
 
What is Kernel, basic idea of kernel
What is Kernel, basic idea of kernelWhat is Kernel, basic idea of kernel
What is Kernel, basic idea of kernel
 
Kernel (OS)
Kernel (OS)Kernel (OS)
Kernel (OS)
 
Linux Networking Explained
Linux Networking ExplainedLinux Networking Explained
Linux Networking Explained
 
Operating system kernal
Operating system kernalOperating system kernal
Operating system kernal
 
KERNAL ARCHITECTURE
KERNAL ARCHITECTUREKERNAL ARCHITECTURE
KERNAL ARCHITECTURE
 
Kernel (computing)
Kernel (computing)Kernel (computing)
Kernel (computing)
 
LinuxCon 2015 Linux Kernel Networking Walkthrough
LinuxCon 2015 Linux Kernel Networking WalkthroughLinuxCon 2015 Linux Kernel Networking Walkthrough
LinuxCon 2015 Linux Kernel Networking Walkthrough
 
The TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelThe TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux Kernel
 
Introduction to Linux OS
Introduction to Linux OSIntroduction to Linux OS
Introduction to Linux OS
 
Linux Kernel Introduction
Linux Kernel IntroductionLinux Kernel Introduction
Linux Kernel Introduction
 
Introduction To Linux Kernel Modules
Introduction To Linux Kernel ModulesIntroduction To Linux Kernel Modules
Introduction To Linux Kernel Modules
 
Linux.ppt
Linux.ppt Linux.ppt
Linux.ppt
 
DevConf 2014 Kernel Networking Walkthrough
DevConf 2014   Kernel Networking WalkthroughDevConf 2014   Kernel Networking Walkthrough
DevConf 2014 Kernel Networking Walkthrough
 
Kernal
KernalKernal
Kernal
 
Linux Kernel Tour
Linux Kernel TourLinux Kernel Tour
Linux Kernel Tour
 
introduction to linux kernel tcp/ip ptocotol stack
introduction to linux kernel tcp/ip ptocotol stack introduction to linux kernel tcp/ip ptocotol stack
introduction to linux kernel tcp/ip ptocotol stack
 

Similar to Linux kernel architecture

Linux internal
Linux internalLinux internal
Linux internal
mcganesh
 
Linux architecture
Linux architectureLinux architecture
Linux architecture
mcganesh
 

Similar to Linux kernel architecture (20)

Section02-Structures.ppt
Section02-Structures.pptSection02-Structures.ppt
Section02-Structures.ppt
 
Linux internal
Linux internalLinux internal
Linux internal
 
Linux architecture
Linux architectureLinux architecture
Linux architecture
 
Unix fundamentals
Unix fundamentalsUnix fundamentals
Unix fundamentals
 
Visual comparison of Unix-like systems & Virtualisation
Visual comparison of Unix-like systems & VirtualisationVisual comparison of Unix-like systems & Virtualisation
Visual comparison of Unix-like systems & Virtualisation
 
CS403: Operating System : Unit I _merged.pdf
CS403: Operating System :  Unit I _merged.pdfCS403: Operating System :  Unit I _merged.pdf
CS403: Operating System : Unit I _merged.pdf
 
linux kernel overview 2013
linux kernel overview 2013linux kernel overview 2013
linux kernel overview 2013
 
Walking around linux kernel
Walking around linux kernelWalking around linux kernel
Walking around linux kernel
 
ch2-system structure.ppt
ch2-system structure.pptch2-system structure.ppt
ch2-system structure.ppt
 
Ch2 system structure
Ch2 system structureCh2 system structure
Ch2 system structure
 
Unix1
Unix1Unix1
Unix1
 
Chapter 1- Introduction.ppt
Chapter 1- Introduction.pptChapter 1- Introduction.ppt
Chapter 1- Introduction.ppt
 
Windows xp
Windows xpWindows xp
Windows xp
 
Windows Architecture Explained by Stacksol
Windows Architecture Explained by StacksolWindows Architecture Explained by Stacksol
Windows Architecture Explained by Stacksol
 
linux system and network administrations
linux system and network administrationslinux system and network administrations
linux system and network administrations
 
operating system1.pdf
operating system1.pdfoperating system1.pdf
operating system1.pdf
 
Introduction to Linux Kernel
Introduction to Linux KernelIntroduction to Linux Kernel
Introduction to Linux Kernel
 
Mohammad ali
Mohammad aliMohammad ali
Mohammad ali
 
Linux kernel Architecture and Properties
Linux kernel Architecture and PropertiesLinux kernel Architecture and Properties
Linux kernel Architecture and Properties
 
Linux Device Driver Introduction
Linux Device Driver IntroductionLinux Device Driver Introduction
Linux Device Driver Introduction
 

More from Teja Bheemanapally (20)

Teradata
TeradataTeradata
Teradata
 
Teradata
TeradataTeradata
Teradata
 
Linux or unix interview questions
Linux or unix interview questionsLinux or unix interview questions
Linux or unix interview questions
 
Linux notes
Linux notesLinux notes
Linux notes
 
Linux crontab
Linux crontabLinux crontab
Linux crontab
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commands
 
Linux01122011
Linux01122011Linux01122011
Linux01122011
 
Kernel (computing)
Kernel (computing)Kernel (computing)
Kernel (computing)
 
Installing red hat enterprise linux1
Installing red hat enterprise linux1Installing red hat enterprise linux1
Installing red hat enterprise linux1
 
Linux basic commands tutorial
Linux basic commands tutorialLinux basic commands tutorial
Linux basic commands tutorial
 
In a monolithic kerne1
In a monolithic kerne1In a monolithic kerne1
In a monolithic kerne1
 
Common linuxcommandspocketguide07
Common linuxcommandspocketguide07Common linuxcommandspocketguide07
Common linuxcommandspocketguide07
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
 
Basic commands
Basic commandsBasic commands
Basic commands
 
File system hierarchy standard
File system hierarchy standardFile system hierarchy standard
File system hierarchy standard
 
40 basic linux command
40 basic linux command40 basic linux command
40 basic linux command
 
15 practical grep command examples in linux
15 practical grep command examples in linux15 practical grep command examples in linux
15 practical grep command examples in linux
 
25 most frequently used linux ip tables rules examples
25 most frequently used linux ip tables rules examples25 most frequently used linux ip tables rules examples
25 most frequently used linux ip tables rules examples
 
Shell intro
Shell introShell intro
Shell intro
 
6 stages of linux boot process
6 stages of linux boot process6 stages of linux boot process
6 stages of linux boot process
 

Recently uploaded

Recently uploaded (20)

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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...
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

Linux kernel architecture

  • 1. Linux Kernel Architecture Amir Hossein Payberah payberah@yahoo.com
  • 2. Contents   What is Kernel ? Kernel Architecture Overview  User Space  Kernel Space  Kernel Functional Overview  File System  Process Management  Device Driver  Memory Management  Networking 2
  • 3. What is Kernel ? Modules or sub-systems that provide the operating system functions.  The Core of OS  3
  • 4. Types of kernels Micro kernel (Modular kernel)  Monolithic kernel  4
  • 5. Micro kernel  It includes code only necessary to allow the system to provide major functionality.  IPC  Some memory management  Low level process management & scheduling  Low level input / output  Such as Amoeba, Mach and … 5
  • 6. Monolithic kernel It includes all the necessary functions.  Such as Linux and …  6
  • 7. Micro vs. Monolithic  Micro  Flexible  Modular  Easy  to implement Monolithic  Performance 7
  • 8. Contents   What is Kernel ? Kernel Architecture Overview  User Space  Kernel Space  Kernel Functional Overview  File System  Process Management  Device Driver  Memory Management  Networking 8
  • 9. Kernel Architecture Overview User Space  Kernel Space  User Space System Call Kernel Space Hardware 9
  • 10. User Space   The User Space is the space in memory where user processes run. This Space is protected.  The system prevents one process from interfering with another process.  Only Kernel processes can access a user process 10
  • 11. Kernel Space   The kernel Space is the space in memory where kernel processes run. The user has access to it only through the system call. 11
  • 12. System Call User Space and Kernel Space are in different spaces.  When a System Call is executed, the arguments to the call are passed from User Space to Kernel Space.  A user process becomes a kernel process when it executes a system call.  12
  • 13. User Space and Kernel Space Relationship User Process User Space Kernel Space Data Flow Library Routine Syscall Dispatch Kernel Service 13
  • 14. Contents   What is Kernel ? Kernel Architecture Overview  User Space  Kernel Space  Kernel Functional Overview  File System  Process Management  Device Driver  Memory Management  Networking 14
  • 15. Kernel Functional Overview File System  Process Management  Device Driver  Memory Management  Networking  15
  • 17. Functional Layer & Architectural Layer User Space System Call MM PM FS Hardware DM Net 17
  • 18. Contents   What is Kernel ? Kernel Architecture Overview  User Space  Kernel Space  Kernel Functional Overview  File System  Process Management  Device Driver  Memory Management  Networking 18
  • 19. File System    It is responsible for storing information on disk and retrieving and updating this information. The File System is accessed through system calls such as : open, read, write, … Example :  FAT16, FAT32, NTFS  ext2, ext3 … 19
  • 20. Type of Files  The Unix system has the following types of files:  Ordinary  Contain information entered into them by a user, an application or …  Directory  Files Manage the cataloging of the file system  Special  Files Files (devices) Used to access the peripheral devices  FIFO Files for Pipes 20
  • 21. Extended File System / /bin /etc ls /dev … /usr /home ping A data.txt /root B pic.gif 21
  • 22. File System Structure Boot Super inode Block Block Block List List   Boot Block : information needs to boot the system Super Block : File System Specifications Size  Max. number of files  Free blocks  Free inodes    inode List Block List : The files data 22
  • 23. Inode Each file has an inode structure that is identified by an i-number.  The inode contains the information required to access the file.  It doesn’t contain file name.  23
  • 26. Virtual File System It manages all the different file system.  It is an abstraction layer between the application program and the file system implementations.  26
  • 27. Virtual File System (Cont.)  It describes the system’s file in terms of superblocks and inodes (the same way as the Ext2). 27
  • 28. Virtual File System (Cont.) Inode cache  Directory Cache  28
  • 29. Contents   What is Kernel ? Kernel Architecture Overview  User Space  Kernel Space  Kernel Functional Overview  File System  Process Management  Device Driver  Memory Management  Networking 29
  • 30. Process Management The Unix OS is a time-sharing system.  Every process is scheduled to run for a period of time (time slice).  Kernel creates, manages and deletes the processes  30
  • 31. Process Management (Cont.)    Every process (except init) in the system is create as the result of a fork system call. The fork system call splits a process into two processes (Parent and Child). Each process has a unique identifier (Process ID). 31
  • 32. Process Structure  Each process is represented by a task_struct data structure.  It contains the specifications of each process such as:     State Scheduling information Identifier … 32
  • 33. Process Structure (cont.)  The task_vector is an array of pointers to every task_struct data structure in the system.  This means that the maximum number of processes in the system is limited by the size of the task vector 33
  • 34. Type of Processes  Running   Waiting   The process is waiting for an event or for a resource. Stopped   The process is either running or it is ready to run. The process has been stopped, usually by receiving a signal. Zombie  This is a halted process which, for some reason, still has a task_struct data structure in the task vector. 34
  • 35. Contents   What is Kernel ? Kernel Architecture Overview  User Space  Kernel Space  Kernel Functional Overview  File System  Process Management  Device Driver  Memory Management  Networking 35
  • 36. Device Driver    On of the purpose of an OS is to hide the system’s hardware from user. Instead of putting code to manage the HW controller into every application, the code is kept in the Linux kernel. It abstracts the handling of devices.  All HW devices look like regular files. 36
  • 37. Type of devices  Character devices A character device is one that can be accessed as a stream of bytes.  Example : Keyboard, Mouse, …  Block devices A block device can be accessed only as multiples of a block.  Example : disk, …  Network devices  They are created by Linux kernel. 37
  • 38. Major Number and Minor Number  Major Number  The major number identifies the driver associated with the device.  Minor Number  The minor number is used only by the driver specified by the major number; other parts of the kernel don't use it.  It is common for a driver to control several devices, the minor number provides a way for the driver to differentiate among them. 38
  • 40. Contents   What is Kernel ? Kernel Architecture Overview  User Space  Kernel Space  Kernel Functional Overview  File System  Process Management  Device Driver  Memory Management  Networking 40
  • 41. Memory Management   Physical memory is limited. Virtual memory is developed to overcome this limitation. 41
  • 42. Virtual memory      Large Address space Protection Memory mapping Fair physical memory allocation Shared virtual memory 42
  • 43. Physical and Virtual memory 43
  • 44. Swap memory  It is a configurable partition on disk treated in a manner similar to memory. 44
  • 45. Contents   What is Kernel ? Kernel Architecture Overview  User Space  Kernel Space  Kernel Functional Overview  File System  Process Management  Device Driver  Memory Management  Networking 45
  • 48. BSD socket layer  It is a general interface (abstract layer).  Used  in networking and IPC. Socket address families:  UNIX  INET  AX25  IPX  APPLETALK  X25 48
  • 49. What is socket? main() { FILE *fd; fd = fopen (…); process (fd); fclose (fd); } main() { int sockfd; sockfd = socket (…); process (sockfd); close (sockfd); } 49
  • 50. INET socket layer It supports the Internet address family.  Its interface with BSD socket layer is through a set of operation which is registered with BSD socket layer.  50
  • 51. Type of sockets  Stream Socket  Provide a reliable, sequenced, two-way connection (such as TCP).  Datagram Socket A connection-less and unreliable connection (such as UDP).  Raw Socket  Used for internal network protocols. 51