5 - Memory Management: (5) What Is Paging? Explain The Conversion of Virtual Address in Paging With Example
5 - Memory Management: (5) What Is Paging? Explain The Conversion of Virtual Address in Paging With Example
The basic idea behind virtual memory is that each program has its own address
space, which is broken up into pages.
Each page is a contiguous range of addresses.
These pages are mapped onto the physical memory but, to run the program, all
pages are not required to be present in the physical memory.
The operating system keeps those parts of the program currently in use in main
memory, and the rest on the disk.
Virtual memory works fine in a multiprogramming system, with bits and pieces of
many programs in memory at once.
While a program is waiting for part of itself to be brought in, it is waiting for I/O and
cannot run, so the CPU can be given to another process.
In a system using virtual memory, the physical memory is divided into page frames
and the virtual address space is divided in into equally-sized partitions called pages.
(5) What is paging? Explain the conversion of virtual address in paging with example.
Paging
The program generated address is called as Virtual Addresses and form the Virtual
Address Space.
Most virtual memory systems use a technique called paging.
Virtual address space is divided into fixed-size partitions called pages.
The corresponding units in the physical memory are called as page frames.
The pages and page frames are always of the same size.
Size of Virtual Address Space is greater than that of Main memory, so instead of
loading entire address space in to memory to run the process, MMU copies only
required pages into main memory.
In order to keep the track of pages and page frames, OS maintains a data structure
called page table.
The conversion of virtual address to physical address
When virtual memory is used, the virtual address is presented to an MMU (Memory
Management Unit) that maps the virtual addresses onto the physical memory
addresses.
A very simple example of how this mapping works is shown in Fig. 5-6.
In this example, we have a computer generated 16-bit addresses, from 0 up to 64K.
These are the virtual addresses.
Figure 5-5. The relation between virtual addresses and physical memory addresses is
given by the page table.
Figure 5-6. The internal operation of the MMU with 16 4-KB pages.