Professional Documents
Culture Documents
Operating Systems
Operating System Structures
Saiful Anwar
State Polytechnic of Jakarta
January, 2007
Interrupts
Interrupt transfers control to the interrupt service
routine
Interrupt Service Routine: Segments of code that
determine action to be taken for each type of interrupt.
Interrupt vector contains the address of service routines.
Trap
software generated interrupt caused either by an error
or a user request.
Interrupt Handling
Types of interrupt
Polling
Vectored interrupt system
I/O Structure
Synchronous I/O
wait instruction idles CPU until next interrupt
no simultaneous I/O processing, at most one outstanding
I/O request at a time.
Asynchronous I/O
After I/O is initiated, control returns to user program without
waiting for I/O completion.
System call
Device Status table - holds type, address and state for
each device
OS indexes into I/O device table to determine device status
and modify table entry to include interrupt.
Memory
Memory
CPU
CPU
I/O instructions
I/O
I/Odevices
devices
Storage Structure
Main memory - only large storage media that the
CPU can access directly.
Secondary storage - extension of main memory
that has large nonvolatile storage capacity.
Magnetic disks - rigid metal or glass platters covered
with magnetic recording material.
Disk surface is logically divided into tracks,
subdivided into sectors.
Disk controller determines logical interaction
between device and computer.
Storage Hierarchy
Storage systems are organized in a hierarchy
based on
Speed
Cost
Volatility
Hardware Protection
Dual Mode Operation
I/O Protection
Memory Protection
CPU Protection
Dual-mode operation
Sharing system resources requires operating
system to ensure that an incorrect program
cannot cause other programs to execute
incorrectly.
Provide hardware support to differentiate
between at least two modes of operation:
1. User mode -- execution done on behalf of a user.
2. Monitor mode (supervisor/kernel/system mode) -execution done on behalf of operating system.
Dual-mode operation(cont.)
Mode bit added to
computer hardware to
indicate the current
mode: monitor(0) or
user(1).
When an interrupt or
fault occurs, hardware
switches to monitor
mode.
Privileged instructions
only in monitor mode.
User
Interrupt/
fault
Set
user
mode
Monitor
I/O Protection
All I/O instructions are privileged
instructions.
Must ensure that a user program could
never gain control of the computer in
monitor mode, for e.g. a user program that
as part of its execution, stores a new
address in the interrupt vector.
Memory Protection
Must provide memory
protection at least for the
interrupt vector and the
interrupt service routines.
To provide memory
protection, add two registers
that determine the range of
legal addresses a program
may address.
Base Register - holds smallest
legal physical memory address.
Limit register - contains the size
of the range.
256000
monitor
Job1
Base register
300040
3000040
Job 2
420940
120900
Job 3
880000
Job 4
1024000
Limit register
CPU Protection
Timer - interrupts computer after specified
period to ensure that OS maintains control.
Timer is decremented every clock tick.
When timer reaches a value of 0, an interrupt occurs.
System Calls
Interface between running program and the OS.
Assembly language instructions (macros and
subroutines)
Some higher level languages allow system calls to be
made directly (e.g. C)
System Programs
Convenient environment for program development and
execution. User view of OS is defined by system
programs, not system calls.
Command Interpreter (sh, csh, ksh) - parses/executes other
system programs
File manipulation - copy (cp), print (lpr), compare(cmp, diff)
File modification - editing (ed, vi, emacs)
Application programs - send mail (mail), read news (rn)
Programming language support (cc)
Status information, communication
etc.
System Generation
OS written for a class of machines, must be
configured for each specific site.
SYSGEN program obtains info about specific hardware
configuration and creates version of OS for hardware
Booting
Bootstrap program - loader program loads
kernel, kernel loads rest of OS.
Bootstrap program stored in ROM
Layered OS Structure
OS divided into number of
layers - bottom layer is
hardware, highest layer is
the user interface.
Each layer uses functions
and services of only lowerlevel layers.
THE Operating System
Kernel has successive
layers of abstraction.
Virtual Machines
Logically treats hardware
and OS kernel as
hardware
processes
processes
processes
kernel kernel
Provides interface
identical to underlying
bare hardware.
kernel
Virtual machine
hardware
Creates illusion of
multiple processes - each
with its own processor
and virtual memory
Summary of OS Structures
Operating System Concepts
Operating System Services, System Programs
and System calls
Operating System Design and Implementation
Structuring Operating Systems