Introduction - Lecture 1
Introduction - Lecture 1
These slides are adapted from Operating Systems Concepts textbook, 8th edition,
Silberscatz, Galvin, Gagne.
What is an Operating System?
• A program that acts as an intermediary between a user of a computer
and the computer hardware.
• Operating system goals:
– Execute user programs and make solving user problems easier.
– Make the computer system convenient to use.
• Use the computer hardware in an efficient manner.
Operating System Definition
• OS is a resource allocator
– Manages all resources (CPU time, memory space, file space...)
– Decides between conflicting requests for efficient and fair resource use
• OS is a control program
– Controls execution of programs to prevent errors and improper use of
the computer. It is especially concerned with the operation and control
of I/O devices.
Operating System Definition (Cont.)
• No universally accepted definition
• The fundamental goal of computer systems is to execute user programs
and make solving user problems easier. For this, hardware is
constructed for which application programs are developed. The
common functions of controlling and allocating resources are then
brought together into “Operating System”.
• “Everything a vendor ships when you order an operating system” is
good approximation
– But varies wildly
• “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
Computer System Organization
• Computer-system operation
– One or more CPUs, device controllers connect through common bus providing
access to shared memory
– Concurrent execution of CPUs and devices competing for memory cycles
Computer-System Operation
• I/O devices and the CPU can execute concurrently.
• Each device controller is in charge of a particular device type.
• Each device controller has a local buffer.
• CPU moves data from/to main memory to/from local buffers
• I/O is from the device to local buffer of controller.
• Device controller informs CPU that it has finished its operation by causing an
interrupt.
• To ensure orderly access to the shared memory, a memory controller is provided
whose function is to synchronize access to memory.
Common Functions of Interrupts
• Interrupt transfers control to the interrupt service routine generally, through the
interrupt vector, which contains the addresses of all the service routines.
• Interrupt architecture must save the address of the interrupted instruction (on the
stack)
• Incoming interrupts are disabled while another interrupt is being processed to
prevent a lost interrupt.
• A trap is a software-generated interrupt caused either by an error or a user
request.
• An operating system is interrupt driven.
Interrupt Handling
• 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
• Interrupts must be handled quickly
– A table of pointers (vectors) to interrupts routines can be used
– Interrupt vector addresses is then indexed by a unique device
number, given with the interrupt request, to provide the address of
the interrupt service routine for the interrupting device.
• After the interrupt is serviced, the saved return address is loaded into the
program counter and the interrupted computation resumes.
Interrupt Timeline
I/O Structure
• Each device controlller is in charge of a specific type of device. Depending on the
controller, there may be more than one attached device (eg. SCSI)
• Device controller maintains some local buffer storage and a set of special purpose
registers. Controller moves the data between the peripheral devices and its local buffer
storage.
• OSs have a device driver for each device controller. Device driver presents a uniform
interface to the device to the rest of OS.
• To do I/O
– Device driver loads the appropriate registers within the device controller.
– Device controller examines the contents of these registers to determine action.
– Controller starts the transfer from the device to its local buffer
– Once the transfer is complete, the controller informs the device driver via an
interrupt.
– The device driver then returns control to the operating system, possibly returning the
data or a pointer to data if the operation was a read.
I/O Structure
• After I/O starts, control returns to user 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.
Two I/O Methods
Synchronous Asynchronous
Device-Status Table
Performance of Various Levels of Storage