Lecture 1: Overview - City University of New York

Download Report

Transcript Lecture 1: Overview - City University of New York

Lecture 2: Review of
Computer Organization
Operating System
Spring 2007
1
Four Elements of a Computer
System

Processor (CPU)


Main Memory



Stores data and programs
RAM - random access memory
I/O Modules



Control the operation of the computer and its data processing
functions.
Auxiliary storage like disk drives, tape drives
Printers, terminals, monitors
System Bus

Provides for transfer of data among processors, main memory, and
I/O modules
2
Computer Organization
MAIN MEMORY
CPU
PC
MAR
IR
MBR
System
Bus
0
1
…
Instruction
Execution
Unit
I/O AR
I/O BR
I/O module
buffer
Instruction
Instruction
…
DATA
DATA
…
n-2
n-1
3
CPU (Processors) Registers

A processor includes a set of registers that
provide a level of memory faster than main
memory.


User-visible Registers
Control and Status Registers
4
User-visible Registers





Many instructions operate on data sitting on working
registers.
Since registers are faster than main memory, it is
better that data be moved to registers before
operating on them.
May be referenced by the machine language that the
processor executes
available to all programs - application programs and
system programs.
Types of registers:


Data registers
Address registers




For
For
For
For
indirect addressing
index register
segment pointer
stack pointer
5
Control and Status Registers







Program Controller (PC) – contains the address of an instruction
to be fetched
Instruction Register (IR) – contains the instruction most recently
fetched
Memory Address Register (MAR)
Memory Buffer Register (MBR)
I/O Address Register (I/O AR)
I/O Buffer Register (I/O BR)
Processor Status Word (PSW)



condition codes or flags
interrupt enable/disable
user/supervisor mode
6
Instruction Cycle
Start
Fetch Cycle
Execute Cycle
Fetch next
instruction
Execute
instruction
Halt
Opcode
Address of Operand
Instruction Format
Sign
magnitude
Integer Format
Sign exponent
magnitude
Floating point Format
7
Actions of CPU
(Types of Instructions)



Processor-Memory Data Transfer
Processor-I/O Data Transfer
Data Processing


Arithmetic or logic operation on data
Control

Alter sequence of execution
8
Interrupts



An interruption of the normal sequence
of execution
Improve processing efficiency
Allows the processor to execute other
instructions while an I/O operation is in
progress
9
Interrupts - Classes of Interrupts

Program







arithmetic overflow or underflow
division by zero
attempt to execute an illegal machine instruction
reference outside user’s memory space
Timer
I/O
Hardware Failure
10
Interrupts –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
11
Interrupt Timeline
12
Interrupts and the Instruction
Cycle
Start
Fetch Cycle
Execute Cycle
Fetch next
instruction
Execute
instruction
Interrupts
Enabled
Check for interrupt
and process interrupt
Interrupts
Disabled
13
Interrupt Cycle



Processor checks for interrupts
If no interrupts, fetch the next instruction for
the current program
If an interrupt is pending, suspend execution
of the current program, and execute the
interrupt handler
14
Program Flow of Control
without and with Interrupts
User Program
I/O Program
(1)
WRITE
(2)
WRITE
(3)
(4)
I/O Command
(5)
END
WRITE
User Program
I/O Program
(4)
(1)
WRITE
(2)
I/O Command
Interrupt Handler
WRITE
(5)
(3)
END
WRITE
No interrupts
Interrupts
15
Simple Interrupt Processing
Hardware
Device controller or other
Hardware generates an interrupt
Software
Save remainder of
process state information
Processor finished
execution of current instruction
Process interrupt
Processor signals
acknowledgement of interrupt
Processor pushes PSW
and PC onto control stack
Processor loads new
PC value based on interrupt
Restore process
state information
Restore old
PSW and PC
16
Multiple Interrupts

Two methods:


Disable other interrupts while processing
one interrupt
Assign priorities to different interrupts.
Interrupts at higher priority can interrupt
lower ones
17
Memory







Registers
Cache
Main memory
Electronic disk
Magnetic disk
Optical disk
Magnetic tapes
volatile
Decreasing cost per bit
Increasing capacity
Increasing access time
nonvolatile
Decreasing frequency of access
of the memory by the processor
18
Performance of Various Levels of
Storage

Movement between levels of storage
hierarchy can be explicit or implicit
19
Caching



Important principle, performed at many levels in a
computer (in hardware, operating system, software)
Information in use copied from slower to faster
storage temporarily
Faster storage (cache) checked first to determine if
information is there


If it is, information used directly from the cache (fast)
If not, data copied to cache and used there
20
Cache




Invisible to operating system
Increase the speed of memory
Processor speed is faster than memory
speed
Contain a portion of main memory
CPU
Word
Transfer
Cache
Block
Transfer
Main
memory
21
Cache Design



Cache size
Block size
Mapping function


Replacement algorithm



Determine which cache location the block will occupy
Determines which block to replace
Least-Recently-Used(LRU) algorithm
Write policy



When the memory write operation takes place
Can occur every time block is updated
Can occur only when block is replaced
22
I/O Communication Techniques



Programmed I/O
Interrupt-Driven I/O
Direct Memory Access (DMA)
23
I/O Communication Techniques



Programmed I/O
Interrupt-Driven I/O
Direct Memory Access (DMA)
24
Programmed I/O




I/O module performs
the action, not the
processor
Sets appropriate bits in
the I/O status register
No interrupts occur
Processor checks status
until operation is
complete
Issue Read
command
to I/O module
CPU->I/O
Read status of
I/O module
I/O -> CPU
Not
ready
Check status
Error
condition
ready
Read word from
I/O -> CPU
I/O module
Write word into
CPU->memory
Main memory
no
Done?
yes
Next instruction
25
I/O Communication Techniques



Programmed I/O
Interrupt-Driven I/O
Direct Memory Access (DMA)
26
Interrupt-Driven I/O




Processor is interrupt
when I/O module
ready to exchange
data
Processor is free to do
other work
No needless waiting
Consumes a lot of
processor time
because every word
read or written passes
through the processor
Issue Read
CPU->I/O
command
Do something
to I/O module
else
Read status of
Interrupt
I/O module I/O -> CPU
Check status
Error
condition
ready
Read word from
I/O -> CPU
I/O module
Write word into
CPU->memory
Main memory
no
Done?
yes
Next instruction
27
I/O Communication Techniques



Programmed I/O
Interrupt-Driven I/O
Direct Memory Access (DMA)
28
Direct Memory Access



Transfer a block of data
directly to or from
memory
An interrupt is sent when
the task is complete
The processor is only
involved at the beginning
and end of the transfer
Issue Read
CPU->DMA
command
Do something
to I/O module
else
Read status of
Interrupt
DMA module DMA -> CPU
Next instruction
29
End of lecture 2
Thank you!
30