You are on page 1of 46

÷ 



 

p pp
! 

O Layered view of OS
O System Components

 a 
@   
@ 
ë 



  



    

ëë

º a 
! 

 a 
@   
@  
O ÿ e structure of OS consists of 4 layers:
› 


Hardware consists of CPU, aain memory, IO
Devices, etc,

      
   
Software includes process management routines,
memory management routines, IO control
routines, file management routines.

r a 
@   
@  

º   


ÿ is layer consists of compilers, Assemblers, linker
etc.

Ñ ë 


ÿ is is dependent on users need.
E.g. ailway reservation system, Bank database
management etc.,

m a 
  

 ëë
O A
 is a

 in execution: (A program is passive, a
process active.)
E.g.Word processing program run by an user
O A process as resources (CPU time, files, memory) and
attributes t at must be managed.
O Apart from resources, a process may require various
initialization data.
E.g. User process compiler requires a file to compile &
appropriate system calls.
O W en t e process terminates t e OS will reclaim any
reusable resources.

? a 
 ÷ 

O aanagement of processes includes:


O Process Sc eduling (priority, time management, . . . )
O Creationtermination
O BlockUnblock (suspensionresumption )
O Sync ronization
O Communication
O Deadlock andling
O Debugging

X a 
  

ë! " ëë


 ´or a program to be executed, it must be mapped to absolute addresses
and loaded into memory.
 ÿo improve bot t e utilization of t e CPU and speed of t e computer·s
response to its users, we must keep several programs in main memory.
Hence, proper memory management sc emes are required
 
    # $ 
OAllocationde-allocation for processes, files, IO.
Oaaintenance of several processes at a time
OKeep track of w o's using w at memory
Oaovement of process memory tofrom secondary storage.

a 
  

´!% ëë
O A file is a collection of related information defined by its creator.
Commonly, files represent programs (bot source and object
forms) and data.
O ÿ e operating system is responsible for t e following activities in
connections wit file management:
Õ ´ile creation and deletion.
Õ Directory creation and deletion.
Õ Support of primitives for manipulating files and directories.
Õ aapping files onto secondary storage.
Õ ´ile backup on stable (nonvolatile) storage media.

! a 
  

!& ëë
O Buffer cac ing system
O eneric device driver code
O Drivers for eac device - translate readwrite requests into
disk position commands.

ë"  ë ëë


O Disks, tapes, optical, ...

O ´ree space management ( pagingswapping )

O Storage allocation ( w at data goes w ere on disk )

O Disk sc eduling

 a 
  

 '!
O Communication system between distributed processors.
O etting information about filesprocessesetc. on a remote
mac ine.
O Can use eit er a message passing or a s ared memory model.

  !
O Of files, memory, CPU, etc.
O aeans controlling of access
O Depends on t e attributes of t e file and user

 a 
"  ë
O Command Interpreters -- Program t at accepts control
statements (s ell, UI interface, etc.)
O Compilerslinkers
O Communications (´ÿP,ÿELNEÿ,etc)

º a 
! 

O S ell
O Kernel
O System calls
O System programs
O Virtual mac ines
O Java virtual mac ines

pp

 a 
"" ÷ 
O A ( is a piece of software t at provides an interface for
users of an operating system w ic provides access to t e
services of a kernel.

r a 
(,

O  (  


)) 
 *
+ ÷ 
 provide a command-line interface (CLI)
to t e operating system.
E.g. Unix
- 

 provide a grap ical user interface ( UI)
E.g.Windows

m a 
m"
O ÿ e kernel is t e essential centre of a computer operating system,
t e core t at provides basic services for all ot er parts of t e
operating system.
O A kernel includes,
- An interrupt andler t at andles all requests or completed
IO operations
- a sc eduler t at determines w ic programs s are t e kernel's
processing time in w at order, and a supervisor t at actually
gives use of t e computer to eac process w en it is sc eduled.
-A kernel may also include a manager of t e operating system's
address spaces in memory or storage, s aring t ese among all
components and ot er users of t e kernel's services.
? a 
÷""
O System calls provide interface between a process & t e operating
system.
O System calls can be made eit er in assembly or ig level
language.
O A collection of system calls is sometimes referred to as an
application program interface (API).
O ÿ ree most common APIs are Win3 API for Windows, POSIX
API for POSIX-based systems (including virtually all versions of
UNIX, Linux, and aac OS X), and Java API for t e Java virtual
mac ine (JVa)

X a 
 ""

 a 
#"  ÷""
O System call sequence to copy t e contents of one file to anot er file(Command line
interface)

! a 
´" #"

O ÿ e file copy operation makes eavy use of OS (system


calls).
O aost users never see t is level of details.
O ÿ e run time support system (set of libraries included
wit a compiler) for most programming languages
provides a muc simpler interface.

 a 
#"
÷  

)  
Ainclude<iostream. 
Ainclude<fstream. 
void main()
{
ifstream infile(´D:input.txtµ);
ofstream outfile(´D:output.txtµ);
c ar c ;
continue reading file until EO´ is reac ed
w ile(infile){
infile.get(c );
outfile.put(c );
}
}
 a 
!$
  % ""
O Standard library functions are built on top of system calls. ´or
example, t e malloc() in C and related functions are built on
top of t e mmap() system call(LINUX). ÿ is means t at
greater control over t e computer·s resources can be obtained
t roug system calls.
O Standard library functions tend to be more standardized t an
system calls. since system calls provide direct access to t e
kernel, different OS·s will ave at least slig tly different
system calls.

