Do you think IIT Guwahati certified course can help you in your career?
No
Introduction
The operating system occupies a portion of memory in a multiprogramming computer, while the remainder is shared among several processes. Memory management is the practice of dividing memory across many operations. Memory management is a way of managing actions between main memory and disk during process execution in the operating system. The primary goal of memory management is to maximize memory use. Paging and swapping are two different kinds of memory management techniques.
In this tutorial, we will talk about the concept of paging and swapping and the difference between paging and swapping.
Paging
Paging is a memory management function in which a computer stores and retrieves data from a device's secondary storage to the primary storage. Memory management is an essential component of every computer system, and paging, in particular, is critical to the deployment of virtual memory.
There are two kinds of computer memory: primary memory and secondary memory. Data in primary storage is transient and regularly accessed by apps or other hardware components. It is usually kept in random access memory (RAM) for quick retrieval. Secondary storage refers to storing data in a computer over extended periods. Secondary storage is usually slower than primary storage. A solid-state drive (SDD), for example, is an example of secondary memory.
Paging
Using this technique, the primary memory is divided into little pieces of physical memory known as frames. The size of frames in paging is fixed. The frame size must be equivalent to the page size to avoid external fragmentation and make the most of the main memory. This method facilitates faster data access.
Example: If the main memory is 16 KB and the frame memory is 1 KB. The main memory will be partitioned into 16 frames, each with 1 KB of memory.
Advantages of Paging
Here are some advantages of using the Paging method:
Easy to use memory management algorithm
No need for external fragmentation
Swapping is easy between equal-sized pages and page frames.
Disadvantages of Paging
Here are the drawbacks/ cons of paging:
This May cause Internal fragmentation
Page tables consume additional memory.
Multi-level paging may lead to memory reference overhead.
Swapping
Swapping is a memory management technique that removes inactive programs from the computer system's main memory. Any process must be executed in memory, but it can be temporarily swapped out of memory to a backup store and then brought back into memory to finish its execution. Swapping is done to ensure that other processes have enough memory to run.
Swapping in the operating system aims to access data stored on the hard disk(HDD or SSD) and bring it into RAM for usage by application programs. It's important to note that swapping is only done when data isn't available in RAM.
Swapping has been subdivided into two concepts: swap-in and swap-out.
Swap-out is a technique for transferring a process from RAM to the hard disk.
Swap-in is a technique for deleting a program from a hard disk and reinstalling it in main memory or RAM.
What is the difference between paging and segmentation?
The segmentation method is quite similar to paging; the only difference is that segments can be of any size, but pages in the paging method are always of the same size.
What is memory management in Operating System?
Memory management regulates and coordinates computer memory by assigning memory blocks to various operating programs to improve the system's overall performance.
What is the basic function of paging?
Paging is a memory management technique that allows a process's logical address space to be non-contiguous.
Differentiate between internal and external fragmentation.
Internal fragmentation occurs when a process is assigned to a larger memory block than what is required. Other processes will not be able to use the extra memory that has been allocated. External fragmentation occurs when a process has enough total memory to run, but the memory is not contiguous, preventing it from using it.
Conclusion
In this article, we have extensively discussed the concepts of Paging and Swapping. We started by introducing Paging and Swapping, the differences between Paging and Swapping, and finally concluded with the pros and cons of Paging and Swapping.