I hope this isn't a duplicate.
Question regarding cache and virtual memory simulation:
- suppose a blocking cache (a blocking cache is a cache that waits until the transfer from memory to cache is complete before delivering data to CPU)
What happens if:
- CPU asks for an instruction not present in instruction cache (there's a miss)
- instruction cache asks for data to MMU/memory
- the MMU reports a page fault
- The CPU receives an interrupt from MMU that alerts about the page fault
- CPU jumps to hardwired address that contains code for handling page fault
- instruction fetch stage asks for the first instruction (from page fault handling) to cache
Now my question: how cache will delivery page fault handling code to CPU if it is waiting for main memory to delivery the other data (the one that caused page fault)?
I came up with this solution: improve my cache so that both CPU and cache receives the page fault signal; cache stores its state, receives and deliveries page fault handling code to CPU and then restore its previous states.
This is what I came up with, but is this the correct/valid and efficient way to do?