Operating system concepts are must to be known by every aspirant! 

Paging in the operating system is one crucial concept that holds a great significance for the users. 

In the operating system, paging is defined as the storage mechanism which is useful to retrieve the processes from the secondary storage to its main memory. 

This memory management strategy offers several pers to the operating system users!

If you want to know about this wonderful yet beneficial concept in detail, you are on the right blog post.

Here, we have covered everything related to the paging in the OS so that you can implement this concept in an ideal way. 

Without any further ado, let’s get started!

 

Paging in operating system

Paging is defined as the storage mechanism that allows an operating system to retrieve all the present processes from the secondary memory to the main memory in pages. 

When it comes to the paging, the main memory gets divided into some small blocks of the fixed size which are called frames. Though, the size of any frame will stay the same as that of a page size for the maximum utilisation of your main memory to avoid any type of external fragmentation.

Paging is basically used for the faster access of the data and this is considered as the logical step. 

Characteristics of the paging in an operating system includes:

  • The external fragmentation will not be present 
  • By procedure any given frame will be employed
  • On your last page in a process, the internal fragmentation will occur 
  • The process’s physical memory will no longer be the contiguous 
  • The process’s logical memory in any case will be contiguous

Let’s take a look at the example;

The size of the main memory is 16 KB and the size of the frame is 1 KB. The main memory in this case will be divided into 16 frames which are of 1 KB. There will be four different processors. They are A1, A2, A3, A4. all of these are 4 KB. 

Here, all processors will be divided into 1 KB pages so that your operating system can easily stroke a page in a frame. At the beginning, the processes will be divided into the 1 KB pages. The operating system can store only one page. 

Though, at the process beginning, the frames stay empty so that the pages of a process may get stored in the contiguous memory. 

 

Memory management unit 

This is a crucial concept which is responsible for conversion of the logical addresses into the physical addresses. These physical addresses refer to all the actual addresses of a given frame where your pages will get stored . otherwise the logical address here refers to the address which will be generated by the CPU for each given page. 

When your CPU accesses any page using its logical address to access any page physically. There will be two elements here in this case which are page number and the offset. 

 

How does paging work?

Paging divides your main memory into the fixed sized block words which we commonly referred to as the frames. The program in this case would be divided into the same kind of blocks which are of the size which is the same as that of the blocks. 

Here, we refer to them as the pages. In this case, the system has to execute the process that will load the pages of a program into the available frames in your main memory. 

In order to start the CPU, you have to generate the logical process. This will be included in your page number or the page offset. The system in this case may use the index in order to trace a page table with a base address for each page in your main memory. 

The base address will be combined with your page offset in order to compute the physical address of a given page for blocking your main memory. 

Consider it with the help of an example;

Suppose p is given as 2 and the page offset is 8.  It means that the CPU needs the access of page 2 for the main memory to get the eight instructions for that particular page.

Though, you should remember that the address that is generated is for the secondary memory but the CPU can pick a page from its main memory. So to access main memory, we need to have the required physical memory. 

The CPU in any case will check your page table to get the required physical address. 

 

Advantages of paging in the operating system

In the operating system, the concept of paging holds numerous perks which are discussed as follows:

  • Memory management in the case of paging will be considered quite effective 
  • There will be simplicity in the partitioning system to allocate the non-contiguous memory 
  • Memory allocation will be considered simple or relatively inexpensive in this case 
  • It is simple to share the pages 
  • No compaction is required in the case of paging in operating system
  • You don’t need any external fragmentation in case of paging 
  • Swapping will be more efficient in this case 

 

When to use paging in the OS?

You can use paging in the OS in following conditions:

  • In case there are too many processes which are running and are not enough for your physical memory 
  • When you are having any large process it can be splitted into the multiple pages 
  • When you need to load a possess into your physical memory

 

Buddy system in OS 

Another useful operating system concept that you should know is the Buddy system in OS. It is defined as the memory allocation and a given management algorithm which manages any memory with the power of two increments. 

 

Wrapping Up 

Learn in-depth about the paging in OS with the help of this blog post and equip yourself with the right knowledge. 

With this blog, you can learn and implement this concept in an ideal way!