When the CPU writes or reads from the memory and stores the value that was read or written into L1 cache. Do the CPU store the whole block( 1 block , leaves the other three ways empty) or the whole set ( 4 blocks)?
$\begingroup$
$\endgroup$
2
-
1$\begingroup$ What have tou tried? Where did you get stuck? What have you read? Since it is "basic question" maybe there is "easy to find common reference"? $\endgroup$– EvilCommented Jul 28, 2016 at 17:57
-
$\begingroup$ Yeah I was wondering how a set associative cache work. Some say that you can write to individual blocks ( one block = 1 way ) and skip the rest. (meaning leaving block(way 2) = empty, block (way 3) = empty , block ( way 4) four empty and write to block (way 1) = data) or do the CPU write to all the ways immediatly in parallell (way 1)block 1 = data,(way 2) block 2 = data , (way 3)block 3 = data ,(way 4) block 4= data). $\endgroup$– bopiaCommented Jul 29, 2016 at 9:58
Add a comment
|
1 Answer
$\begingroup$
$\endgroup$
3
Four way set associative does not mean 4 sets.
It means each set is of 4 blocks.
Individual block can be read or written.
Go through this document for understanding the concept of set associative cache.
-
$\begingroup$ But how do we know if individual blocks are written or all the ways ( 4 blocks each way contains 1 block) are written ? Isnt there a common rule to write to the cache or is it the hardware that decides this rule ???? $\endgroup$– bopiaCommented Jul 29, 2016 at 9:51
-
$\begingroup$ Block is collection of bytes.whenever we fetch data into cache from memory the unit of transfer is a block. $\endgroup$– MaharajCommented Jul 29, 2016 at 9:57
-
$\begingroup$ Ok that was the answer I was looking for thanks! $\endgroup$– bopiaCommented Jul 29, 2016 at 10:00