2. Chapter 1: Introduction
s What Operating Systems Do
s Computer-System Organization
s Computer-System Architecture
s Operating-System Structure
s Operating-System Operations
s Process Management
s Memory Management
s Storage Management
s Protection and Security
s Distributed Systems
s Special-Purpose Systems
s Computing Environments
Operating System Concepts – 7 th Edition 1.2 Silberschatz, Galvin and Gagne
3. What is an Operating System?
s A program that acts as an intermediary between a user of a
computer and the computer hardware.
s Operating system goals:
q Execute user programs and make solving user problems
easier.
q Make the computer system convenient to use.
s Use the computer hardware in an efficient manner.
Operating System Concepts – 7 th Edition 1.3 Silberschatz, Galvin and Gagne
4. Computer System Structure
s Computer system can be divided into four components
q Hardware – provides basic computing resources
CPU, memory, I/O devices
q Operating system
Controls and coordinates use of hardware among various
applications and users
q Application programs – define the ways in which the system
resources are used to solve the computing problems of the
users
Word processors, compilers, web browsers, database
systems, video games
q Users
People, machines, other computers
Operating System Concepts – 7 th Edition 1.4 Silberschatz, Galvin and Gagne
5. Four Components of a Computer System
Operating System Concepts – 7 th Edition 1.5 Silberschatz, Galvin and Gagne
6. Operating System Definition
s OS is a resource allocator
q Manages all resources
q Decides between conflicting requests for efficient and fair
resource use
s OS is a control program
q Controls execution of programs to prevent errors and improper
use of the computer
Operating System Concepts – 7 th Edition 1.6 Silberschatz, Galvin and Gagne
7. Operating System Definition (Cont.)
s No universally accepted definition
s “Everything a vendor ships when you order an operating system”
is good approximation
q But varies wildly
s “The one program running at all times on the computer” is the
kernel. Everything else is either a system program (ships with
the operating system) or an application program
Operating System Concepts – 7 th Edition 1.7 Silberschatz, Galvin and Gagne
8. Computer Startup
s bootstrap program is loaded at power-up or reboot
q Typically stored in ROM or EPROM, generally known as
firmware
q Initializes all aspects of system
q Loads operating system kernel and starts execution
Operating System Concepts – 7 th Edition 1.8 Silberschatz, Galvin and Gagne
9. Computer System Organization
s Computer-system operation
q One or more CPUs, device controllers connect through
common bus providing access to shared memory
q Concurrent execution of CPUs and devices competing for
memory cycles
Operating System Concepts – 7 th Edition 1.9 Silberschatz, Galvin and Gagne
10. Computer-System Operation
s I/O devices and the CPU can execute concurrently.
s Each device controller is in charge of a particular device type.
s Each device controller has a local buffer.
s CPU moves data from/to main memory to/from local buffers
s I/O is from the device to local buffer of controller.
s Device controller informs CPU that it has finished its operation by
causing an interrupt.
Operating System Concepts – 7 th Edition 1.10 Silberschatz, Galvin and Gagne
11. Interrupts
An event external to the currently executing process that
causes a change in the normal flow of instruction
execution; usually generated by hardware devices
external to the CPU
Operating System Concepts – 7 th Edition 1.11 Silberschatz, Galvin and Gagne
12. Why Interrupts ?
People like connecting devices
• A computer is much more than the CPU
• Keyboard, mouse, screen, disk drives, Scanner, printer, sound
card, camera, etc.
These devices occasionally need CPU service
• But we can’t predict when
• • we want to keep the CPU busy between events
Need a way for CPU to find out devices need attention
Operating System Concepts – 7 th Edition 1.12 Silberschatz, Galvin and Gagne
13. Common Functions of Interrupts
s Interrupt transfers control to the interrupt service routine generally,
through the interrupt vector, which contains the addresses of all the
service routines.
s Interrupt architecture must save the address of the interrupted
instruction.
s Incoming interrupts are disabled while another interrupt is being
processed to prevent a lost interrupt.
s A trap is a software-generated interrupt caused either by an error or
a user request.
s An operating system is interrupt driven.
Operating System Concepts – 7 th Edition 1.13 Silberschatz, Galvin and Gagne
14. Interrupt Handling
s The operating system preserves the state of the CPU
by storing registers and the program counter.
s Determines which type of interrupt has occurred:
q Polling
q Vectored interrupt system
s Separate segments of code determine what action
should be taken for each type of interrupt
Operating System Concepts – 7 th Edition 1.14 Silberschatz, Galvin and Gagne
15. Interrupt Handling
“Polling is like picking up your phone every few
seconds to see if you have a call. Interrupts are
like waiting for the phone to ring.”
• Interrupts win if processor has other work to do
and event response time is not critical
• Polling can be better if processor has to respond
to an event ASAP
Operating System Concepts – 7 th Edition 1.15 Silberschatz, Galvin and Gagne
16. Interrupt Handling
Polling
s In polled devices, the only information the system has about
a device interrupt is either the bus interrupt priority level
(IPL) or the interrupt request number (IRQ)
s Interrupt handler poll or send a signal to each device in turn
in order to find out which one sent the interrupt request.
Operating System Concepts – 7 th Edition 1.16 Silberschatz, Galvin and Gagne
17. Interrupt Handling
Vectored interrupt system
q Devices that use vectored interrupts are assigned an
interrupt vector .
q This is a number that identifies a particular interrupt
handler.
q When the device interrupts, the system enters the
interrupt acknowledgement cycle, asking the interrupting
device to identify itself.
q The device responds with its interrupt vector. The kernel
then uses this vector to find the responsible interrupt
handler.
Operating System Concepts – 7 th Edition 1.17 Silberschatz, Galvin and Gagne
19. I/O Structure
s After I/O starts, control returns to user program only upon I/O
completion.
q Wait instruction idles the CPU until the next interrupt
q Wait loop (contention for memory access).
q At most one I/O request is outstanding at a time, no
simultaneous I/O processing.
s After I/O starts, control returns to user program without waiting
for I/O completion.
q System call – request to the operating system to allow user
to wait for I/O completion.
q Device-status table contains entry for each I/O device
indicating its type, address, and state.
q Operating system indexes into I/O device table to determine
device status and to modify table entry to include interrupt.
Operating System Concepts – 7 th Edition 1.19 Silberschatz, Galvin and Gagne
20. Two I/O Methods
Synchronous Asynchronous
Operating System Concepts – 7 th Edition 1.20 Silberschatz, Galvin and Gagne
22. Direct Memory Access Structure
s Stands for "Direct Memory Access." A feature of modern
computers and microprocessors that allows certain hardware
subsystems within the computer to access system memory for
reading and/or writing independently of the central processing
unit.
s DMA is a method of transferring data from the computer's RAM to
another part of the computer without processing it using the CPU.
While most data that is input or output from your computer is
processed by the CPU, some data does not require processing,
or can be processed by another device. In these situations, DMA
can save processing time and is a more efficient way to move
data from the computer's memory to other devices.
Operating System Concepts – 7 th Edition 1.22 Silberschatz, Galvin and Gagne
23. DMA: Example
Many hardware systems use DMA including disk
drive controllers, graphics cards, network cards
and sound cards.
s Sound card may need to access data stored in the
computer's RAM, but since it can process the data
itself, it may use DMA to bypass the CPU.
s Video cards that support DMA can also access
the system memory and process graphics without
needing the CPU.
Operating System Concepts – 7 th Edition 1.23 Silberschatz, Galvin and Gagne
24. Storage Structure
s Main memory – only large storage media that the CPU can access
directly.
s Secondary storage – extension of main memory that provides large
nonvolatile storage capacity.
s Magnetic disks – rigid metal or glass platters covered with magnetic
recording material
q Disk surface is logically divided into tracks, which are
subdivided into sectors.
q The disk controller determines the logical interaction between
the device and the computer.
Operating System Concepts – 7 th Edition 1.24 Silberschatz, Galvin and Gagne
25. Storage Hierarchy
s Storage systems organized in hierarchy.
q Speed
q Cost
q Volatility
s Caching – copying information into faster storage system; main
memory can be viewed as a last cache for secondary storage.
Operating System Concepts – 7 th Edition 1.25 Silberschatz, Galvin and Gagne
27. Caching
s Information in use copied from slower to faster storage temporarily
s Faster storage (cache) checked first to determine if information is
there
q If it is, information used directly from the cache (fast)
q If not, data copied to cache and used there
s Cache smaller than storage being cached
q Cache management important design problem
q Cache size and replacement policy
Operating System Concepts – 7 th Edition 1.27 Silberschatz, Galvin and Gagne
28. Performance of Various Levels of Storage
s Movement between levels of storage hierarchy can be explicit or
implicit
Operating System Concepts – 7 th Edition 1.28 Silberschatz, Galvin and Gagne
29. Migration of Integer A from Disk to
Register
s Multitasking environments must be careful to use most recent
value, no matter where it is stored in the storage hierarchy
s Multiprocessor environment must provide cache coherency in
hardware such that all CPUs have the most recent value in their
cache
s Distributed environment situation even more complex
q Several copies of a datum can exist
Operating System Concepts – 7 th Edition 1.29 Silberschatz, Galvin and Gagne
30. Operating System Structure
s Multiprogramming needed for efficiency
q Single user cannot keep CPU and I/O devices busy at all times
q Multiprogramming organizes jobs (code and data) so CPU always has
one to execute
q A subset of total jobs in system is kept in memory
q One job selected and run via job scheduling
q When it has to wait (for I/O for example), OS switches to another job
s Timesharing (multitasking) is logical extension in which CPU switches
jobs so frequently that users can interact with each job while it is running,
creating interactive computing
q Response time should be < 1 second
q Each user has at least one program executing in memory process
q If several jobs ready to run at the same time CPU scheduling
q If processes don’t fit in memory, swapping moves them in and out to
run
q Virtual memory allows execution of processes not completely in
memory
Operating System Concepts – 7 th Edition 1.30 Silberschatz, Galvin and Gagne
31. Memory Layout for Multiprogrammed
System
Operating System Concepts – 7 th Edition 1.31 Silberschatz, Galvin and Gagne
32. Operating-System Operations
s Interrupt driven by hardware
s Software error or request creates exception or trap
q Division by zero, request for operating system service
s Other process problems include infinite loop, processes modifying
each other or the operating system
s Dual-mode operation allows OS to protect itself and other system
components
q User mode and kernel mode
q Mode bit provided by hardware
Provides ability to distinguish when system is running user
code or kernel code
Some instructions designated as privileged, only
executable in kernel mode
System call changes mode to kernel, return from call resets
it to user
Operating System Concepts – 7 th Edition 1.32 Silberschatz, Galvin and Gagne
33. Transition from User to Kernel Mode
s Timer to prevent infinite loop / process hogging resources
q Set interrupt after specific period
q Operating system decrements counter
q When counter zero generate an interrupt
q Set up before scheduling process to regain control or terminate
program that exceeds allotted time
Operating System Concepts – 7 th Edition 1.33 Silberschatz, Galvin and Gagne
34. Process Management
s A process is a program in execution. It is a unit of work within the system.
Program is a passive entity, process is an active entity.
s Process needs resources to accomplish its task
q CPU, memory, I/O, files
q Initialization data
s Process termination requires reclaim of any reusable resources
s Single-threaded process has one program counter specifying location of
next instruction to execute
q Process executes instructions sequentially, one at a time, until
completion
s Multi-threaded process has one program counter per thread
s Typically system has many processes, some user, some operating system
running concurrently on one or more CPUs
q Concurrency by multiplexing the CPUs among the processes / threads
Operating System Concepts – 7 th Edition 1.34 Silberschatz, Galvin and Gagne
35. Process Management Activities
The operating system is responsible for the following activities in
connection with process management:
s Creating and deleting both user and system processes
s Suspending and resuming processes
s Providing mechanisms for process synchronization
s Providing mechanisms for process communication
s Providing mechanisms for deadlock handling
Operating System Concepts – 7 th Edition 1.35 Silberschatz, Galvin and Gagne
36. Memory Management
s All data in memory before and after processing
s All instructions in memory in order to execute
s Memory management determines what is in memory when
q Optimizing CPU utilization and computer response to users
s Memory management activities
q Keeping track of which parts of memory are currently being
used and by whom
q Deciding which processes (or parts thereof) and data to move
into and out of memory
q Allocating and deallocating memory space as needed
Operating System Concepts – 7 th Edition 1.36 Silberschatz, Galvin and Gagne
37. Storage Management
s OS provides uniform, logical view of information storage
q Abstracts physical properties to logical storage unit - file
q Each medium is controlled by device (i.e., disk drive, tape drive)
Varying properties include access speed, capacity, data-
transfer rate, access method (sequential or random)
s File-System management
q Files usually organized into directories
q Access control on most systems to determine who can access
what
q OS activities include
Creating and deleting files and directories
Primitives to manipulate files and dirs
Mapping files onto secondary storage
Backup files onto stable (non-volatile) storage media
Operating System Concepts – 7 th Edition 1.37 Silberschatz, Galvin and Gagne
38. Mass-Storage Management
s 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.
s Proper management is of central importance
s Entire speed of computer operation hinges on disk subsystem and its
algorithms
s OS activities
q Free-space management
q Storage allocation
q Disk scheduling
s Some storage need not be fast
q Tertiary storage includes optical storage, magnetic tape
q Still must be managed
q Varies between WORM (write-once, read-many-times) and RW (read-
write)
Operating System Concepts – 7 th Edition 1.38 Silberschatz, Galvin and Gagne
39. I/O Subsystem
s One purpose of OS is to hide peculiarities of hardware devices
from the user
s I/O subsystem responsible for
Memory management of I/O including
q buffering (storing data temporarily while it is being transferred),
q caching (storing parts of data in faster storage for performance)
q spooling (the overlapping of output of one job with input of
other jobs)
General device-driver interface
q Drivers for specific hardware devices
Operating System Concepts – 7 th Edition 1.39 Silberschatz, Galvin and Gagne
40. Protection and Security
s Protection – any mechanism for controlling access of processes
or users to resources defined by the OS
s Security – defense of the system against internal and external
attacks
q Huge range, including denial-of-service, worms, viruses,
identity theft
s Systems generally first distinguish among users, to determine who
can do what
q User identities (user IDs, security IDs) include name and
associated number, one per user
q User ID then associated with all files, processes of that user to
determine access control
q Group identifier (group ID) allows set of users to be defined
and controls managed, then also associated with each process,
file
q Privilege escalation allows user to change to effective ID
with more rights
Operating System Concepts – 7 th Edition 1.40 Silberschatz, Galvin and Gagne
41. Computing Environments
s Traditional computer
q Blurring over time
q Office environment
PCs connected to a network, terminals attached to
mainframe or minicomputers providing batch and
timesharing
Now portals allowing networked and remote systems
access to same resources
q Home networks
Used to be single system, then modems
Now firewalled, networked
Operating System Concepts – 7 th Edition 1.41 Silberschatz, Galvin and Gagne
42. Computing Environments (Cont.)
s Client-Server Computing
q Dumb terminals supplanted by smart PCs
q Many systems now servers, responding to requests generated by
clients
Compute-server provides an interface to client to request
services (i.e. database)
File-server provides interface for clients to store and retrieve
files
Operating System Concepts – 7 th Edition 1.42 Silberschatz, Galvin and Gagne
43. Peer-to-Peer Computing
s Another model of distributed system
s P2P does not distinguish clients and servers
q Instead all nodes are considered peers
q May each act as client, server or both
q 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
Operating System Concepts – 7 th Edition 1.43 Silberschatz, Galvin and Gagne
44. Web-Based Computing
s Web has become ubiquitous
s PCs most widespread devices
s More devices becoming networked to allow web access
s New category of devices to manage web traffic among similar
servers: load balancers
s Use of operating systems like Windows 95, client-side, have
evolved into Linux and Windows XP, which can be clients and
servers
Operating System Concepts – 7 th Edition 1.44 Silberschatz, Galvin and Gagne