Search code examples
memory-managementmemory-addressvirtual-memorytlbpage-tables

What does the cpu do after it's obtained the physical memory address


So I understand that when the cpu looks up a virtual address it looks at the TLB and then at the page table in order to get the physical address (pa), but I'm kind of confused about what it does with that pa.

Does it just check that address at each level of memory until it gets a hit? For example: check pa at cache l1, if miss then check pa at l2, if miss then check pa at l3, if miss then check pa in RAM, if miss then read from disk. I've tried googling this and searching stack overflow, but I can't find any comprehensive or clear explanation of the process.


Solution

    1. Your question suggests quite a bit of confusion. To start you on your learning process, I suggest ignoring the cache entirely. Caching checking is entirely a hardware process and, unless you are into CPU design, it has no [little] bearing on programming.

    2. The CPU translates logical addresses into physical addresses. More precisely, it translate logical addresses into a physical page frame an an office into the physical page frame.

    3. If the CPU cannot translate a logical address into a physical address, it triggers a page fault.

    4. The operating system's page fault handler then tries to see if the corresponding page is virtual (stored on disk). If so, the page fault handler loads the page from disk and restarts the instruction that caused the fault. If not, the operating system triggers an access violation of some sort.