Paging – Conversion of virtual address in paging

Lists of Descriptive Questions Answers and Short Study Notes On Operating System – Paging

  • (1) What is paging? Explain the conversion of virtual address in paging with example.

 

Question- What is paging? Explain the conversion of virtual address in paging with example.

  • 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. below.
  • In this example, we have a computer generated 16-bit addresses, from 0 up to 64K. These are the virtual addresses.
  • However, only 32 KB of physical memory is available, so although 64-KB programs can be written, they cannot be loaded in to memory in their entirety and run.
  • A complete copy of a program’s core image, up to 64 KB, must be present on the disk. Only required pages are loaded in the physical memory.

virtual address conversion

Figure – The relation between virtual addresses and physical memory addresses is given by the page table.

  • With 64 KB of virtual address space and 32 KB of physical memory, we get 16 virtual pages and 8 page frames.
  • Transfers between RAM and disk are always in units of a page.
  • The virtual address is split into a virtual page number (high order bits) and an offset (low-order bits).
  • With a 16-bit address and a 4 – KB page size, the upper 4 bits could specify one of the 16 virtual pages and the lower 12 bits would then specify the byte offset (0 to 4095) within the selected page.
  • The virtual page number is used as an index into the Page table.
  • If the present/absent bit is 0, it is page-fault; a trap to the operating system is caused to bring required page into main memory.
  • If the present/absent bit is 1, required page is there with main memory and page frame number found in the page table is copied to the higher order bit of the output register along with the offset.
  • Together Page frame number and offset creates physical address.
  • Physical Address = Page frame Number + offset of virtual address.

internal operation of the MMU

Figure – The internal operation of the MMU with 16 4-KB pages.