Operating systems allow for more virtual memory allocation than the entire size of actual (physical) memory space on any given computer system. Before we set out to explain paging and segmentation, do know that they are both parts of memory management and an essential function of operating systems.
Here, we aim to throw light on paging and segmentation in the operating system, the difference between segmentation and paging, etc.
Segmentation vs. Paging
Segmentation and paging, help memory management processes unite large-sized slow memory along with small-sized high-speed memory for the sake of achieving higher-speed memory for more effective use.
|Basis of Difference||Paging||Segmentation|
|Function||Paging is utilized for getting an ample linear address space. This can be done without having to purchase more physical memory.||Segmentation permits codes, programs, and data to break up into independent address spaces. These spaces help in the sharing and protection of the programs.|
|Sharing of Procedures||Paging does not facilitate any sharing of procedures.||Segmentation allows for the sharing of procedures.|
|Knowledge of Memory limits||Paging is transparent and clear for programmers as the system manages it automatically.||Segmentation makes it essential for programmers to have prior knowledge of memory limits.
This has to be done even as the programmer attempts to allocate memory space to functions and variables, or strives to reach the read-only memory violation that eventually results in segmentation faults.
|Security for data and procedures||Paging fails to distinguish and secure processes and data in a separate fashion.||Segmentation differentiates between and secures procedures and data separately.|
|Physical memory||Paging is needed for getting a linear address space that is larger without making it essential to purchase more physical memory.||Segmentation permits programs and data segregation into independent address spaces. This enables sharing and protection.|
|Advantages||Paging is transparent to programmers, and therefore it eliminates the requirement of external fragmentation. It always ensures the efficient and effective use of the main memory space. The units that move across the main memory are of the same size and fixed. Therefore, complicated memory management algorithms for exploiting the program’s behavior are not possible.||Segmentation is visible and can be seen by developers. This process has the capability of managing the overall growth of modularity, data structure, and provides support for the exchange and protection of data.|
|Memory space wastage||In paged systems, memory in its physical form is divisible into blocks of equal magnitude. Processes are designated with a specified number of pages that happen to be larger than what’s required physically. Overall, lesser space is wasted when the last page is reached.||In segmented systems, as the allocated memory size is flexible, the operating system allocates the desired amount of space as asked for by the process. This may lead to memory space wastage in some instances.|
What is Paging?
In the operating system, paging means of writing and reading data to the secondary storage unit and use the same in the primary storage that’s referred to as the main memory. In computer architecture, paging serves a vital role in enabling memory management processes.
- To define paging in OS, we have to understand how OS reads and accesses data from the secondary storage in the form of blocks called pages. These blocks or pages have the same size.
- The physical area of memory comprises a single page referred to as a frame. While using paging, the structure need not include a singular physically contiguous space in the secondary storage.
- The approach of paging in computer architecture provides users with an advantage over conventional memory management methods. This because it allows for more efficient and speedier usage of the available storage.
What is Segmentation?
In an operating system, Segmentation means of achieving memory protection, which relates to the use of an instruction operand or a memory location. It includes a value that can identify a segment and an offset in that segment.
- Segmentation leads to the presence of a set of permissions, length, which is associated with the same.
- If the offset present in the segment lies in the range as specified by the segment’s length, then the referencing is permitted, else a hardware exception will be raised.
- The user program, as well as the associated data, is divisible into several segments. These segments need not be of the same size, even though there exists a maximum segment length.
- The logical address using the segmentation comprises of two parts - the number of segments plus the dislocations present in that segment.
The key difference between Paging and Segmentation
- An essential difference between paging and segmentation is that paging delivers virtual as well as physical address space.
- It also provides a secondary memory space in the form of blocks (pages) of equivalent lengths.
- Segmentation gives a virtual address space in the form of blocks (segments).
- These blocks correspond directly to objects on the programming level.
- Segments have no fixed length and can be altered during program execution.
- Yet another difference is that application developer are unaware of paging.
- To them, memory is linear; also, they know that the system and processing unit are managing the partition and converting them to virtual addresses.
- In segmentation systems, the segment and page are listed as two parts in the programs. The pages are of equal length, while the segments are different in size.
This tutorial explains user about paging vs. segmentation, the definitions of paging and segmentation in os, and how to explain segmentation with paging concept. Do tell us about your views on what is paging and segmentation as well. We shall wait to hear from you.