Pages and Paging
- The virtual address space of a program is divided into pages, which are contiguous groups of a fixed size of bytes.
- Machine architecture determines the page size of that computer. Typical sizes include 4KB on 32-bit systems and 8KB on 64-bit systems. (32-bit and 64-bit tell the length of a memory address: 32 vs. 64 bits long.)
- A page is called valid if the data (values of variables and objects, program's instructions, etc.) of this page is now located in RAM.
- An page is called invalid if its data is located on disk instead of in main memory. How could this happen? Sometimes, when there's not enough place in RAM to store data, the OS keeps some of the program's data on disk. This memory management technique is called virtual memory.
- A page fault happens when the program needs to use data that is located on an invalid page. That is, when the data is located on disk and not in main memory. The operating system will page-in (= copy) the data from the disk into RAM. The location in RAM that stores a page is called a frame.
- Paging-out is the process of moving data from RAM to secondary storage (to make room for new pages). Usually, such data are unlikely to be used soon, which is why we decide to them to disk instead of moving other, more crucial data.