Segmentation with Paging in OS

Paging:

It is an efficient memory management scheme, it is a non-contiguous memory allocation method. The basic idea of paging is physical memory (Main memory) is divided into fixed-sized blocks called Frames. The logical address space is divided into fixed-sized blocks called Pages but page size and frame size should be equal. The size of the frame or page is depending on the operating system. Generally, the page size is 4 KB.

Advantages of using Paging:

1. It supports the Time-sharing System.
2. It doesn’t affect fragmentation.
3. It supports virtual memory.
4. Sharing of common code is possible.

Disadvantages of using Paging:

1. This scheme may suffer ‘page breaks’.
2. If the number of pages is high, it is difficult to maintain page tables.

Segmentation:

Each process is divided into a number of segments. A process is loaded by loading all of its segments into dynamic partitions. Segmentation is the technique for managing segments.

Advantages of Segmentation:

1. Segmentation supports virtual memory.
2. It allows dynamically growing segments.
3. Eliminate fragmentation.
4. Dynamically linking and loading the segments.
5. Facilitate shared segments.

Segmentation with Paging:

It is better possible to combine these two schemes to improve on each. The combined scheme was ‘Page the segments’. Each segment in this scheme is divided into pages and each segment maintains a page table. So, the logical address is divided into 3 parts. One is the segment numbers and second is the page number and another is displacement or offset(D).

The logical address space is divided into 3 segments numbered 0 to 2. Each segment maintains a page table, and the mapping between the page and frame is done by a page table.

Advantages of Segmentation with Paging:

1. Avoid fragmentation
2. It supports ‘user view of memory’.
3. It also has Hardware support.