Paging

Filter Course


Paging

Published by: Zaya

Published date: 22 Jun 2021

Paging Photo

Paging

  • Paging is a memory management scheme by which a computer stores and retrieves data from secondary storage for use in main memory.
  • Paging is a process of reading data from, and writing data to the secondary storage.
  • Partition memory into small equal fixed-size chunks and divide each process into the same size chunks.
  • The chunks of a process are called pages.
  • The chunks of memory are called frames.
  • The basic idea behind paging is to only keep those part of the processes in memory that are actually being used
  • Paging is a non-contiguous memory allocation technique.
  • The basic idea behind paging is to only keep those part of the processes in memory that are actually being used
  • Paging:

- divides processes into a fixed-sized pages
-Then selectively allocates pages to frames in memory, and
-manages (moves, removes, reallocates) pages in memory

  • The logical memory of the process is still contiguous but the pages need not be allocated contiguously in memory
  • By dividing the memory into fixed-sized pages, we can eliminate external fragmentation
  • However, paging does not eliminate internal fragmentation (e.g4KB frame size and 15 KB of process)
  • Summary: breaking process memory into fixed-sized pages and map them to a physical frame of memory

OS needs to do two things
1. Mapping the pages to frame, maintain a page table
2. Translate the virtual address (contiguous) into a physical address (not so easy as the physical address for a process is scattered all over the memory)

The address generated by CPU (logical address) is divided into:

  • Page number p is an index into a page table that contains the base address of each page in physical memory.
  • Page offset d is a displacement, combined with the base address to define the physical memory address that is sent to the memory unit.

Page Fault

  • When the page (data) requested by a program is not available in the memory, it is called a page fault. This usually results in the application being shut down.
  • A page is a fixed-length memory block used as a transferring unit between physical memory and external storage. A page fault occurs when a program accesses a page that has been mapped in address space but has not been loaded in the physical memory.

Page hit
Whenever a process refers to a page that is present in memory, such a condition is known as page hit.

Page table
A page table is the data structure used by a virtual memory system in a computer operating system to store the mapping between virtual addresses and physical addresses

Frame
Frame is a fixed sized block in physical memory space.

paging

Advantages and Disadvantages of paging


• Paging reduces external fragmentation, but still suffers from internal fragmentation.
• Paging is simple to implement and assumed as an efficient memory management technique.
• Due to the equal size of the pages and frames, swapping becomes very easy.
• Page table requires extra memory space, so may not be good for a system having small RAM.