Earlier we discussed the idea of the separation of the logical addressing space from the physical addressing space. We changed the memory management unit (MMU) to make this work. Instead of using the base register to check an address we used it to relocate an address. This allowed us to put any program anywhere in memory— dynamic relocation. However, we found that allowing variable-sized programs to come and go in memory caused us to have external fragmentation of the memory and to spend valuable CPU time doing compaction. Definition of Paging Unfortunately, compaction is not “useful work” in the sense that it is not anything the user is trying to do.
It is merely a task that the OS does to make things work better in an overall sense. Eventually another solution was developed—we divide the memory into fixed-size blocks and instead of allocating to an application the entire space it needs in one large segment, However, the blocks we allocate do not need to be contiguous—they can be anywhere in memory because we ask the MMU to dynamically relocate each block separately. This technique is known as paging. This means that we have to make our memory management unit a lot more complex.
We see that the CPU generates a memory address. In general, the program ignores the fact that the memory is handled in separate pages, so these addresses are regarded as just a binary number in the range of the logical address space. This address might be the address of the next sequential instruction, a jump to a subroutine, a reference to a data item or to the stack. The purpose of the reference does not matter.
As before, we call this the logical address. However, the MMU will regard the address as being composed of two parts, shown here as the page number, p and the displacement, d. The displacement is the address of the specific byte within the frame. If our frame size is 4 KB then our displacement field is the exact size needed to address every byte in a frame, or 12 bits. When we relocate a logical address to a physical address we will still be addressing the same displacement in the frame as we were in the page. Definition of Paging So we will not change the displacement part of the logical address.
the logical address is the page number. What we need to relocate is the page, so we will look in a page table of relocation addresses for the frames. We will have a register that holds the memory address of the page table for the running process. This register is called the page table address register. The memory control unit will add the page number from the logical address generated by the process running in the CPU to the value in the page table address register.
The value stored in that location of the page table will be the relocation address of the particular frame we are trying to access. In this case, it is shown as the value f. Definition of Paging The value of f is combined with the displacement we already had to address the particular byte in physical memory.
that this entry contains the number of frame 7. So the memory management unit will look into frame 7 to find the information we are accessing. Of course, in a real system the frames would be spread out and mixed in with frames from other processes.