º a 
!$
  % ""

O System calls cause a ´context switc µ, meaning t at t e application


program stops w ile t e kernel program runs for a w ile to
perform t e requested operation. Because of t is, a system
function call takes longer t an a normal function call wit in our
own program.

 a 
  
O 3 met ods
. Parameters in registers.
. ´or more parameters, block of memory is used. Address
of t e memory block w ere parameters are stored is
passed as parameter in a register. (LINUX)

r a 
  

3. Parameters can be placed or pus ed onto t e stack by t e


program and popped off t e stack by t e operating system.

O Some operating systems prefer t e block or stack met ods,


because t ose approac es do not limit t e number or lengt of
parameters being passed.

m a 
÷""&" 
O ÿypically, a number associated wit eac system call
O System-call interface maintains a table indexed according to t ese
numbers
O ÿ e system call interface invokes intended system call in OS
kernel and returns status of t e system call and any return values
O ÿ e caller need know not ing about ow t e system call is
implemented
O Just needs to obey API and understand w at OS will do as a result call
O aost details of OS interface idden from programmer by API
O aanaged by run-time support library (set of functions built into libraries
included wit compiler)

? a 
&' ÷""'   "  

X a 
÷!$#"
O C program invoking printf() library call, w ic calls write()
system call

 a 
%-.   
ÿ ere are  (or more) steps in making t e system call
O  O 

º! a 
  ÷""
O Process control
O ´ile management
O Device management
O Information maintenance
O Communications

º a 
 
O System programs provide a convenient environment for program
development and execution.
O ÿ  
   

. ´ile management:ÿ ese programs create, delete, copy, rename,
print, list and generally manipulate files and directories.

º a 
 
. Status information: Some programs simply ask t e system for t e
data, amount of available memory or disk space, number of users,
etc..
O ÿ at information is t en formatted and presented.

3. ´ile aodification: Several text editors may be available to create


and modify t e content of files stored on t e disk.
E.g. aS word, Notepad
ºº a 
 
3. Programming language support: Compilers, assemblers and
interpreters for common programming languages are often
provided to user t e OS.
4. Program loading and execution: ÿ e system may provide
absolute loaders, relocatable loaders, linkers, etc..
5.Communications : ÿ ese programs allow users to send messages
to one anot er·s screens, to browse web pages, to send email ,
etc«
E.g. Internet Explorer, windows mail
O aost important system program for an operating system is
command interpreter or s ell.

º a 
" 


O aS-DOS ² written to provide t e most functionality in t e
least space
O Not divided into modules
O Alt oug aS-DOS as some structure, its interfaces and levels
of functionality are not well separated

ºr a 
 () ! 



ºm a 
-&*
O UNIX ² limited by ardware functionality, t e original
UNIX operating system ad limited structuring. ÿ e UNIX
OS consists of two separable parts
O Systems programs
O ÿ e kernel
O Consists of everyt ing below t e system-call interface and above t e
p ysical ardware
O Provides t e file system, CPU sc eduling, memory management, and
ot er operating-system functions; a large number of functions for one
level

º? a 
-&*  



ºX a 
Π+!!! 



º a 
  ,"  


O aoves as muc from t e kernel into ´á  µ space
O Communication takes place between user modules using
message passing
O Benefits:
O Easier to extend a microkernel
O Easier to port t e operating system to new arc itectures
O aore reliable (less code is running in kernel mode)
O aore secure
O Detriments:
O Performance over ead of user space to kernel space
communication

! a 
%
" 
O In a Virtual aac ine - eac process "seems" to execute on its
own processor wit its own memory, devices, etc.
O A virtual mac ine provides an interface  to t e
underlying bare ardware
O ÿ e operating system creates t e illusion of multiple processes,
eac executing on its own processor wit its own (virtual)
memory

 a 
%
" -÷ .

O ÿ e resources of t e p ysical computer are s ared to create t e


virtual mac ines
O CPU sc eduling can create t e appearance t at users ave t eir
own processor
O Spooling and a file system can provide virtual card readers and
virtual line printers
O A normal user time-s aring terminal serves as t e virtual mac ine
operator·s console

O ÿ e virtual-mac ine concept provides complete protection of system


resources since eac virtual mac ine is isolated from all ot er virtual
mac ines. ÿ is isolation, owever, permits no direct s aring of
resources.

 a 
%
" -÷ .

Non-virtual aac ine Virtual aac ine

(a) Nonvirtual mac ine (b) virtual mac ine


º a 
/%
" -%.
 JVa is a component of t e Java system t at interprets and
executes t e instructions in our class files.
 ´or eac Java class, t e Java compiler produces an arc itecture
-
$output (.class) file t at will run on any
implementation of t e JVa.
   
.Class loader
. Class verifier
3. Java Interpreter
 a 
%

Verifier

r a 
%
 ÿ e    loads .class files from bot t e Java program
and Java API for execution by t e Java interpreter.
 ÿ e ×   c ecks t e class file is valid Java bytecode and
does not overflow or underflow t e stack.
 ÿ e    t at interprets t e bytecodes one at a time
to turn t e arc itecture neutral bytecodes into native
mac ine language of t e ost computer.
 ÿ e JVa makes it possible to develop programs t at are
arc itecture neutral and portable.
 ÿ e implementation of t e JVa is specific for eac system.

m a