Week 4 Flashcards
What is the Octal System?
Base 8
symbols: 0,1,2,3,4,5,6,7
4096 512 64 8 1
8^4 8^3 8^2 8^1 8^0
What is the Binary System?
Base 10
10000 1000 100 10 1
10^4 10^3 10^2 10^1 10^0
What is the Hexadecimal System?
Base 16
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
65536 4096 256 16 1
16^4 16^3 16^2 16^1 16^0
What is the purpose of memory?
Stores both code and data
Memory is divided into units of 1 byte (8 bits)
Memory with 2^n addressable units requires n-bit addresses
8 bits = 256 addresses
32 bit = 2^32 addresses (roughly 4gb)
What is the CPU (Central Processing Unit)
Controls the execution of instructions
What are Registers (hint: memory locations)?
Small, fast memory locations within CPU
What is the purpose of General Purpose Registers?
Data storage, address calculations and arithmetic operations
What is the purpose of Special Purpose Registers?
One that has a specific control or data handling task to carry out
What is the Stack Pointer?
Points to the top of the stack
What is the Base Pointer (hint: current frame)?
Points to the start (base) of the current frame
What is the Link Register (LR) (hint: function completion)?
Stores return address for after function completion
What is a Program Counter (PC)?
Stores the address of the next instruction to be executed
What is the Arithmetic Logic Unit (ALU)?
The ALU handles arithmetic and logical operations
What is the Status Register (hint: contains)?
Contains status and mode bits
What are Assembly Languages?
Simple Instructions
Difficult programming language
What is Branching (Branch Instructions)?
Branch instructions will “jump” to a different instruction
They do so by changing the program counter
What is Temporal Locality?
Items accessed recently are likely to be accessed again soon
If you want to discard data, start with the one that has not been requested in a long time
What is Spatial Locality?
Items located near each other in memory are likely to be accessed within a short period of time
Most programs exhibit spatial location
Copy additional memory locations into the cache
What are the 2 outcomes of a memory request?
Cache hit
Cache miss
What is a Cache Hit?
Cache contains the data (faster data return)
What is a Cache Miss?
Cache does not contain requested data - first read from memory
What are the 3 Cache Designs?
Direct Mapping
Fully-associative Mapping
Set-associative Mapping
What is a Direct-Mapped Cache?
Each block of main memory maps to one unique cache line
What are the pros and cons of a Direct-Mapped Cache?
Pros:
Simple, easy to implement and search
Cons:
Inefficient use of the cache space
What is a Fully-Associative Cache?
Each block of main memory can map to any line of the cache
What are the pros and cons of a Fully-Associative Cache?
Pros:
Flexible
Cons:
Takes a long time to search
What is a Set-Associative Cache?
Cache divided into N cache sets
Each cache set consists of S lines
Each block of main memory maps to one unique cache set
What are the 2 options with dealing with a Write Hit?
Write-Back - initially write only to cache, write into memory if being replaced
Write-Through - Write into both cache and memory
What are the pros and cons of Write-Back?
Pros:
Fast writes
Cons:
Mechanism for cache coherence
What are the pros and cons of Write-Through?
Pros:
Consistency between the cache and memory
Cons:
Slow writes
What are the 2 options with dealing with a Write-Miss?
Write around - write into memory only
Write allocate - fetch from memory and write into cache
What are the pros and cons of Write around?
Pros:
Avoids unnecessary cache access and cache pollution
Cons:
Does not utilise temporal locality
What are the pros and cons of Write allocate?
Pros:
Exploits spatial and temporal locality
Cons:
Potential unnecessary cache access and cache pollution
What is Virtual Memory?
Use disk storage as if it was main memory
analogy: Main memory is the cache of the disk
What is Demand Paging?
Only load a page when there is a request for it
What are the pros and cons of Demand Paging?
Pros:
More processes can be loaded into memory
Cons:
CPU spends too much time swapping pages - Thrashing
What is Pre-Paging?
Guess which pages will be requested and pre-load them
What are the pros and cons of Pre-Paging?
Pros:
Less overhead when page predictions are accurate
Cons:
Resources wasted on loading unused pages