Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Paging in Operating System

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Paging is a memory management scheme that eliminates the need for contiguous allocation of physical memory. The process of retrieving processes in the form of pages from the secondary storage into the main memory is known as paging. The basic purpose of paging is to separate each procedure into pages. Additionally, frames will be used to split the main memory.This scheme permits the physical address space of a process to be non – contiguous.

All vital terminologies associated with memory control in running systems:

        1. Logical Address or Virtual Address: This is an deal with that is generated thru the CPU and used by a technique to get right of entry to                 reminiscence. It is known as a logical or digital deal with because it isn’t always a physical vicinity in memory but as an opportunity a                        connection with a place inside the device’s logical address location.

        2. Logical Address Space or Virtual Address Space: This is the set of all logical addresses generated via a software program. It is                          normally represented in phrases or bytes and is split into regular-duration pages in a paging scheme.

        3. Physical Address: This is an cope with that corresponds to a bodily place in reminiscence. It is the actual cope with this is available on the            memory unit and is used by the memory controller to get admission to the reminiscence.

        4 Physical Address Space: This is the set of all bodily addresses that correspond to the logical addresses inside the way’s logical deal with               place. It is usually represented in words or bytes and is cut up into fixed-size frames in a paging scheme.

In a paging scheme, the logical deal with region is cut up into steady-duration pages, and every internet web page is mapped to a corresponding body within the physical deal with vicinity. The going for walks tool keeps a web internet web page desk for every method, which maps the system’s logical addresses to its corresponding bodily addresses. When a method accesses memory, the CPU generates a logical address, that is translated to a bodily address using the net page table. The reminiscence controller then uses the physical cope with to get right of entry to the reminiscence.

 some of the important thing features of paging in pc reminiscence management:

   1. Logical to bodily address mapping: In paging, the logical address area of a technique is divided into constant-sized pages, and each web           page is mapped to a corresponding physical body within the main reminiscence. This permits the working gadget to manipulate the memory in        a  extra flexible way, as it is able to allocate and deallocate frames as needed.

  2. Fixed web page and frame length: Paging makes use of a set web page length, which is usually identical to the size of a frame within the            most  important memory. This facilitates to simplify the reminiscence control technique and improves device performance.

  3. Page desk entries: Each page within the logical address area of a method is represented through a page table entry (PTE), which contains            facts approximately the corresponding bodily body in the predominant memory. This consists of the frame range, in addition to other                        manipulate bits  which can be used by the running machine to manage the reminiscence.

4. Number of page desk entries: The range of page desk entries in a manner’s page desk is identical to the wide variety of pages inside the             logical deal with area of the technique.

5. Page table stored in important memory: The web page desk for each system is typically saved in important reminiscence, to allow for green      get right of entry to and change by the operating device. However, this could additionally introduce overhead, because the web page table must      be updated on every occasion a system is swapped in or out of the main memory.

Example: 

  • If Logical Address = 31 bit, then Logical Address Space = 231 words = 2 G words (1 G = 230)
  • If Logical Address Space = 128 M words = 27 * 220 words, then Logical Address = log2 227 = 27 bits
  • If Physical Address = 22 bit, then Physical Address Space = 222 words = 4 M words (1 M = 220)
  • If Physical Address Space = 16 M words = 24 * 220 words, then Physical Address = log2 224 = 24 bits

The mapping from virtual to physical address is done by the memory management unit (MMU) which is a hardware device and this mapping is known as paging technique.

  • The Physical Address Space is conceptually divided into a number of fixed-size blocks, called frames.
  • The Logical address Space is also splitted into fixed-size blocks, called pages.
  • Page Size = Frame Size

Let us consider an example:

  • Physical Address = 12 bits, then Physical Address Space = 4 K words
  • Logical Address = 13 bits, then Logical Address Space = 8 K words
  • Page size = frame size = 1 K words (assumption)

size   Address generated by CPU is divided into

  • Page number(p): Number of bits required to represent the pages in Logical Address Space or Page number
  • Page offset(d): Number of bits required to represent particular word in a page or page size of Logical Address Space or word number of a page or page offset.

