ch1 of Os
ch1 of Os
Interrupt Handling
Interrupt Timeline
• The operating system preserves the state of the
CPU by storing registers and the program counter.
• Determines which type of interrupt has occurred:
– polling
– vectored interrupt system
• Separate segments of code determine what
action should be taken for each type of interrupt
Two I/O Methods
I/O Structure
• After I/O starts, control returns to user Synchronous Asynchronous
program only upon I/O completion.
– Wait instruction idles the CPU until the next
interrupt
– Wait loop (contention for memory access).
– At most one I/O request is outstanding at a time,
no simultaneous I/O processing.
• After I/O starts, control returns to user
program without waiting for I/O completion.
– System call – request to the operating system to
allow user to wait for I/O completion.
– Device-status table contains entry for each I/O
device indicating its type, address, and state.
– Operating system indexes into I/O device table to
determine device status and to modify table
entry to include interrupt.
Direct Memory Access Structure
Device-Status Table • Used for high-speed I/O devices able to
transmit information at close to memory
speeds.
• Device controller transfers blocks of data from
buffer storage directly to main memory
without CPU intervention.
• Only on interrupt is generated per block,
rather than the one interrupt per byte.
Storage Structure Storage Hierarchy
• Main memory – only large storage media that the • Storage systems organized in hierarchy.
CPU can access directly.
– Speed
• Secondary storage – extension of main memory
– Cost
that provides large nonvolatile storage capacity.
– Volatility
• Magnetic disks – rigid metal or glass platters
covered with magnetic recording material • Caching – copying information into faster
– Disk surface is logically divided into tracks, which are storage system; main memory can be viewed
subdivided into sectors. as a last cache for secondary storage.
– The disk controller determines the logical interaction
between the device and the computer.
Storage-Device Hierarchy Caching
• Important principle, performed at many levels in a
computer (in hardware, operating system, software)
• Information in use copied from slower to faster storage
temporarily
• Faster storage (cache) checked first to determine if
information is there
– If it is, information used directly from the cache (fast)
– If not, data copied to cache and used there
• Cache smaller than storage being cached
– Cache management important design problem
– Cache size and replacement policy
Migration of Integer A from Disk to Register
Performance of Various Levels of Storage
• Multitasking environments must be careful to use most recent
value, not matter where it is stored in the storage hierarchy
• Movement between levels of storage
hierarchy can be explicit or implicit
Process Management
Process Management Activities
• A process is a program in execution. It is a unit of work within the The operating system is responsible for the following
system. Program is a passive entity, process is an active entity.
• Process needs resources to accomplish its task activities in connection with process management:
– CPU, memory, I/O, files • Creating and deleting both user and system processes
– Initialization data
• Process termination requires reclaim of any reusable resources • Suspending and resuming processes
• Single-threaded process has one program counter specifying location of
next instruction to execute
• Providing mechanisms for process synchronization
– Process executes instructions sequentially, one at a time, until • Providing mechanisms for process communication
completion
• Multi-threaded process has one program counter per thread • Providing mechanisms for deadlock handling
• Typically system has many processes, some user, some operating system
running concurrently on one or more CPUs
– Concurrency by multiplexing the CPUs among the processes /
threads
Memory Management Storage Management
• OS provides uniform, logical view of information
• All data in memory before and after processing storage
– Abstracts physical properties to logical storage unit - file
• All instructions in memory in order to execute – Each medium is controlled by device (i.e., disk drive, tape
• Memory management determines what is in memory drive)
• Varying properties include access speed, capacity, data-transfer
when rate, access method (sequential or random)
– Optimizing CPU utilization and computer response to users • File-System management
– Files usually organized into directories
• Memory management activities – Access control on most systems to determine who can
– Keeping track of which parts of memory are currently access what
being used and by whom – OS activities include
• Creating and deleting files and directories
– Deciding which processes (or parts thereof) and data to • Primitives to manipulate files and dirs
move into and out of memory • Mapping files onto secondary storage
• Backup files onto stable (non-volatile) storage media
– Allocating and deallocating memory space as needed
Mass-Storage Management I/O Subsystem
• Usually disks used to store data that does not fit in main memory or data that must be kept
•
for a “long” period of time.
Proper management is of central importance
• One purpose of OS is to hide peculiarities of
• Entire speed of computer operation hinges on disk subsystem and its algorithms hardware devices from the user
• OS activities
– Free-space management • I/O subsystem responsible for
– Storage allocation
– Disk scheduling
– Memory management of I/O including buffering
• Some storage need not be fast (storing data temporarily while it is being
– Tertiary storage includes optical storage, magnetic tape
– Still must be managed
transferred), caching (storing parts of data in
– Varies between WORM (write-once, read-many-times) and RW (read-write) faster storage for performance), spooling (the
overlapping of output of one job with input of
other jobs)
– General device-driver interface
– Drivers for specific hardware devices
Protection and Security Computing Environments
• Protection – any mechanism for controlling access of processes or • Traditional computer
users to resources defined by the OS – Blurring over time
• Security – defense of the system against internal and external – Office environment
attacks
– Huge range, including denial-of-service, worms, viruses, identity theft, • PCs connected to a network, terminals attached to mainframe or
theft of service minicomputers providing batch and timesharing
• Systems generally first distinguish among users, to determine who • Now portals allowing networked and remote systems access to same
can do what
– User identities (user IDs, security IDs) include name and associated resources
number, one per user – Home networks
– User ID then associated with all files, processes of that user to • Used to be single system, then modems
determine access control
– Group identifier (group ID) allows set of users to be defined and • Now firewalled, networked
controls managed, then also associated with each process, file
– Privilege escalation allows user to change to effective ID with more
rights
Computing Environments (Cont.)
Client-Server Computing
Peer-to-Peer Computing
Dumb terminals supplanted by smart PCs
Many systems now servers, responding to requests generated by • Another model of distributed system
clients
Compute-server provides an interface to client to request • P2P does not distinguish clients and servers
services (i.e. database)
File-server provides interface for clients to store and retrieve – Instead all nodes are considered peers
files
– May each act as client, server or both
– Node must join P2P network
• Registers its service with central lookup service on
network, or
• Broadcast request for service and respond to requests
for service via discovery protocol
– Examples include Napster and Gnutella
Web-Based Computing
• Web has become ubiquitous
• PCs most prevalent devices
• More devices becoming networked to allow
web access End of Chapter 1
• New category of devices to manage web
traffic among similar servers: load balancers
• Use of operating systems like Windows 95,
client-side, have evolved into Linux and
Windows XP, which can be clients and servers