Question

In a processor, what happens to the cache when the operating system replaces a page, if there is not enough space to hold all running processes' pages in memory? Does it need to flush the cache on every page replacement?

Thanks in advance for your replies.

Était-ce utile?

La solution

When a page is swapped in, the contents are read off the disk and into memory. Typically this is done using DMA. So the real question is, "How is the cache kept coherent with DMA?". You can either have DMA talk to the cache controller on each access, or make the OS manage the cache manually. See http://en.wikipedia.org/wiki/Direct_memory_access#Cache_coherency.

Autres conseils

I am not 100% sure of what happens in details, but caches and virtual memory using paging are similar: both are divided in "pages".

The same way that only one page needs to be replaced in a page fault, only one line of the cache needs to be replaced when it occurs a miss on the cache. The cache has several "pages" (lines), but only the problematic page will be replaced.

There are other things that I do not know if takes part on such replacements: cache size, cache coherency - write-through/back and so on. I hope someone else can give you a more detailed answer.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top