Introduction to Operating Systems: Unit III: Memory Management

Segmentation with Paging

Memory Management - Introduction to Operating Systems

Most of the architecture support paging and segmentation. All the pages of segment need not be in main memory.

Segmentation with Paging

• Most of the architecture support paging and segmentation. All the pages of segment need not be in main memory.

• It simplify the memory allocation and speed increases. It requires a high speed register to store the base address of the segment map table.

• For each segment, page table is created by OS. A pointer to the page table is kept in the segment's entry in the segment table.

• Segments are typically larger than pages.

• The base address get from the segment descriptor table is concatenated with the offset. This new address is referred to as a linear address. Linear address is generated by paging hardware.

Advantage

Combines all advantages of paging and segmentation.

Disadvantages

1. It increases hardware cost.

2. It increases processor overheads.

3. Dangers of thrashing.

Example 4.8.1 Paging system consists of physical memory 224 bytes, pages of logical address space is 256. Page size of 210 bytes, how many bits are in a logical address. Solution: Logical address space = 256 = 28

Page size = 210 bytes

So, Total logical address space = 28 x 210 = 218 bytes

For 218 byte address space - 18-bit address is required.

Example 4.8.2 On a system using simple segmentation, compute the physical address for each of the logical addresses, logical address is given in the following segment table. If the address generates a segment fault, indicate so.

Solution: a) 0, 99

Offset = 99;  Segment length = 124;  Segment = 0

* Offset 99 is less than segment length 124.

* Starting location of segment 0 is start from 330.

* Physical address = Offset + Segment base = 99 + 330 = 429

b) 2, 78

Segment = 2; Offset = 78; Segment length = 99

* Offset 78 is less than segment length 99

* Starting location of segment 2 is 111

* Physical address = Segment base + Offset = 111 + 78 = 189

c) 1, 265

Segment = 1; Offset 265; Segment length = 211

* Offset 265 is greater than segment length 211.

* This address results in a segment fault.

d) 3, 222

Segment = 3; Offset = 222; Segment length = 302

* Offset 222 is less than segment length 302.

* Starting location of segment 3 is 498

* Physical address = Segment base + Offset = 498 + 222 = 720

e) 0, 111

Segment = 0; Offset = 111; Segment length = 124

* Offset 111 is less than segment length 124.

* Starting address of segment 0 is 330

* Physical address = Segment base + Offset = 330 + 111 = 441

Example 4.8.3 System using a paging and segmentation, the virtual address space consists of upto 8 segments where each segment can be up to 229 byte long. The hardware pages each segment into 256 bytes pages. How many bits in the virtual address specify the

i) Segment number ii) Page number iii) Offset within page iv) Entire virtual address

Solution: i) Segment number: Virtual address space consists of upto 8 segments. So 

8 = 23

3 bits are needed to specify segment number.

ii) Page number: Hardware pages each segment into 256 byte pages. So

256 = 28 byte pages

Size of segment is 229 bytes.

229/28 = 229-8 = 221 = 21 pages

.. 21 bits are required to specify the page number.

iii) Offset within the page: For 28 byte page, 8 bits are needed.

iv) Entire virtual address = 3 + 21 + 8 = 32

Introduction to Operating Systems: Unit III: Memory Management : Tag: : Memory Management - Introduction to Operating Systems - Segmentation with Paging