3.basic hardware elements
TRANSCRIPT
OPERATING SYSTEMOVERVIEW
Contents
Basic hardware elements
Most I/O devicesare much slower thanthe processor
Interrupts
Interrupt request signal
Active waiting cycle (polling)
An interrupt cycle isadded to the instructioncycle (fecth and execute).
The processor checks tosee if an interrupt hasoccured (interrupt signal)
Interrupt mechanism
interrupt handler
interrupt vector
Interrupt mechanism
CPU saves PS and PC(push) into the controlstack
CPU loads into PC andPS the correspondingvalues from theinterrupt vector
Interrupt processing
iret
interrupt handler execution
Interrupt processing
Interrupt enable/disablebit (PS register)
Hardware priority
STI (Set Interrupt)CLI (Clear Interrupt)
Interrupt mechanism
mainmainmemorymemory
i+1 PS inth
1OOi1OO
149
15O iret
1OOO
12OO12O1
mainmainmemorymemory
inthinth
progproginterruptinterrupt
1
2
3
interruptinterruptvectorvector
Interrupt processing
PS prog
12O1
3824
PS
PC
SP
stack
mainmemory
3824
39OO
CPU completes executionof the current instruction
Interrupt processing
interrupt signal has beenaccepted
PS inth
1OO
3822
PS
PC
SPstack
mainmainmemorymemory
3824
39OO
12O1
PS prog3823
3822
Interrupt processing
PS inth
151
3822
PS
PC
SP
stack
main memorymain memory
3824
39OO
12O1
PS prog
3823
3822
iret execution
Interrupt processing
stack
mainmemory
3824
39OO
PS prog
12O1
3824
PS
PC
SP
iret completed
Interrupt processing
O.S.Components
Contents
Process Management
O.S. COMPONENTS
Main-Memory Management
Secondary-MemoryManagement
File Management
I/O-System Management
O.S. COMPONENTS
Creating and deletingprocesses
Suspending and resumingprocesses
Provide mechanismsfor process interaction
Process management
Keeping track of whichparts of memoryare currently being usedand by whom
Main memory management
Deciding which processesare to be loaded whenmemory becomes available
Main memory management
Allocating anddeallocating memoryspace as needed
Main memory management
Secondary memorymanagement
Free space management
Storage allocation
Disk scheduling
I/O SYSTEM MANAGEMENT
The I/O subsystemconsists of
A memory-managementcomponent that includesbuffering and spooling
A general device driverinterface
Drivers for specifichardware devices
I/O SYSTEM MANAGEMENT
The I/O subsystemconsists of
File management
Creating and deletingfiles and directories
Supporting primitivesfor manipulating fileand directory
Mapping filesonto storage
Backing up fileson stable storage media
File management
Protection systems
Mechanism forcontrolling the accessof processes to systemresources
The mechanism mustprovide means forspecifying the controlsto be imposed and meansfor enforcement
Protection systems
The interface betweenusers and O.S.
A program that readsand interpretes controlstatements
Comand-Interpreter System
Its main function: to getnext command statementand execute it (shell)
Comand-Interpreter System
System calls
Contents
Processes communicatewith the O.S. and requestservices to it by makingsystem calls
System Calls
System calls providethe interface between anyprocess and O.S.
System Calls
Process control
Examples of System Call
Communications
Information management
Devicemanipulation
File manipulation
Corresponding to
each system call
there is a library procedure
count= read (file, buffer,nbytes)
count returns the number of bytesactually read
C program
Example:Example: readread system callsystem call
Library readLibrary readprocedureprocedure
operatingoperatingsystemsystem
system callREAD
INTINT
returnreturnfrom INTfrom INT
register x
x ← callparameters
load x
system callREAD
23
1
Puts the parameters of thesystem call in machineregisters
The library procedureThe library procedure
The control is returned tothe caller by returning thestatus code as a result
Issues a INT instruction tostart the O.S.
directly via registers
in a memory block whoseaddress is passed as aparameter in a registry
into the stack (push, pop)
Methods to pass parameters tooperating system
hardware(CPU, memory, disks, terminals, …)
UNIX O.S.
(process management, memorymanagement, file system, I/O, ...)
standard library(open, close, read, write, ..)
utility programs(shell, compiler, …)
users
usermode
kernelmode
userint.
libraryinterface
systemcallinterf.
Dual mode of operations
user mode
Hardware control does notallow the execution ofprivileged instructions
Used for normal execution ofuser programs
Used for the execution ofUsed for the execution ofO.S. functions as requiredO.S. functions as requiredby system callsby system calls
supervisor mode (kernel mode)
All instructions can beAll instructions can beexecutedexecuted
Dual mode of operations