a system using a combined segmentation and paging Problem

92 Views Asked by At

In a system using a combined segmentation and paging: the max segment size is 4 MB, the page size is 4 KB, the process virtual memory size is 4 GB and the physical memory (RAM) size is 4 GB. It’s desired to limit the page table size to one page. The free frame list is (10, 20, 30, 40, 50, 60, 70, 80). Frames allocation is done from the list head (left most). Process A with 2 segments of size 3 KB and 6 KB, respectively, will be completely loaded into RAM.

For process A: what’s the start address of its segment table? Construct its segment table and page tables showing the following: (Assume the 1st segment is completely loaded before the 2nd one) a.segment table fields: segment number, base and limit. b.Page table fields: page number and frame number). What’s the process A virtual address that corresponds to physical address (0003C000)16? How the virtual address will be calculated

How the virtual address will be calculated I tried to solve it but the answer is different

1

There are 1 best solutions below

0
Juntire On

Segment table for process A:

Segment number Base Limit
0 0 3 KB
1 3 KB 9 KB

Page tables for process A:

Segment number Page number Frame number
0 0 10
0 1 20
1 0 30
1 1 40

How to calculate the virtual address that corresponds to physical address (0003C000)16:

  1. The physical address is within the range of the second segment (3 KB to 9 KB).
  2. The page offset is 3C000 / 4096 = 9.
  3. The virtual address is calculated as follows:
Virtual address = Segment base address + Page number * Page size + Page offset
Virtual address = 3 KB + 1 * 4 KB + 9 = 7096

Therefore, the virtual address that corresponds to physical address (0003C000)16 is 7096.

Explanation:

In a combined segmentation and paging system, the virtual address is translated to a physical address in two steps:

  1. The segment number is used to index the segment table to get the segment base address and limit.
  2. The page number is used to index the page table for the segment to get the frame number.
  3. The frame number is used to get the physical address from the physical memory.

The following diagram shows how the virtual address is translated to a physical address in a combined segmentation and paging system:

                            +-----------------------+
                            |       Segment table     |
                            +-----------------------+
                                 |
                                 |
                                 V
                    +-----------------------+
                    |       Page table       |
                    +-----------------------+
                        |
                        |
                        V
                    +-----------------------+
                    |       Physical memory   |
                    +-----------------------+

The virtual address is split into three parts:

  • Segment number: This part is used to index the segment table.
  • Page number: This part is used to index the page table for the segment.
  • Page offset: This part is used to locate the byte within the frame.

The physical address is calculated as follows:

Physical address = Segment base address + Page number * Page size + Page offset

In the case of process A, the virtual address 7096 is translated to the physical address (0003C000)16 as follows:

Segment number = 1
Page number = 1
Page offset = 9

Segment base address = 3 KB
Page size = 4 KB

Physical address = 3 KB + 1 * 4 KB + 9 = 7096