Segmentation in OS - How is it different from Paging

By:   Last Updated: in: ,

Operating System: Q1.Memory Segmentation in OS? - How is it different from Paging? or Paging and Segmentation in OS? (Operating System all notes)

Segmentation-in-OS

Q1. What is Memory Segmentation in OS? How is it different from Paging?

Ans. Memory Segmentation: Memory segmentation is a technique of non-contiguous memory allocation. In segmentation, the logical memory space is divided into certain unequal size chunks known as segments. According to segmentation, an application is loaded into memory as a collection of modules. In other words, the logically related instructions and data items are grouped and loaded into a segment.

For Example: An application can consist of five modules: the main program, function A, function B, the stack for storing data when a function is called, and shared data for all the modules such as global variables. Each module is loaded in a distinct segment in the main memory.
[ Topic= Paging and Segmentation in OS ]

Accessing Addresses in Segmentation:

In a segmented memory, a logical address consists of two parts: Segment number and offset. An offset is the location within a segment, where any particular data is stored. e.g., : The logical address 3:10,000 indicates offset 10,000 and segment number 3.
A segment table, which has two fields: the base address of the segment and the size of the segment, is used for validation of an address. The base address of a segment is the location of a particular segment in the main memory, from where the segment starts.
Segments-and-Segment-Table-in-OS-Diagram
This elaborates various memory segments in the main memory and their corresponding entries in the segment table. The segments need not to be loaded sequentially. e.g., : Segment 2 has been loaded in a lower position in the memory than in segment 0. The starting address and size of segments are stored in the segment table.
For example, the base or starting address of the segment 2 is 60,000 and size of segment 2 is 15,000 bytes.

When accessing an address in a segmented memory, the segment table is used for validation The logical address 2:12,000 indicates the location 12,000 starting from the base of the segment 2. The segment to start from the location 60,000 and its size is 15,000 bytes.
[ Topic= Paging and Segmentation in OS ]

Segmentation with Paging: Paging and Segmentation in OS

Segmentation of memory can be implemented with a paging scheme. The unequal size segment can be represented by equal size pages. e.g. In a logical address space of 64 KB there are 32 pages of 2 KB each. A program is divided into 3 segments of the size 15 KB. 18 KB. 10 KB. These three segments require 8, 9, and 5 pages respectively to be loaded into the memory.

The first segment occupies the memory space of 8 pages of 2 KB each or 18 KB each, whereas it's requirement is 15 KB memory space. Thus, an internal fragmentation of 1 KB occurs.

In segmentation with a paging scheme two tables are used: a segment table and a page table. The segment table has two fields : base address and size. The base address of a segment is the address of the first page in the segment.
The size of the segment is the number of pages a segment occupies. The page table stores the address of a frame where a page is loaded into the memory.

For example: Value of the 15th cell of page table is 38,000. This mean that page 15 has been loaded into the frame located at the address 38,000 in the main memory.
Paging-and-Segmentation-in-OS-Diagram




[ Topic= Paging and Segmentation in OS ]
[ Topic= Paging and Segmentation in OS ]
[ Topic= Paging and Segmentation in OS ]



Join us on Facebook, Instagram, and Twitter to get the latest study material. You can also ask us any questions.
Facebook = @allbcaweb
(click on it or search "allbcaweb" on Facebook)
Instagram = @allbcaweb
(click on it or search "allbcaweb" on Instagram)
Twitter = @allbcaweb
(click on it or search "allbcaweb" on Twitter)
Email= allbca.com@gmail.com
Send us your query anytime about Paging and Segmentation in OS!


External Links:-

1. Segmentation in OS - (click here)
2. Paging and Segmentation in OS - (click here)

[ Topic= Paging and Segmentation in OS ]
[ Topic= Paging and Segmentation in OS ]

No comments:
Write comment