Physical Address is divided into

In a paging scheme, the physical cope with area is divided into fixed-length frames, each of which contains some of bytes or words. When a manner is running, its logical address space is split into constant-size pages, which might be mapped to corresponding frames within the physical address space.

To represent a physical address in this scheme,  parts are commonly used:

1. Frame range: This is the variety of the frame within the physical cope with area that consists of the byte or phrase being addressed. The wide         variety of bits required to represent the body range relies upon on the scale of the physical cope with area and the size of each frame. For               instance, if the physical cope with area carries 2^20 frames and each frame is 4KB (2^12 bytes) in size, then the frame range could require             20-12 = 8 bits.

2. Frame offset: This is the wide variety of the byte or word within the body this is being addressed. The number of bits required to represent the       frame offset relies upon on the size of every frame. For instance, if every body is 4KB in size, then the frame offset could require 12 bits.

   So, a physical address in this scheme may be represented as follows:

   Physical Address = (Frame Number << Number of Bits in Frame Offset) + Frame Offset

   Where “<<” represents a bitwise left shift operation.

  • The TLB is associative, high speed memory.
  • Each entry in TLB consists of two parts: a tag and a value.
  • When this memory is used, then an item is compared with all tags simultaneously.If the item is found, then corresponding value is returned.

Paging is a memory management technique used in operating systems to manage memory and allocate memory to processes. In paging, memory is divided into fixed-size blocks called pages, and processes are allocated memory in terms of these pages. Each page is of the same size, and the size is typically a power of 2, such as 4KB or 8KB.

In paging, the physical memory is divided into fixed-size blocks called page frames, which are the same size as the pages used by the process. The process’s logical address space is also divided into fixed-size blocks called pages, which are the same size as the page frames. When a process requests memory, the operating system allocates one or more page frames to the process and maps the process’s logical pages to the physical page frames.

The mapping between logical pages and physical page frames is maintained by the page table, which is used by the memory management unit to translate logical addresses into physical addresses. The page table maps each logical page number to a physical page frame number.

Here are some important points about paging in operating systems:

1. Reduces internal fragmentation: Paging facilitates to lessen internal fragmentation by using allocating memory in fixed-size blocks (pages),         which might be usually a whole lot smaller than the size of the process’s facts segments. This lets in for greater efficient use of memory in view       that there are fewer unused bytes in each block.

2. Enables reminiscence to be allotted on call for: Paging enables memory to be allocated on call for, this means that that memory is most             effective allocated when it’s far needed. This allows for extra efficient use of memory in view that only the pages that are absolutely used by the       manner want to be allocated inside the physical memory.

3 Protection and sharing of memory: Paging allows for protection and sharing of reminiscence between methods, as each procedure has its         own web page table that maps its logical deal with area to its physical address space. This permits for techniques to proportion facts at the same     time as preventing unauthorized get right of entry to to every other’s memory.

4. External fragmentation: Paging can result in outside fragmentation, wherein memory turns into fragmented into small, non-contiguous blocks.      This can make it difficult to allocate massive blocks of reminiscence to a method seeing that there may not be enough contiguous free memory to    be had.

5. Overhead :Paging involves overhead because of the renovation of the web page table and the translation of logical addresses to physical               addresses. The working device must maintain the page table for each manner and perform deal with translation whenever a procedure                   accesses memory, that can slow down the machine.

.
Some reference books on operating system concepts that cover paging include:

  1. “Operating System Concepts” by Abraham Silberschatz, Peter Baer Galvin, and Greg Gagne.
  2. “Modern Operating Systems” by Andrew S. Tanenbaum.
  3. “Operating Systems: Three Easy Pieces” by Remzi H. Arpaci-Dusseau and Andrea C. Arpaci-Dusseau.
  4. These books provide detailed coverage of operating system concepts, including memory management and paging techniques.

My Personal Notes arrow_drop_up
Last Updated : 13 May, 2023
Like Article
Save Article
Similar Reads