Computer System Structures Operating Systems are Interrupt-driven by dblock21

VIEWS: 0 PAGES: 2

									Operating System Theory, Section 2:                                               What happens is an INTERRUPT. That is a request from the software or
                                                                                  hardware to the OS to perform some task. Almost all Operating Systems work in
                        Computer System Structures                                this fashion, and hence we say that
                                                                                                 Operating Systems are Interrupt-driven
(This corresponds to Chapter 2 of the text book).
In order to study Operating System theory, we must have an understanding of how   Interrupts
(modern) computers works. The hardware of a computer must provide certain
facilities so that Operating System can get the computer to operate               Different computer systems and Operating Systems implement interrupts, but
 1. Efficiently                                                                     some features are standard:

 2. Safely (reliably)                                                              • Interrupts transfers control to the Interrupt Service Routine. This is done via
                                                                                     the interrupt vector, an array containing address of service routines.
To see how this happens we must study
                                                                                   • The address if the interrupted instruction must be saved so that it can resume
 • Computer System Operation (today)                                                 at a later time.
 • Input/Output (I/O) mechanisms (today)
                                                                                   • While one interrupt is begin processed, incoming interrupts must be disabled
 • Storage structure and hierarchy                                                   – this is to prevent interrupt loss.
 • Hardware (Memory, I/O and CPU) protection                                      Often we refer to a software-generated interrupts as a trap.

 CS208, 13 Sep 2002.                                                        1      CS208, 13 Sep 2002.                                                           3




Computer System Structure                                                         Input/Output (I/0) Structure

Modern computer systems consist of
                                                                                  Computer systems consist of a CPU and memory connected to peripheral devices
 • CPU                                                                            via a bus. Each group of devices has a controler responsible for moving data from
                                                                                  the peripheral device on its local storage buffer.
 • Devices and Device Controllers
                                                                                  (E.g., if a lan-based PC might have a Network Interface Controller to deal with
 • System Bus                                                                     the network, but only one disk controller to deal with, say, two hard-drives and a
 • Memory and Memory Controller                                                   CD drive.)
                                                                                  This size of the buffer depends on the device. For a disk it is a multiple of 512
Bootstrapping: When a computer start running a bootstrap program must             bytes – the size of a sector.
run. This initialises the registers and devices and loads the Operating System
                                                                                  The controller also has registers where the CPU can store instructions for the
kernel. The first process is started (called init on Unix systems). And then the
                                                                                  controller.
Operating System...

... waits for something to happen.




 CS208, 13 Sep 2002.                                                        2      CS208, 13 Sep 2002.                                                           4
I/O Interrupts

Suppose a process wants to read some data from a disk. The CPU must load the
device controller’s registers with the appropriate instruction.
The controller examines the register contents and begins to load the data into its
buffers.
When it is ready, it sends the CPU an interrupt.
The I/O operation may be completed in one of two manners:


Synchronous V Asynchronous I/0

Synchronous: The CPU sends a request to the device controller. The OS then
waits until the data transfer is complete.
Advantage: Simple and so easy to implement.
Disadvantage: Inefficient – the CPU is idle during I/O operations.


 CS208, 13 Sep 2002.                                                           5




Asynchronous: After the I/O request is made the OS continues to process user
programs without waiting for I/O completion.
Advantage: More efficient use of CPU.
Disadvantage: Requires more sophistication on the part of the hard-ware and the
OS.
Asynchronous I/O is the more popular on modern computers. It is managed as
follows:
 • The system maintains a Device Status Table. Each table entry contains
   1. The device type      2. Address    3. The device State.
   The possible states are
    1. idle: waiting for a request
    2. busy: processing an I/O request
 • The OS maintains a queue of outstanding I/O requests. This is because, with
   Async. I/O, a request can be made of a device while it is busy with another
   operation



 CS208, 13 Sep 2002.                                                           6

								
To top