Documente Academic
Documente Profesional
Documente Cultură
Computer-System Structure
A general-purpose computer system consists of a
CPU and a number of device controllers that are
connected through a common bus that provides
access to the shared memory.
2.1
2.2
2.3
External Interrupts
An external interrupt is a temporal suspension of a
process caused by an event external to that process
and performed in such a way that the process can
be resumed.
I/O
Timer
Hardware failure
Interrupt Handler
A program that determines nature of the interrupt
and performs whatever actions are needed
Control is transferred to this program
Generally part of the operating system
Instruction Cycle with Interrupts
CPU checks for interrupts after each instruction.
If no interrupts, then fetch next instruction of current
program.
If an interrupt is pending, then suspend execution of
the current program. The processor sends an
acknowledgement signal to the device that issued
the interrupt so that the device can remove its
interrupt signal.
Interrupt architecture saves the address of the
interrupted instruction (and values of other
registers).
Interrupt transfers control to the interrupt service
routine (Interrupt Handler), generally through the
2.4
2.5
Example:
when
input
arrives
from
communication line, it needs to be absorbed
quickly to make room for more input.
Traps
A trap is a software-generated interrupt caused by
an error, for example:
arithmetic overflow/underflow
division by zero
execute illegal instruction
reference outside users memory space
2.6
I/O Structure/Methods
2.7
2.8
2.9
2.10
2.11
Storage Structure
Main memory only large storage media that the
CPU can access directly.
Secondary storage extension of main memory that
provides large nonvolatile storage capacity.
Magnetic disks rigid metal or glass platters
covered with magnetic recording material
Disk surface is logically divided into tracks, which
are subdivided into sectors.
The disk controller determines the logical
interaction between the device and the computer.
2.12
Storage Hierarchy
Storage systems organized in hierarchy.
Speed
Cost
Volatility
Storage-Device Hierarchy
Caching
Use of high-speed memory to hold recentlyaccessed data.
Requires a cache management policy.
Caching introduces another level in storage
hierarchy. This requires data that is simultaneously
stored in more than one level to be consistent.
Dual-Mode
Operation
2.13
2.14
Interrupt/fault
use
r
monit
or
set user mode
Trap instruction is
used to switch to
monitor mode
I/O Protection
All I/O devices need to be protected from
wrongdoing by the users.
All I/O instructions are privileged instructions. Thus
user cannot issue I/O instructions directly. We must
ensure that a user program could never gain control
of the computer in monitor mode (i.e., a user
program that, as part of its execution, stores a new
address in the interrupt vector).
Given the I/O instructions are privileged, how does
the user program perform I/O?
Solution: System Calls (from user programs).
System call the method used by a process to
request action by the operating system:
Usually takes the form of a trap to a specific
location in the interrupt vector. Control passes
through the interrupt vector to a service routine
2.15
2.16
Memory Protection
Must provide memory protection at least for the
interrupt vector and the interrupt service routines.
In general, OS should be protected from user
programs and user programs from each other
as well.
In order to have memory protection, add two
registers that determine the range of legal
addresses a program may access:
Base register holds the smallest legal
physical memory address.
Limit register contains the size of the range
2.17
2.18
CPU Protection
A user program must be prevented from getting
stuck in an infinite loop and never returning control
to the OS. To accomplish this, a timer is used.
A Timer interrupts computer after specified period to
ensure operating system maintains control.
Timer is decremented every clock tick.
When timer reaches the value 0, an interrupt
occurs.
Timer commonly used to implement time sharing.
Time also used to compute the current time.
Load-timer is a privileged instruction.
2.19