written 3.1 years ago by |
Paging is a storage mechanism that allows OS to retrieve processes from the secondary storage to the main memory in the form of pages. Every memory access while paging requires reading the page table. ( Page table is a data structure used by the virtual memory system to store the mapping between logical addresses and physical addresses. )
Logical addresses are generated by the CPU for the pages of the processes therefore they are generally used by the processes. Physical addresses are the actual frame address of the memory. They are generally used by the hardware or more specifically by RAM subsystems.
Let's say arithmetic operations have to be performed upon every memory access in the software. This results in the system getting slow because of low effective access time. Page size (like the frame size) is typically defined by hardware.
For hardware support to be effective, the required page size to be the power of two, varying between 512 bytes and 1GB per page depending on the computer architecture. This can perform fast logical shifting to get page number and the page offset, no need to perform expensive arithmetic operations. The selection of a power of 2 as a page offset is particularly easy. If the size of the logical address space is 2^m, and page size is 2^n bytes, give 2^(m-n) pages so require (m-n) bits to specify page number and offset of n bits to specify offset within the page. Thus, the logical address is as follows
where p is an index into the page table and d is the displacement within the page.