Memory
Memory Hierarchies
Speed for each, price is higher the higher it is on the list
Register
- On CPU
- 1 clock cycle
cache
Level 1
4 clock cycles
Level 2
10 clock cycles
Level 3
75 clock cycles
Main memory
100s of clock cycles
Magnetic and solid state
1000s of clock cycles
External storage
10,000s clock cycles
How do i make my memory faster?
Access time
Time for operation to be performed
Cycle time
Time for next cycle to begin
How does the memory hierarchy work?
- Processor requests a virtual address
- Memory Management Unit (MMU), will then translate the virtual address into a real address and request it from Cache
- If not found in Cache, request is made to the Main Memory
- If not found in Main Memory, request is made to the Disk or equivalent
- Data is then sent up or down the stack

What advantage does virtual addressing bring?
It allows for the Processor to abstract away from the messy reality
Cache

Where is cache Located?
Between main memory and the processor
What does cache store?
Frequently used data
What is a cache hit?
When the data is found in cache
What is a cache miss?
When the data is not found in cache
What is the average access time for cache equation?
(hit time + miss rate) * sum of corresponding access times
What data is loaded into cache?
When data is loaded, all surrounding data is loaded into cache because it is more likely to be needed
What is this known as?
Data locality
Program locality
Data must be the same on both main memory and cache
What is Write through?
This is where when data is changed in cache it is also changed in main memory at the same time
Problem
More traffic
What is Write Back/Deferred?
Changed in main memory when the line is about to be replaced
Problem
Requires a dirty flag to keep note of what has been changed
Main memory
SRAM
What does SRAM stand for?
Static RAM
How much faster is it than DRAM?
10x
Why is SRAM faster than DRAM?
Because SRAM does not need to be refreshed
What is SRAM made up of?
Flip Flops, Transistors, Inverters
What are the states of SRAM?
Stable i.e. 1 or 0
Unstable nether a 1 or a 0
Why is it so expensive?
Because memory cells take up a-lot of space
DRAM
What does DRAM stand for?
Dynamic RAM
What components does DRAM use?
Capasitor
Transistor
What is refreshing?
Capacitors charge will leak
So its charge must be refreshed every few nano seconds
This slows it down
Why choose DRAM over SRAM?
Cheaper
Larger
How would I increase memory bandwidth
- wider memory
- faster memory
Error-correction
What is error correction?
Sometimes memory has error correction code attached to them, which allows them to correct errors, this is done with parity bits
What is ECC
Error Correction Code
Where is it typically found
servers
NOT home pc's
ECCs are also used for what?
data integrity verification
What is a parity check?
Where you check if something has been changed from even num of 1s to a odd number of 1s.
What is a parity bit?
What is a problem with parity bits?
If two bits are false
Memory & OS
What is memory divided up into?
- Code segment
- Data segment
- Stack
- Heap
What is a stack?
Lets you buffer objects with a LIFO, uses push and pop methods
What is a heap?
Used to store:
- Structures that are variable in length (size varies dynamically, like strings)
- Structures that are allocated dynamically (like records)
- Structures that are created and must be kept even after the function returns
What is a problem with heaps?
Allocation and free space management, there tends to be gaps where there is no data when data is removed
When the OS attempts to do this it is called 'de-allocation' or the 'garbage collection'
Secondary memory
What requirements must secondary storage meet?
- Possible to store large amounts of data
- none volatile
- Multiple programs must be-able to access the data at the same time
Describe the following
Hard disk
A read write head will move in and out along each disk, the disks will spin.
Data can be read/written on both sides of a disk.
The surface is divided up into tracks which are divided into sectors, a cluster is a group of sectors.
Compact disks
Laser burns holes into a glass master, forming pits and lands.
When a laser is reflected on these pits and lands, the computer can interpret them as 1's or 0's
CD Formats
DVDs





