7/24/2019 Unix Internals-Lec1
1/36
UNIX Internals
Rohit Jnagal
7/24/2019 Unix Internals-Lec1
2/36
Introduction
First Steps
7/24/2019 Unix Internals-Lec1
3/36
7/24/2019 Unix Internals-Lec1
4/36
0perating System 3efresher
+hy an 0perating System:
you dont want to know what goes into making pepperoni
Process 4 3esources (memory5 dis-5 cpu5 net/or-!
0perating System 6oals:
7 Create 3esource A,stractions
7 Create Process A,stractions
7 8anage 3esource Sharing
7 Process &solation
7 0thers 9
7/24/2019 Unix Internals-Lec1
5/36
0perating System 3efresher
Computer System Components:
ard/are
7 pro*ides ,asic computing resources (CP$5 8emory5 &0!
0perating System7 controls and coordinates the use of hard/are among *arious
application programs for *arious users;
Application Programs (Processes!
7 /ays in /hich system used to sol*e pro,lems of a user (compilers5
data,ase systems5 *ideo games and ma-ing tea! $sers
7 (people5 machines5 other computers!
7/24/2019 Unix Internals-Lec1
6/36
0perating Systems 3efresher
+hy learn 0perating Systems:
7/24/2019 Unix Internals-Lec1
7/36
0perating System istory
0perating Systems through the ages:
=ar- Ages ( >?@ 7 !
acuum
7/24/2019 Unix Internals-Lec1
8/36
0perating System istory
0perating Systems through the ages: >st6eneration (>? 7 !
Mainframe Systems
7 Batching similar Do,s
7 0ne Do, at a time7 Automatic Do, sequencing
7 3esident 8onitor
&nitiate control in monitor
Control transfer to a Do,
+hen Do, completes5 transfer ,ac- tomonitor
7 Se*ere &0 ,ottlenec-
7/24/2019 Unix Internals-Lec1
9/36
0perating System istory
0perating Systems through the ages: 2nd6eneration ( >? 7 E !
Integrated ICs Renaissance
7 8ulti.programmed Batch Systems
7 %otion of computer architecture
7 =is- dri*es
7 0n.line terminals
7 Se*eral Do,s in memory at the same
time7 0S features
Go, scheduling
8emory management ( 0*erlays!
CP$ scheduling
Protection
7/24/2019 Unix Internals-Lec1
10/36
0perating System istory
0perating Systems through the ages:
2nd6eneration (>? 7 E !
7/24/2019 Unix Internals-Lec1
11/36
0perating System istory
A )ong
7/24/2019 Unix Internals-Lec1
12/36
0perating System istory
0perating Systems through the ages:
Hrd6eneration (>?E . !
)S&s5 )S&s5 %ano K mobile an ant can use
Architecture Ad*ances:
7 Smaller5 faster 8icroprocessors
7 Caches
7 )arger Faster Storage
7 0ffloading CP$ /or-
8odern 0S feature7 6$&
7 8ultimedia
7 &nternet 4 +e,
7 %et/or-ed5 =istri,uted5 etc
7/24/2019 Unix Internals-Lec1
13/36
0perating System istory
Current $%&' Systems:
P P.$'
P ( =igital (Compaq! !
7/24/2019 Unix Internals-Lec1
14/36
0perating System Classifications
8ulti.user Single user 8ultiprogramming
8ulti.threaded
7 $ser threads thread li,raries
7 SystemLernel threads
8onolithic Lernel 8icro.-ernels
Functional Classification
7 8ainframe
7 Ser*er
7 =es-top
7/24/2019 Unix Internals-Lec1
15/36
$%&' 0perating System
$%&' Structure
hardwareProc/threadmgmt
File systems
applications
MP
daemons
Misc...
cmds
shells
Memory
Mgmt
IPCdrivers
LVM
I/ O
7/24/2019 Unix Internals-Lec1
16/36
$%&' features
Files andProcesses
File system has places ( *s C:5 =: !
Processes ha*e life
"*erything is a file
Processing en*ironment ard/are mode support
&nterrupts and "#ceptions
Processor "#ecution )e*els
Process 8anagement Su,system 8emory 8anagement Su,system
LernelSystem &nterfaces
So5 /hatJs different in a %on.$%&' system 9
7/24/2019 Unix Internals-Lec1
17/36
Processor 8odes
Super*isor or $ser 8ode
Super*isor 8ode
Can e#ecute all instructions
Can reference all memory locations
Lernel e#ecute in this mode
$ser 8ode
Can e#ecute su,set of instructions
Can reference a su,set of memory locations
7/24/2019 Unix Internals-Lec1
18/36
System ierarchies
Hardware Level
LibrariesUser program
Systemcall interfacelightweight system calls
MemoryManagementSubsystem
device drivers
LVM
User Level
Kernel Level
Hardware control
Process ManagementSubsystem
Scheduling
IP
!u"er ache
Phys #ileSystem
Virtual #ile System
I$ %
7/24/2019 Unix Internals-Lec1
19/36
Primary Su,systems
Process 8anagement
8anages all acti*e processes and threads8emory 8anagement
Allocates memory for processes at run.time
Performs translations of physical memory locations to *irtual memorylocations
File Su,system
irtual File System )ayer
7 A,stracts and manages data for different file system types
Physical File System )ayer
7 8anages access for specific file systems of *arious types&0 Su,system
8anages system &0 resources5 dri*ers5 and data structures
=ri*es system configuration process
7/24/2019 Unix Internals-Lec1
20/36
&s my system $%&' or $%&' compliant 9
A
7/24/2019 Unix Internals-Lec1
21/36
P.$' istory
P$' release istory
e/lett Pac-ard $%&'
P$' >; in >?EH
P$' >; (>??! : ,ased on S3@ $%&' standard
P$' >>; (>??M! : First @.,it *ersion
P$' >>;>>(2>! .N >>i series (+orld +ar > Armistice! P$' >>;2 (22!: First &tanium release
P$' >>;2H >>i *2 (2H!: supports ,oth PA and &tanium5
supports cc%$8A
7/24/2019 Unix Internals-Lec1
22/36
P.$' Specials
P.$' features
First to use access control lists for file access permissionsFirst $%&' system /ith ,uilt in olume 8anager
"nhanced 3elia,ility5 security and partitioning
Clustering technology
Cell Based5 cc%$8A architecture support
irtual Ser*er "n*ironment (S"!
Scaling
>2E processors (e#panda,le to 2!
>
7/24/2019 Unix Internals-Lec1
23/36
Learning
check
7/24/2019 Unix Internals-Lec1
24/36
Computer Architecture 3efresher
Components: CP$
7 &nstruction Set Architecture 3&SC s C&SC
x86 CISC -> RISC +micro-ops
&AH25 &A@5 PA.3&SC5 Po/erPC5 A38
"P&C: &tanium
7 Pipelining Fetch5 =ecode5 "#ecute
Superpipelined5 Superscalar
7 3egisters 6eneral Purpose 3egisters
Program Counters
Program Status +ord (PS+!
8emory 4 8emory ierarchy
7 Caches
7 3A8
7 =is-s
7
7/24/2019 Unix Internals-Lec1
25/36
Computer Architecture 3efresher
0S and Architecture : 8utual &nteraction
7 0S functionality limited ,y Architecture features
8ultiprogramming on EE
7 0S structure can ,e simplified /ith Architecture support &nterrupt5 =8A5 etc
7 8ost proprietary 0S are de*eloped for a particular architecture
PA.3&SC 5 &PF
#E
SPA3C
7/24/2019 Unix Internals-Lec1
26/36
Computer Architecture 3efresher
Architecture support for 0S:
&nterrupt and "#ceptions7 o/ does the -ernel notice an &0 has finished
Polling
ard/are &nterrupt
7 &nterrupts
6enerated ,y ard/are =e*ices
Asynchronous
7 "#ceptions
6enerated ,y e#ecuting instructions
Synchronous
7/24/2019 Unix Internals-Lec1
27/36
Computer Architecture 3efresher
Architecture support for 0S:
&0 0perations7 =ata
7/24/2019 Unix Internals-Lec1
28/36
Computer Architecture 3efresher
Architecture support for 0S:
0S Protection7 o/ does the processor -no/ if a protected instruction should ,e
e#ecuted9
3ings or 8odes of 0peration
Access 3ights
Crossing Protection Boundaries
$ser process call Lernel to do something pri*ileged
0S defined sequence of System Calls
8odes5 Conte#ts and S/itches
8emory Protection
Protect user programs from each other
Protect itself from user programs 8emory 8anagement $nit
Segmentation
Virtual Memory
Page table, Page protection, !"s
"ase an# !imit Registers
7/24/2019 Unix Internals-Lec1
29/36
Computer Architecture 3efresher
Architecture support for 0S:
SynchroniOation7 Pro,lems
&nterrupt may occur at any time and may interfere /ith interrupted code
SynchroniOation of Concurrent Processes
8ulti.processor synchroniOation
7 Solutions
7/24/2019 Unix Internals-Lec1
30/36
Learning
check
7/24/2019 Unix Internals-Lec1
31/36
System Calls
8ethods to request system action on ,ehalf of a user
3equest
System Action 0n ,ehalf of a user
A Single program ma-es numerous system calls;
Program: 3ead from one file and /rite to another
7/24/2019 Unix Internals-Lec1
32/36
System Calls
Passing Parameters
7/24/2019 Unix Internals-Lec1
33/36
System Calls
7/24/2019 Unix Internals-Lec1
34/36
8a-ing a System Call
Gust use the stu,
&nternally5
7 Stu, pushes the syscall num,er on stac-registeru.area
7Arguments go on stac-registersu.area
7A special trap instruction is called
Changes e#ecution mode to -ernel
7/24/2019 Unix Internals-Lec1
35/36
Learning
check
7/24/2019 Unix Internals-Lec1
36/36