# How does cpu fetch active program data (using virtual address) from storage when there is a page fault?

I read that cpu generates virtual address and using the same mmu translates to physical address and then fetches the data from RAM. But when there is a page fault, the data is fetched from the HDD(or Secondary Storage) where the program resides. But how does the cpu knows exact location of the program on storage device. Does it maps the virtual address to the address of storage device? If yes, how does it do ?

• Page faults are handled by software, i.e., the OS knows where in secondary storage a particular page has been stored. – Paul A. Clayton Apr 19 '15 at 8:15
• could you please be more brief.. Can you explain taking an example. – Nanda Kishore Ch Apr 19 '15 at 8:22
• The hardware just signals to the OS where the page fault occurred. Then, the OS looks through its data structures to determine what to do : Maybe it is a software error, maybe it is a 'zero fill on demand' page, maybe it is on disk... – TEMLIB Apr 19 '15 at 10:17

• In each descriptor, the lowest bit indicates whether the descriptor is valid. If the lowest bit is 0, the descriptor is valid, and the corresponding physical page is $2^11 \times d$ where $d$ is the descriptor value. If the lowest bit is 1, the descriptor is invalid, and the MMU ignores the other bits. (In the real world, there are more bits in descriptors for permissions, cache maintenance, etc.)