Computer System Overview: 1 Spring 2015
Computer System Overview: 1 Spring 2015
Computer System Overview: 1 Spring 2015
Spring 2015
Introduction
Computer system:
Hardware
Software
Operating System (system software)
Applications
Hardware
Processor
The processor (CPU) is the brain of the system.
It fetches instructions from memory and executes them.
Main memory
Volatile storage for programs and data
I/O modules
Allow data to be moved to and from the computer and
I/O devices.
System bus
The pathway for data and instructions to move between
the processor, memory, and I/O modules.
3
Hardware Configuration
CPU
System
Bus
I/O Modules
Input /
Output
Devices
Main
Memory
The system bus connects the CPU, I/O Modules, and Main Memory
4
Other supporting chips co-exist with the CPU to provide such things as
encoding/decoding video (codecs), or for encryption and security.
Instruction Cycle
A program is a set of instructions to be executed in
memory.
A simplified view of the processor consists of two phases,
fetch and execute.
The fetch step retrieves an instruction from memory.
The execute step carries out the instruction.
After each fetch, the program counter (PC) is normally
incremented so that it is ready to fetch the next instruction.
The fetched instruction loads into the IR.
The instruction in the IR is then decoded to determine
what the processor should do.
8
Processing
Main Memory
Execute
Fetch Instruction
CPU
Instruction Execution
Instruction Actions
Processor-memory
transfer data between processor and memory
Processor-I/O
data transferred to or from a peripheral device
Data processing
arithmetic or logic operation on data
Control
alter sequence of execution (branch instruction)
11
3 4
Opcode
Data (integer):
0
1
Sign
Magnitude
15
Address
15
12
Instruction Format
Notice that a machine will have a size for instructions like
16-bit or 32-bit based on its architecture.
This limits the size of an instruction.
If part of the instruction is an opcode and part an address,
then the portion set aside for the opcode determines how
many opcodes there can be, and the portion set aside for the
address determines how much memory is directly
addressable.
For example, if 4 bit opcodes, then only 16 opcodes are
possible (which isnt many).
13
Example Opcodes
0001 = Load AC from memory
0010 = Store AC to memory
0101 = Add to AC from memory
AC is the Accumulator register. It is a register
commonly used for loading and storing values to memory
and doing arithmetic.
14
15
Interrupts
Interrupts are a mechanism for interrupting the processors
execution in order to do something else.
Common types of interrupts are:
Program instruction exceptions:
arithmetic overflow
division by zero
execute illegal instruction
reference outside users memory space
Timer system timer
I/O completion of I/O or I/O error.
Hardware failure power failure or memory parity
error.
16
17
Interrupts
Interrupts improve processor utilization by notifying the
processor of an event versus making the processor wait.
This frees the processor to do other processing.
Without interrupts, the processor would have to keep
checking to see if an event has occurred.
With interrupts, the processor is free to do something else
until the event occurs, at which time it will be notified.
18
Interrupts
An example of using interrupts to improve processor
utilization is in processing I/O commands.
Most I/O devices are much slower than the processor.
Rather than have the processor wait for an I/O to finish,
the processor could continue processing and be interrupted
when an I/O finishes. This is much more efficient.
The next slide illustrates this technique:
19
20
Time
Processor
Wait
I/O Operation
Interrupt
2a
Interrupt handler
2b
Processor
Wait
I/O Operation
Interrupt
3a
5
I/O Operation
I/O Operation
Interrupt handler
3b
3
Without interrupts
With interrupts
21
Interrupt Cycle
22
Interrupt Cycle
After instruction execution, the processor checks to see if
an interrupt has occurred.
If so, it executes an Interrupt Handler, which is code that
processes the interrupt.
The processor must save system state (the registers) on the
stack before executing the interrupt handler, or the
interrupt handler may be written to preserve system state.
The processor may have to determine which interrupt
handler to run for this interrupt.
23
24
Interrupt Processing
Memory
Stack
Interrupt
handler
CPU
Program
26
Multiple Interrupts
It is possible for an interrupt to occur while another
interrupt is being processed.
Two solutions:
Disable interrupts while processing an interrupt.
Disadvantage: high-priority interrupt may wait too
long and lose data while waiting for a low-priority
interrupt to finish.
Interrupt Priorities: lets high-priority interrupt execute
when processing low-priority interrupt. Interrupts lowpriority interrupt just like interrupting a program.
27
28
29
Memory Hierarchies
Memory on a computer system is composed of a hierarchy
of differing kinds of memory.
Generally these tradeoffs apply across the spectrum of
memory technologies:
Faster access time, greater cost per bit
Greater capacity, smaller cost per bit
Greater capacity, slower access time.
30
Memory Hierarchies
The computer system designer wants greater capacity for
larger programs and reduced cost per bit, but also wants
fast access times which requires lower capacity memories
having higher cost.
Therefore, a single memory solution isnt appropriate, that
is why a hierarchy of memory types is used.
31
32
33
Cache Memory
Today most processors can execute instructions faster than
they can be retrieved from main memory.
Cache memory sits between the processor and main
memory and exploits the principle of locality of
reference by keeping a working set of instructions and
data in its small but high-speed memory.
34
35
Cache Principles
When the processor fetches an instruction, a block is read
into the cache.
When the next instruction is fetched, there is a high
probability it is contained in the same cache block, which
can be accessed quickly.
A cache consists of slots (or lines) of K words.
Main memory is divided into blocks of K words.
If main memory is size 2N words, then there are M=2N/K
blocks of memory.
If C is the number of cache slots, C << M.
Cache lines are addressed by a tag, which is some number
of high-order bits of the address.
36
37
Cache Example
The hit ratio is the fraction of memory accesses that are
found in the cache.
Suppose memory has an access time of 1s and the cache
has an access time of .1s.
If the hit ratio is 95%, then the average access time is:
(0.95)(0.1 s) + (0.05)(0.1 s + 1 s) = 0.15 s
Thus, the access time is much closer to the cache rate than
the memory rate.
38
39
Cache Design
Considerations:
Cache size how big is the entire cache (a small cache still
offers a lot of improvement).
Block size how big is a block? Needs to be around the
size of a cluster.
Mapping function where to put a new block?
Replacement algorithm how to replace a block?
Write policy when to write a block back to main
memory?
40
44
45
47
End of Slides
48