Computer System Overview PDF
Computer System Overview PDF
Systems:
Internals Chapter 1
and Design
Principles Computer System
Overview
Eighth Edition
By William Stallings
Operating System
Exploits
the hardware resources of one or more
processors
Provides a set of services to system users
Manages secondary memory and I/O devices
Basic Elements
I/O
Processor Modules
Main System
Memory Bus
Processor
Referred to as
the Central
Processing Unit
(CPU)
Main Memory
Volatile
Provides for
communication among
processors, main memory,
and I/O modules
CPU Main Memory
0
System 1
2
PC MAR Bus
Instruction
Instruction
Instruction
IR MBR
I/O AR
Data
Execution
unit Data
I/O BR Data
Data
PC = Program counter
Buffers IR = Instruction register
MAR = Memory address register
MBR = Memory buffer register
I/O AR = Input/output address register
I/O BR = Input/output buffer register
processor reads
processor executes
(fetches) instructions
each instruction
from memory
Two steps
Fetch Stage Execute Stage
1 4 1
I/O
Command
Figure 1.5a WRITE
5
WRITE
2a
END
2
Flow of Control 2b
WRITE WRITE
Without 3a
Interrupts 3
3b
WRITE WRITE
1 4 1 4 1
I/O I/O
Command Command
WRITE WRITE WRITE
5
2a
END
Figure 1.5b
2
Interrupt
2
2b Handler
3 3
3b
4 1 4 1 4
Figure 1.5c
2a
END
2
Interrupt Interrupt
2b Handler Handler
END END
3a
3b
WRITE WRITE
No interrupts (b) Interrupts; short I/O wait (c) Interrupts; long I/O wait
User Program Interrupt Handler
i
Interrupt
occurs here i+1
Interrupts
Disabled
Check for
Fetch next Execute interrupt;
START instruction instruction initiate interrupt
Interrupts
handler
Enabled
HALT
1 1
4 4
I/O operation
I/O operation;
processor waits 2a concurrent with
processor executing
5 5
2b
2
4
I/O operation
4 3a concurrent with
processor executing
I/O operation;
processor waits 5
5 3b
1 1
4 4
5
2
4
4
3 I/O operation
concurrent with
I/O operation; processor executing;
processor waits then processor
waits
5
5
Device controller or
other system hardware
issues an interrupt
Save remainder of
process state
information
Processor finishes
execution of current
instruction
Process interrupt
Processor signals
acknowledgment
of interrupt
Restore process state
information
Processor pushes PSW
and PC onto control
stack
Restore old PSW
and PC
Processor loads new
PC value based on
interrupt
Y Start Y Start
Interrupt General Interrupt General
Service Registers Service Registers
Y + L Return Routine T Y + L Return Routine T–M
Stack Stack
Pointer Pointer
Processor Processor
T–M T
N User's N User's
N+1 N+1
Program Program
Main Main
Memory Memory
An interrupt occurs
while another interrupt Two approaches:
is being processed
• e.g. receiving data from • disable interrupts while
a communications line an interrupt is being
and printing results at processed
the same time • use a priority scheme
Interrupt
User Program Handler X
Interrupt
Handler Y
Interrupt
User Program Handler X
Interrupt
Handler Y
15
0 t=
t =1
t = 25
t= t = 25 Disk
40 interrupt service routine
t=
35
Greater capacity
Faster = smaller cost per
access time bit
= greater Greater
cost per bit capacity =
slower access
speed
The Memory Hierarchy
Going down the Inb
g-
Re r s
i st
e
e
hierarchy:
ch
Me o a r d Ca
mo in
ry M a or y
m
Me
sk
Ou Di
t tic
Sto boar ne OM
increasing capacity B
decreasing frequency of
access to the memory by
the processor
Figure 1.14 The Memory Hierarchy
T1 + T2
T2
T1
0 1
Fraction of accesses involving only Level 1 (Hit ratio)
Also referred to
as auxiliary
memory
• external
• nonvolatile
• used to store
program and data
files
Invisible to the OS
Interacts with other memory management hardware
Processor must access memory at least once per instruction
cycle
Processor execution is limited by memory cycle time
Exploit the principle of locality with a small, fast memory
Block Transfer
Word Transfer
Fastest Fast
Less Slow
fast
C-1
Block Length
(K Words)
(a) Cache
Block M – 1
2n - 1
Word
Length
(b) Main memory
RA - read address
Receive address
RA from CPU
Load main
Deliver RA word
memory block
to CPU
into cache slot
DONE
number of
cache block size
levels
Main
categories
are:
write mapping
policy function
replacement
algorithm
Cache and Block Size
Cache Size
Block
Size
the unit of data
small caches have
exchanged
significant impact
between cache and
on performance
main memory
Mapping Function
∗ Determines which cache
location the block will occupy
when one block is read in,
another may have to be
replaced
Two constraints affect
design:
the more flexible the
mapping function, the
more complex is the
circuitry required to
search the cache
Replacement Algorithm
Least Recently Used (LRU) Algorithm
effective strategy is to replace a block that has been
in the cache the longest with no references to it
hardware mechanisms are needed to identify the
least recently used block
chooses which block to replace when a new block is
to be loaded into the cache
Write Policy
System Bus
Main I/O
Memory I/O Adapter
Subsystem
I/O
Adapter
I/O
Adapter
32 kB 32 kB 32 kB 32 kB 32 kB 32 kB 32 kB 32 kB 32 kB 32 kB 32 kB 32 kB
L1-I L1-D L1-I L1-D L1-I L1-D L1-I L1-D L1-I L1-D L1-I L1-D
12 MB
L3 Cache