You are on page 1of 39

Linux System Architecture

By : Amir Hossein Payberah


Tehran Polytechnic University
1

payberah@yahoo.com

Contents

!hat is "ernel# "ernel Architecture $vervie%


User Space "ernel Space &ile System Process 'ana(ement )evice )river 'emory 'ana(ement *et%or+in(

"ernel &unctional $vervie%


Tehran Polytechnic University

What is Kernel ?

'o-ules or sub.systems that provi-e the operatin( system /unctions. The 0ore o/ $S 1t is %ritten in 0

Tehran Polytechnic University


,

Contents

!hat is "ernel# "ernel Architecture $vervie%


User Space "ernel Space &ile System Process 'ana(ement )evice )river 'emory 'ana(ement *et%or+in(
2

"ernel &unctional $vervie%


Tehran Polytechnic University

Kernel Architecture Overview


User Space "ernel Space )ata &lo% Bet%een User Space an"ernel Space

Tehran Polytechnic University


3

User Space

The User Space is the space in memory %here user processes run. This memory is above the "ernel.

1t inclu-es the rest o/ available memory. The system prevents one process /rom inter/erin( %ith another process. $nly "ernel processes can access a user process

This Space is protecte-.

Tehran Polytechnic University

Kernel Space

The "ernel Space is the space in memory %here all +ernel services are provi-e- via +ernel processes. The user has access to it only throu(h the system call.

A user process becomes a +ernel process %hen it executes a system call.

Tehran Polytechnic University


5

System Call

User Space an- "ernel Space are in -i//erent spaces. !hen a System 0all is execute-7 the ar(uments to the call are passe- /rom User Space to "ernel Space.

Tehran Polytechnic University


6

User Space and Kernel Space Relationship


User Process Library Routine Syscall ispatch ata !low

User Space Kernel Space

Tehran Polytechnic University

Kernel Service

Contents

!hat is "ernel# "ernel Architecture $vervie%


User Space "ernel Space &ile System Process 'ana(ement )evice )river 'emory 'ana(ement *et%or+in(
19

"ernel &unctional $vervie%


Tehran Polytechnic University

Kernel !unctional Overview


&ile System Process 'ana(ement )evice )river 'emory 'ana(ement *et%or+in(

Tehran Polytechnic University


11

Kernel !unctional Overview

Tehran Polytechnic University


1

!unctional Layer " Architectural Layer

Tehran Polytechnic University


1,

Contents

!hat is "ernel# "ernel Architecture $vervie%


User Space "ernel Space &ile System Process 'ana(ement )evice )river 'emory 'ana(ement *et%or+in(
12

"ernel &unctional $vervie%


Tehran Polytechnic University

!ile System

Tehran Polytechnic University

1t is responsible /or storin( in/ormation on -is+ an- retrievin( an- up-atin( this in/ormation. The &ile System is accesse- throu(h system calls such as : open7 rea-7 %rite7 : ;xample :

&AT147 &AT, 7 *T&S ext 7 ext, :


13

!ile System

#Cont$%

The Unix system has the /ollo%in( types o/ /iles:


$r-inary &iles

0ontain in/ormation entere- into them by a user7 an application or : 'ana(e the catalo(in( o/ the /ile system Use- to access the peripheral -evices

)irectory &iles

Special &iles <-evices=

Tehran Polytechnic University

&1&$ &iles /or Pipes


14

!ile System
>

#Cont$%

>bin >etc ls
Tehran Polytechnic University

>-ev

: >usr

>home >root A B pic.(i/


15

pin(

-ata.txt

!ile System Structure


&oot &loc'

Super &loc'

inode List

&loc' List

Boot Bloc+ : in/ormation nee-s to boot the system Super Bloc+ : &ile System Speci/ications
Si?e 'ax. number o/ /iles &ree bloc+s &ree ino-es

Tehran Polytechnic University


ino-e List Bloc+ List : The /iles -ata


16

(node

;ach /ile has an ino-e structure that is i-enti/ie- by an i.number. The ino-e contains the in/ormation re@uire- to access the /ile. 1t -oesnAt contain /ile name.

Tehran Polytechnic University


18

(node

#Cont$%

Tehran Polytechnic University


9

irectories

!ile )ame

inode )umber

Tehran Polytechnic University


1

Contents

!hat is "ernel# "ernel Architecture $vervie%


User Space "ernel Space &ile System Process 'ana(ement )evice )river 'emory 'ana(ement *et%or+in(

"ernel &unctional $vervie%


Tehran Polytechnic University

Process *ana+ement

The Unix $S is a time.sharin( system. ;very process is sche-ule- to run /or a perio- o/ time <time slice=. "ernel creates7 mana(es an- -eletes the processes

Tehran Polytechnic University


,

Process *ana+ement
#Cont$%

Tehran Polytechnic

University

1n the Unix system process 97 calle- the s%apper7 is al%ays assi(ne- to the process an0PU sche-uler. 1t mana(es the complete operation o/ process sche-ulin( an- s%appin(. Process 9 is create as a part o/ system boot.up. ;very other process in the system is create as the result o/ a /or+ system call. The /or+ system call splits a process into t%o processes <Parent an- 0hil-=. ;ach process has a uni@ue i-enti/ier <Process 1)=.

Process *ana+ement
#cont$%

;ach process is represente- by a tas+Bstruct -ata structure.

1t contains the speci/ications o/ each process such as:


State Sche-ulin( in/ormation 1-enti/ier :

Tehran Polytechnic University

The tas+Bvector is an array o/ pointers to every tas+Bstruct -ata structure in the system.

This means that the maximum number o/ processes in the system is limite- by the si?e o/ the tas+ vector
3

,ype o- Processes

Cunnin(

The process is either runnin( or it is rea-y to run. The process is %aitin( /or an event or /or a resource. The process has been stoppe-7 usually by receivin( a si(nal. This is a halte- process %hich7 /or some reason7 still has a tas+Bstruct -ata structure in 4 the tas+ vector.

!aitin(

Stoppe

Tehran Polytechnic University

Dombie

Contents

!hat is "ernel# "ernel Architecture $vervie%


User Space "ernel Space &ile System Process 'ana(ement )evice )river 'emory 'ana(ement *et%or+in(
5

"ernel &unctional $vervie%


Tehran Polytechnic University

evice

river

Associate- %ith each physical -evice or virtual -evice is a piece o/ co-e7 calle-evice -river7 %hich mana(e the -evice har-%are. The main /unctions o/ -evice -river:

Tehran Polytechnic University

Settin( up har-%are on initiali?ation. Brin(in( the associate- -evices into an- out o/ services. Ceceivin( -ata /rom the har-%are anpassin( it bac+ to the +ernel. Sen-in( -ata /rom the +ernel to the -evice. )etectin( an- han-lin( -evice errors.
6

,ype o- devices

;very thin( in Unix is a /ile.

;ach -evice is li+e a /ile.

0haracter -evices

A character <char= -evice is one that can be accesse- as a stream o/ bytes. ;xample : "eyboar-7 'ouse7 : A bloc+ -evice can be accesse- only as multiples o/ a bloc+7 %here a bloc+ is usually one +ilobyte o/ -ata or another po%er o/ . ;xample : -is+7 :
8

Tehran Polytechnic University

Bloc+ -evices

*a.or )umber and *inor )umber

'aEor *umber

The maEor number i-enti/ies the -river associate- %ith the -evice. The minor number is use- only by the -river speci/ie- by the maEor numberF other parts o/ the +ernel -onGt use it. 1t is common /or a -river to control several -evices7 the minor number provi-es a %ay /or the -river to -i//erentiate amon( them.
,9

'inor *umber

Tehran Polytechnic University

evice

river #Cont$%

Tehran Polytechnic University


,1

Contents

!hat is "ernel# "ernel Architecture $vervie%


User Space "ernel Space &ile System Process 'ana(ement )evice )river 'emory 'ana(ement *et%or+in(
,

"ernel &unctional $vervie%


Tehran Polytechnic University

*emory *ana+ement

Physical memory is -ivi-e- into se(ments o/ e@ual si?e7 calle- pa(es. Type o/ memory:

Physical memory Hirtual memory S%ap memory

Tehran Polytechnic University


,,

/irtual and swap memory

S%ap

1t is a con/i(urable partition on -is+ treate- in a manner similar to memory. Processes s%appin( in an- out o/ memory on a recurrin( basis /ra(ment physical memory. 1t is impossible to (uarantee that exactly the same physical memory bloc+s %ill be available to a speci/ic process. Hirtual a--ress space solves this problem by assi(nin( conti(uous virtual memory bloc+s to a process. These bloc+s are mappe- to physical memory %hen a process is s%ap in7 an- to s%ap -evice memory %hen the process is s%appe- out.
,2

Hirtual memory

Tehran Polytechnic University

Physical and /irtual memory

Tehran Polytechnic University


,3

Contents

!hat is "ernel# "ernel Architecture $vervie%


User Space "ernel Space &ile System Process 'ana(ement )evice )river 'emory 'ana(ement *et%or+in(
,4

"ernel &unctional $vervie%


Tehran Polytechnic University

)etwor'in+

The /irst inte(rate- communication capability in Unix %as -evelope- /or Ber+eley Unix 2. bs- as the soc+ets implementation. Soc+ets provi-e a pro(rammin( inter/ace /or net%or+in(.

Tehran Polytechnic University


,5

Contents

!hat is "ernel# "ernel Architecture $vervie%


User Space "ernel Space &ile System Process 'ana(ement )evice )river 'emory 'ana(ement *et%or+in(
,6

"ernel &unctional $vervie%


Tehran Polytechnic University

0uestion?
Tehran Polytechnic University
,8

You might also like