Memory management is one of the basic functions of the operating system. Modern operating systems allow each process to get more virtual memory than the total size of the actual (physical) memory on a given computer system. The main goal of memory management is that by combining large but slow memory with small but high speed memory, to achieve the effect of larger high-speed memory.
What is Paging?
Separating between fixed and variable partitioning is ineffective in terms of memory utilization, since fixed partitioning results in internal, while dynamic in external fragmentation. A possible solution to the problem of fragmentation is to allow the process not to be written to a continuous memory block. The program can be scattered arbitrarily in the memory. In this case, the working memory is divided into smaller blocks of fixed size called frames. The logical address space of the program is also divided into blocks of the same size, called pages. When a program is entered into the memory, the pages are written into free memory frames. For ease of transferring programs from a disk to a working memory, the disk is also divided into frames of the same size as the memory frames. Thus, one frame from the disk is written into one frame of the working memory. The paging system operates in the following manner: when the program is accepted for execution, its size is calculated, which is expressed with the required number of pages. If a sufficient number of frames is free, the process is recorded in the memory page per page. At the same time, the number of frames in which each page are written is entered in the frame table.
What is Segmentation?
The user program and associated data can be divided into a number of segments. Segments of all programs don’t have to be of the same size, although there is a maximum segment length. As with paging, the logical address that uses the segmentation consists of two parts, in this case the number of segments and dislocations within that segment. Because of the use of segments of different sizes, segmentation is similar to dynamic partitioning. In absence of an overlay scheme or use of virtual memory, it is required that all program segments are loaded into the memory for execution. The difference compared to dynamic partitioning is that segmentation can take more than one partition, and that partition does not have to be adjacent. Segmentation solves the problem of internal fragmentation, but as well as dynamic partitioning, the problem of external fragmentation remains. However, because the process is divided into a number of smaller parts, the external fragmentation is typically smaller. Unlike paging which is invisible to the programmer, segmentation is usually visible and suitable for organizing programs and data. For the purpose of modular programming, the program or data can be further divided into several smaller segments. The downside of this technique is that the programmer must know the limitations of the maximum segment size. The next convenience of using segments of different sizes is that there is no prospective connection between logical and physical addresses. Similar to paging, the simple segmentation technique uses segments table for each process and a list of available blocks in the main memory.
Difference Between Paging and Segmentation
1. Concept of Paging and Segmentation
Paging delivers a virtual and a physical address space, and a secondary memory space on blocks (pages) of equal lengths. This allows the continual virtual address space to be allocated to the process of dispersion (not necessarily continually distributed) in the real address space and secondary memory. Even the page, as a term, refers to memory rather than logical objects that are visible at the program level. Segmentation delivers a virtual address space on blocks (segments) that directly correspond to objects at the program level. Because of this, the segment has no fixed length, so even the segment size can be changed during program execution. Protection and division are, therefore, possible at the object level, and there are visible processes where segmentation is performed.
2. Characteristics of Paging and Segmentation
The application developer is unaware of the paging. He writes programs as if the memory is linear, and the operating system and processor are concerned about its partitioning and converting to virtual addresses. Programmer on segmentation systems, however, lists two parts of the address, segment and page in their programs. All pages are of the same size while the segments are different. Segmentation has multiple linear address spaces, and paging only one. Segments allow logical partitioning and protection of application components, and pages do not.
3. Advantages of Paging and Segmentation
Paging, which is transparent to the programmer, eliminates external fragmentation and thus ensures efficient use of the main memory. The pieces that move in and out of the main memory are fixed and the same size, so it is possible to develop sophisticated memory management algorithms that exploit the program’s behavior. Segmentation is visible to the developer and has the ability to manage the growth of data structure, modularity, and support for exchange and protection.
Paging vs. Segmentation: Comparison Chart
Paging |
Segmentation |
fixed pages size | segments are not fixed in size |
invisible for programmer | visible for programmer |
one linear address space | multiple linear address spaces |
doesn’t allow logical partitioning and protection of application components | allows |
Summary of Paging and Segmentation
- Paging is based on the distribution of the entire address space on fixed-length blocks that are operated as memory quantizes. Further, it is necessary to provide a means for marking available memory that can be executed by the presence of the “header” of each page indicating the status of the page (global linked list where each node points to the next free page) or by placing the free page address in the global array, which is usually the worst solution.
- Segmentation means dividing the address space into segments that have clearly marked access rights to the MMU processor. Within the segment, the processes allocate exactly as much memory as they need, but the problem of memory management is how to provide such an allocation where it can preserve large enough continuous block memory that may need some time.