Paging in operating system – memory management

Paging is a very important concept of memory management system and if you are very comfortable in concept of paging you can solve all the question asked on the paging very easy in examination so let’s start with the concept of paging in OS.


What is paging?

So in paging we split a process into equally sized pages and insert into the frames of main memory this is the basically simple definition of Paging.

Let’s take a very basic example suppose you are using a computer or laptop and that device has three main component here we are taking this for example RAM, CPU and HDD.

In general as we know that RAM is limited in nature that is the size of RAM is very limited compare to the size of HDD so when RAM is around 4-128GB a HDD starts typically 1 Tb or 500 GB so we have a lot of secondary storage and for the same money the RAM is very expensive.

The Reason why the RAM is more expensive because Ram is totally very different device which is very high speed memory device and it is volatile in nature and it is best suited for programs to execute.

So basically programs can be stored in HDD but when they are suppose to be executed they are move to the primary memory in the RAM because then the CPU can execute instruction from the program very fast and that’s the beauty of the RAM that Is a very high speed memory access device so this is the very basic things we all know this so where does paging comes into the picture?


Why we need paging?

Now as that technology being advancing and as the programs are becoming more complex the Ram sizes are not really increasing so typically when a multitasking scenario comes into the picture so there are lot of applications which are running in the RAM.

So even if you just open up your task manager there will be like hundreds of processes already running in the background and when you open up more complex application as specially gaming and graphic intensive applications they take up more RAM and more processing so this makes the entire RAM full.

This is where the memory management comes into the picture now the memory management terms itself tells us that you have to manage the memory and paging in Operating system is one such methodology in which you can efficiently manage memory.


How does this paging work?      

In this paging we use some portion of secondary memory as virtual RAM we can also say it is vram so this newly allotted memory can be used to store processes in the form of pages so we will come to what is page.

But essentially what we are going to do is some of the running applications or some part of the running application can be stored in the secondary memory if they are not used.

So CPU is gone be running some other processor application we can understand this thing with the help of this given diagram.


Paging in operating system

So here in RAM think that there are two process are running and two are not running so that tow process which are not running that two process goes into vram and they comes back into Ram when we need that process so this is the concept of paging in OS.

So with the help of paging we can use secondary memory as RAM and with the help of that we can increase the size of RAM not physically but we can use that memory. 

Overview of Paging


·        In computer operating system, Paging is a memory management scheme by which a computer stores and retrieves data from secondary memory for use in main memory.

·       In this scheme, the operating system retrieves data from secondary storage in same size block called pages.

·       Paging is an important part of virtual memory implementation in modern operating system using secondary storage to let programs exceed the size of available physical memory. Non-contiguous memory allocation. Helps to prevent external fragmentation. 

·      Logical address space is divided into equal size of pages. Physical address space is divided into equal size frames. Here we think that what is frame, frame is nothing else but the RAM can divided into same size of block so that one block calls frame, in vram we call it one page  and in Ram we call it one Frame.  

·      Page size = Frame size  

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

If you want to understand what is mapping then you can go threw are previous article on what is mapping and how mapping works.


Example of Paging

Here I explain you the paging with one simple example so let’s understand with the help of diagram

Paging in operating system

First suppose here you start one application for example we can take suppose you open chrome browser there is so many process are start running for example one process is conducted the name of that process is X and the size of process is let’s take 10 Kb as you know in paging the memory is divided into a same size so our page size is 2 kb.

So the process divided into 5 parts of 2 kb each so we named them as P1 P2 P3 P4 P5 so the CPU is going to generate the logical address so you can see the CPU in diagram it points that two part P and D so P is page no and D is page offset here P is contain the base address of particular page.

So with the help of mapping the data can be transfer from secondary memory to RAM so that is very easy hope so you understand the full process of paging.

If you don’t understand you can go threw are video lecture there you can understand very easily.


If you have any question regarding paging in OS or any other type of question which comes under to the computer science you can ask in comment section.  

Post a comment