Transcript Lecture 1

Contact Information






Office: 225 Neville Hall
Office Hours: Monday and Wednesday 12:00-1:00 and by
appointment.
E-Mail: [email protected]
Phone: 581-3967
Textbook: Operating System Concepts, 7th edition,
Silberschatz, Galvin, and Gagne.
URL: http://umcs.maine.edu/~dickens/COS431/COS431.html
Components of a Computer System

A computer system consists of
 hardware
 system programs
 application programs
System Components

Hardware:

Physical Devices:



Memory, CPU, I/O devices….
Micro-architecture: Executes machine-level
instructions. Hardware or firmware (microcode).
Machine language: Hardware and instructions
visible to an assembly language program.
Components of a Computer System

Operating System:

Hides complexity of hardware and
provides simplified set of instructions
(API, Application Program Interface).
Components of a Computer System

System programs:


Generally execute in user mode. (Why?)
Command interpreter (shell), compilers,
editors, …..
So What is an Operating System?

It is an extended machine


Hides the messy details.
Presents user with a virtual machine, easier to use


Don’t want to program I/O devices, handle interrupts, etc.
It is a resource manager (and scheduler)

Each program gets time with the resource


E.g., CPU, I/O devices, memory
Each program gets space on the resource

E.g., Disk space.
So What is an Operating System?

Control Program

Manages the execution of user applications to prevent errors and
improper use of system.



Program A should not be able to access memory of an unaffiliated
program B.
No one user should be able to starve OS and/or other users of system
resources (e.g., CPU).
No user should be able to trash I/O devices (deliberately or by error).
Computer Hardware Review
Monitor
Bus

Components of a simple personal computer

Special registers:



Program counter.
Stack pointer.
Process Status Word (PSW).


CPU and other devices can run concurrently.
When device needs attention, it issues an interrupt.




Character transferred from keyboard to system buffer.
Disk read/write completed.
Page fault.
User programs generate interrupts when making
system calls.


Trap instruction.
Generally termed software interrupt.
Interrupts

Operating systems are interrupt-driven.



Perform action, such as executing a process, then wait until
receives an interrupt.
Makes developing an operating system a very complex task.
When an interrupt is generated the CPU stops what it
is doing and execution is transferred to the
appropriate interrupt handler.

Addresses of interrupt handlers are found in the interrupt
vector.


Table of addresses
Each device has a particular offset within the table.
Interrupts



The state of the interrupted computation must be
saved before interrupt can be processed.
This state is restored when the OS returns from the
interrupt handler.
Termed a context switch.
I/O Devices


Each type of device has its own controller that accepts and
carries out commands from the operating system.
Because each controller is different, manufacturer provides
device driver for each operating system it supports.

OS talks to device driver.
I/O Operation









Program makes I/O request (e.g., read/write to/from a file).
Device driver loads appropriate controller registers.
Controller reads registers and determines the operation
requested.
Starts data transfer from the device to its local buffer.
When completed, generates an interrupt.
State of currently executing program is saved.
Interrupt handled by the device driver.
Device driver returns control to the OS.
OS restarts suspended program.
(a)
(a)
(b)
Steps in starting an I/O device and getting interrupt
(b) How the CPU is interrupted
Three I/O Methods



Synchronous
Asynchronous
DMA (Direct Memory Access).
Three I/O Methods

Synchronous

Wait instruction idles the CPU until the next interrupt
 Wait loop (contention for memory access).
Generally a bad idea.


After I/O starts, control returns to user program only upon
I/O completion.
I/O Methods

Asynchronous



After I/O starts, control returns to user program without
waiting for I/O completion.
I/O completion signaled by an interrupt.
More complicated than synchronous I/O.
Two of the I/O Methods
Synchronous
Asynchronous
I/O Methods

DMA



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 one interrupt is generated per block, rather than the
one interrupt per byte.
I/O Methods

Asynchronous I/O requires the ability to handle
multiple I/O commands concurrently.


Uses device status table.
Queue waiting requests.
Device-Status Table