lecture 12 Flashcards

Cache Memory, Mapping Algorithms, and the Principle of Locality

1
Q

cache memory (real definition)

A

small fast SRAM-based memory
- managed in automatically in the hardware (NOT SOFTWARE)
- located on CPU
- hold frequently accessed memory blocks in RAM (main memory)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
1
Q

cache (online definition)

A

fast storage buffer that is located in the CPU (central processing unit) of a computer
*also called cache memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

where is cache located?

A

CPU (central processing unit) in your computer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what are blocks?

A

blocks –> equal-sized chunks of main memory that are held in the cache

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

are blocks physical partitions?

A

no, block is a contiguous range of physical address locations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

controller
————
0
1
2

N - 1
—————–

how many blocks is RAM partitioned into?

A

RAM = N-1 blocks in total

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what is the process for a Block Read Operation for a block that is not in the cache?

A
  1. CPU sends Block Read operation
    to RAM controller
    • operation –> CPU sends the start
      address of the block in RAM
  2. RAM controller goes to that address in main memory
    • makes a copy of the block (aka
      data)
    • puts the copy of the block onto
      the BUS
  3. CPU controller reads the copy of the block from the BUS
    - puts it in cache memory in the
    CPU
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is the process for a Block Write Operation for a block that is in the cache that needs to be in main memory?

A
  1. CPU controller goes into cache
    • puts a copy of block onto the BUS
      with a specific address in the
      main memory
  2. RAM controller reads from the BUS
    • goes to that specific address in
      main memory
    • replaces current block with the
      copy of the block from the BUS
      from the cache in the CPU
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

block size in main memory = ? bytes

A

4 bytes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

0000 —- start of block 0
0001
0010
0011 —- end of block 0

0100 —- start of block 1
0101
0110
0111 —- end of block 1

what are these binary numbers an example of?

A

block address bits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

0000 —- start of block 0
0001
0010
0011 —- end of block 0

0100 —- start of block 1
0101
0110
0111 —- end of block 1

what is ‘10’, ‘11’, ‘01’, ‘10’ an example of?

A

block offset bits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what are block offset bits?

A

the last two binary digits in the block address bits –> references specific byte within the block

ex) byte at offset 11
- references one byte within
block with unique block offset
bits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

block size =

A

2^b
b = bytes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

total number of blocks =

A

2^m/ 2^b

m = physical address bits (4)
b = bytes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

3 types of cache mapping algorithms

A
  1. Fully Associative
  2. Direct Mapping
  3. Set Associative
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

which type doesn’t have line bits?

A

FA–> the block could be anywhere in the cache

16
Q

which type does have line bits?

A

DM–> line bits determine exactly where the block is located in the cache

17
Q

which type has the block replacement algorithm?

A

FA

18
Q

what is the block replacement algorithm?

A

cache = full, line must be evicted to make space for new line of data

19
Q

3 methods to determine which block to replace for FA

A
  1. LRU (least recently used)
  2. FIFO (first in first out)
  3. Random (no favoritism)
20
Q

**DM

0 1 1 0

what is the tag bit?

A

0 –> msb

21
Q

**DM

0 1 1 0

what is the line bit?

A

1 –> next bit to left of msb

22
Q

**DM

0 1 1 0

what are the block offset bits?

A

1 0 –> last two bits after tag and line

  • 0 is technically lsb
23
Q

what are the two different policies for writing operations for cache?

A
  1. write-through: CPU writes are cached while also written to main memory
    - stalls the CPU until write is done
  2. write-back: CPU writes are cached, but not immediately written to main memory
    - main memory contents become
    “stale”
    - value = evicted or modified
    (“dirty”) –> then written to main
    memory
24
Q

how big is a block in physical memory?

A

one word

25
Q

principle of locality

A

programs tend to use data and instructions in memory that have addresses near or equal to those they have used recently

26
Q

temporal locality

A

recently referenced blocks are likely to be referenced again in the near future

27
Q

spatial locality

A

blocks with nearby addresses tend to be referenced close together in time