What exactly is a fault bucket and what causes it?

What exactly causes a page fault?

  • So Wikipedia says this:" page fault (sometimes #pf or pf) is a http://en.wikipedia.org/wiki/Trap_%28computing%29 to the software raised by the hardware when a program accesses a http://en.wikipedia.org/wiki/Page_%28computer_memory%29 that is mapped in the virtual http://en.wikipedia.org/wiki/Address_space,  but not loaded in physical memory. In the typical case the operating  system tries to handle the page fault by making the required page  accessible at a location in physical memory or terminates the program in  the case of an illegal access My question is - how exactly did the mismatch between virtual address space and physical space exactly arise? Did the page table originally contain a consistent mapping between virtual address space and physical space, and then the CPU might have moved the data in physical space to a swap file in the meantime? (without updating the virtual address space when it moved the data) Or what? also see http://www.reddit.com/r/AskComputerScience/comments/1wrken/how_does_exactly_memory_paging_work_and_what_is/

  • Answer:

    The CPU doesn't move any pages of its own accord. The operating system swaps pages between physical memory and the swap file. The virtual address space can't be updated when swapping occurs because applications already hold pointers into it. A pointer shouldn't become invalid when the page it points to is swapped out. If an application dereferences a pointer into a page that has been swapped out of physical memory, the operating system then has to intervene to swap that page back in. That's why the CPU has to generate a page fault---to pass control back to the OS. A page fault is not some sort of error condition that indicates a bug, unless a process actually tries to access memory it's not allowed to access.

Brian Bi at Quora Visit the source

Was this solution helpful to you?

Other answers

When a process is being executed not all the pages held by the process are loaded into the physical memory. Only those pages that are required are loaded. When the CPU runs out of memory it replaces the unused pages in the physical memory with the pages of the process that needs to be executed. Later, when the process whose page was removed from the physical memory tries to access the page, a page fault occurs during which the page is reloaded into the physical memory by removing some other page or utilizing any free memory that is available. Have a look at he following presentation slides for better understanding http://www.cs.ucla.edu/~ani/classes/cs111.08w/Notes/Lecture%2016.pdf

Rajkiran R Bala

First of all let me explain how the mapping between logical address and physical address takes place. The physical address is divided into fixed size blocks called frames. Similarly the logical address is divided into blocks of same size called pages. Now the logical address generated by the cpu is divided into two parts page no and offset. A page table contains an index to the page no and corresponding mapping to the frame no. The offset is added to this frame no and that gives the corresponding address in the physical memory. The paging hardware is shown below : Now when a page no is not found in the page table a page fault occurs. So what happens when a page fault occurs .. 1. We check an internal table (usually kept with the process control block) for this process to determine whether the reference was a valid or an invalid memory access. 2. If the reference was invalid, we terminate the process. If it was valid, but we have not yet brought in that page, we now page it in. 3. We find a free frame (by taking one from the free-frame list, for example). 4. We schedule a disk operation to read the desired page into the newly allocated frame. 5. When the disk read is complete, we modify the internal table kept with the process and the page table to indicate that the page is now in memory. 6. We restart the instruction that was interrupted by the trap. The process can now access the page as though it had always been in memory. These steps can be understood by the image below  

Sourabh Anand

When a process tries to visit a virtual address, the OS will first check the TLB, see if the page is cached there; if not, it refers to the page table, and check the valid bit is set or not; if not, then the mismatch arise, since the page is not in the frame. The OS has a global management to the mapping between virtual address space and physical space. Especially for a 64 bits system, since a program can be very large, and a multilevel paging scheme can be slow, the inverted page table will be adopted to map each page of each process to a frame (image this as a hash table, with separate chaining to solve collision). The mapping is NOT consistent, the OS will assign the free physical frame to processes which need more frames.

Silvery Fu

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.