- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference between Demand Paging and Segmentation
Both Demand Paging and Segmentation are memory management techniques used in operating systems. In Demand Paging, a page is loaded from the secondary memory into the primary memory, only when it is needed. On the other hand, Segmentation follows a strategy whereby the entire memory space is divided into discrete segments and each segment is allocated to a process. Read through this article to find out more about Demand Paging and Segmentation and how they are different from each other.
What is Demand Paging?
As the name suggests, Demand Paging swaps a page into the main memory only when it is demanded by the CPU. The space available in primary memory is limited and at any given time, it has to run several processes simultaneously and each of these processes require some pages (not all of it) to be fetched from the secondary memory. For example, let's suppose you are using MS-Excel and it occupies 300 MB of space in the secondary memory, however it may not require all of it to be present at a time in the primary memory. Hence, the primary memory fetches only those pages which the CPU demands in order to run a specific process.
Demand Paging is also known as "Lazy Swapping" because it swaps pages lazily from the secondary memory, and only when they are demanded by the CPU.
Advantages of Demand Paging
Demand Paging supports efficient memory utilization. It never fetches those pages into the primary memory that are not required by the CPU. In Pure Demand Paging, a process starts without any pages in the primary memory and as soon as the process starts executing, the CPU triggers a page fault, whereby the requires pages are fetched from the secondary memory.
Disadvantages of Demand paging
Although Demand Paging improves memory utilization, the memory access time is normally longer. In addition, it creates more overheads due to interrupts and page tables.
What is Segmentation?
Segmentation is another memory management technique, just like Paging, that divides the addressable memory in distinct segments. However, there is a difference between a Page and a Segment. While Paging divides the memory into blocks of fixed size, Segmentation divides the memory into segments of variable sizes that can grow or shrink as per requirement. A computer that uses segmentation as the memory management technique would have a logical address space that can be viewed as multiple segments.
Advantages of Segmentation
Segmentation supports user's view of memory by dividing a process into modules that provide better visualization. There is no internal fragmentation in Segmentation. A Segment Table keeps track of all the segments, which occupies less space as compared to an equivalent Paging Table that keeps a record of all the pages.
Disadvantages of Segmentation
Segmentation is an expensive technique because it involves a lot of overhead for maintaining a separate segment table for each process. Since the segments are of unequal length, they are not suitable for swapping. Segmentation leads to external fragmentation as the available memory space is broken down into smaller chunks as the processes are being loaded and removed.
Difference between Demand Paging and Segmentation
The following table highlights the major differences between Demand Paging and Segmentation −
Key | Demand Paging | Segmentation |
---|---|---|
Definition | Paging is a memory management technique in which process address space is broken into blocks of the same size called "pages". | Segmentation is a memory management technique in which each job is divided into several segments of different sizes, one for each module that contains pieces that perform related functions. |
Block Size | The block size is fixed in case of Demand Paging. | In Segmentation, the process address space is broken in varying sized blocks which are called as "sections". So block size is not fixed in case of Segmentation. |
Block size dependency | In Demand Paging, the size of blocks is dependent on system memory and gets assigned accordingly. | In Segmentation, the size is not dependent on system memory and is all up to user's choice that of what size blocks are needed. |
Performance | In context of performance, Demand Paging is faster as compared to Segmentation. | Segmentation is slower in speed as compared to Pagination. |
Data Load | In case of Demand Paging, pages get loaded in the main memory at runtime when the user demands it. | In case of Segmentation, all the sections get loaded at the time of compilation. |
Data Record | In Demand Paging, there is a Page map table that manages the record of pages in memory. | In case of Segmentation, there is a Segment map table that manages every segment address in the memory. |
Conclusion
The most important point that you should note here is that Paging is a faster technique than Segmentation. In Paging, the pages are of fixed size and it is decided by the hardware. In contrast, the size of segments in Segmentation can vary as per the user's requirements.
- Related Articles
- Difference between Paging and Segmentation
- Difference Between Paging and Segmentation in OS
- Difference between Autonomous Demand and Derived Demand
- Difference Between Paging and Swapping in OS
- Difference between Aggregate Demand and Aggregate Supply
- What is paging?
- Demand Curve and The Law of Demand
- Region and Edge Based Segmentation
- What is Segmentation?
- Fashion Consumer Segmentation
- What is shadow paging in DBMS?
- Demand
- What is Market Segmentation?
- Image Segmentation by Clustering
- Overlay an image segmentation with Numpy and Matplotlib
