0
$\begingroup$

Both are based on the principle of locality. Then why virtual memory uses table lookup while cache memory uses associative memory for block identification?

$\endgroup$
1
  • $\begingroup$ TLBs are caches for virtual memory translations. $\endgroup$
    – TEMLIB
    May 24 '20 at 18:09
1
$\begingroup$

I think it's because when using virtual memory, you have access to disk and thus have vasts amounts of memory to store extra data structures than can help you identify each page. In cache, you don't have that much memory, so the way to do things is to add identification (tag and set) bits to each cache line so that you don't need another data structure to identify each cache block because it would be expensive memory-wise. You just iterate over each set, identify the set you're looking for, then iterate over each cache line in that set and identify the cache line you're looking for and then extract the desired bytes. Also, iterating over all cache lines is not that expensive because there aren't a lot of them, but applying this technique to pages, which can be thousands, is really inefficient.

$\endgroup$
1
  • 1
    $\begingroup$ (Well, cache lines of "desktop CPU" L3 caches are well into the thousands as of 2020.) And iteration doesn't sound smart for caches used to circumvent the signal travel time to and from memory (2×) four inches away (about three cycles) - typically virtually addressed to skip/overlap TLB access time. $\endgroup$
    – greybeard
    May 24 '20 at 7:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.