You are on page 1of 17

Virtual Memory

LECTURE 5
VM Problems

Problem 2
Consider a VM systems with the following characteristics:
 Virtual address : 40 bits
 Page size : 16 KB
 Physical Address : 36 bits
 Control bits in a PTE take up 4 bits
 All virtual pages are in use
 Disk addresses are not stored in page table
Determine Page table size of each running process.
VM Problems

Problem 2
Consider a VM systems with the following characteristics:
 Virtual address : 40 bits
 Page size : 16 KB Page Offset bits = 14 b
 Physical Address : 36 bits Frame#= 36 – 14 = 22 b, Page#= 40-14=26 b
 Control bits in a PTE take up 4 bits
 All virtual pages are in use
 Disk addresses are not stored in page table
Determine Page table size of each running process.
VM Problems

40 bits
Virtual Address 26 14
Solution Page # Offset
# pages
= 226 = #PTEs 26 bits
Page table size PTE 22 4
= 226 * 26 bits Frame # Control
= (226 * 26)/8 B
= 223 * 26 B
= 8 * 26 MB
= 208 MB Table fragmentation
Problem 3
Assume that a task is divided into four equal-sized segments and that the
system builds an eight-entry page table for each segment. Thus the system
has a combination of segmentation and paging. Assume also that the page
size is 2KB.
 Calculate the maximum size of each segment?
 Calculate the maximum logical address space for the task?
 Assume that an element in the physical location 00021ABC is accessed by
this task. Calculate the format of this physical address? Calculate the
maximum physical address space for the system?
Problem 3
Assume that a task is divided into four equal-sized segments and that the system
builds an eight-entry page table for each segment. Thus the system has a
combination of segmentation and paging. Assume also that the page size is 2KB.
 Calculate the maximum size of each segment?
Each segment has eight pages of size 2KB each. Total Segment size= 2K*8=16KB
 Calculate the maximum logical address space for the task?
 Assume that an element in the physical location 00021ABC is accessed by this
task. Calculate the format of this physical address? Calculate the maximum
physical address space for the system?
Problem 3
Assume that a task is divided into four equal-sized segments and that the system
builds an eight-entry page table for each segment. Thus the system has a
combination of segmentation and paging. Assume also that the page size is 2KB.
 Calculate the maximum size of each segment?
Each segment has eight pages of size 2KB each. Total Segment size= 2K*8=16KB
 Calculate the maximum logical address space for the task?
The task is given 4 segments of 16KB each. Total VAS=4*16K=64KB
 Assume that an element in the physical location 00021ABC H is accessed by
this task. Calculate the format of this physical address? Calculate the
maximum physical address space for the system?
Problem 3
Assume that a task is divided into four equal-sized segments and that the system builds an eight-entry page
table for each segment. Thus the system has a combination of segmentation and paging. Assume also that
the page size is 2KB.
 Calculate the maximum size of each segment?
Each segment has eight pages of size 2KB each. Total Segment size= 2K*8=16KB
 Calculate the maximum logical address space for the task?
The task is given 4 segments of 16KB each. Total VAS=4*16K=64KB
 Assume that an element in the physical location 00021ABC is accessed by this task. Calculate the
format of this physical address? Calculate the maximum physical address space for the system?
The physical address given is of 32 bits. PAS=232 Bytes.
Offset takes 11 bits. (Page size= 2KB=211 B)
Format of the physical address is as follows:
21 bits Frame # 11 bit Offset
Problem 4
This question refers to the architecture using segmentation with paging. In this
architecture, the 32 bit virtual address is divided into fields as follows:
 4 bit segment number, 12 bit page number, 16 bit offset
 Find the physical address corresponding to the following virtual addresses
(answer bad virtual address if the virtual address is invalid):
 00000000 H _________________
 20022002 H _________________
 10015555 H _________________
 The contents of memory are given as under:
Segment table Page table A Page table B
0 Page table A 0 CAFE 0 F000
1 Page table B 1 DEAD 1 D8BF
2 (rest invalid) 2 BEEF X (rest invalid)
3 BA11
X (rest invalid)
Problem 4
This question refers to the architecture using segmentation with paging. In this
architecture, the 32 bit virtual address is divided into fields as follows:
 4 bit segment number, 12 bit page number, 16 bit offset
 Find the physical address corresponding to the following virtual addresses
(answer bad virtual address if the virtual address is invalid):
 00000000 H CAFE0000 H_________________
 20022002 H _________________
 10015555 H _________________
 The contents of memory are given as under:
Segment table Page table A Page table B
0 Page table A 0 CAFE 0 F000
1 Page table B 1 DEAD 1 D8BF
2 (rest invalid) 2 BEEF X (rest invalid)
3 BA11
X (rest invalid)
Problem 4
This question refers to the architecture using segmentation with paging. In this
architecture, the 32 bit virtual address is divided into fields as follows:
 4 bit segment number, 12 bit page number, 16 bit offset
 Find the physical address corresponding to the following virtual addresses
(answer bad virtual address if the virtual address is invalid):
 00000000 H CAFE0000 H_________________
 20022002 H bad virtual address _________________
 10015555 H _________________
 The contents of memory are given as under:
Segment table Page table A Page table B
0 Page table A 0 CAFE 0 F000
1 Page table B 1 DEAD 1 D8BF
2 (rest invalid) 2 BEEF X (rest invalid)
3 BA11
X (rest invalid)
Problem 4
This question refers to the architecture using segmentation with paging. In this
architecture, the 32 bit virtual address is divided into fields as follows:
 4 bit segment number, 12 bit page number, 16 bit offset
 Find the physical address corresponding to the following virtual addresses
(answer bad virtual address if the virtual address is invalid):
 00000000 H CAFE0000 H_________________
 20022002 H bad virtual address _________________
 10015555 H D8BF5555 H_________________
 The contents of memory are given as under:
Segment table Page table A Page table B
0 Page table A 0 CAFE 0 F000
1 Page table B 1 DEAD 1 D8BF
2 (rest invalid) 2 BEEF X (rest invalid)
3 BA11
X (rest invalid)
Problem 5
VM Problems Suppose that it takes 10 ns to conduct a parallel search in TLB and
Main Memory access time is 200 ns. Determine average memory
access time if TLB hit ratio is 80%. Assume no page fault.
Solution
TLB Hit:
access time in case of hit =10ns + 200 ns = 210 ns
TLB Miss:
1. Discovering that PTE is missed in TLB
2. Accessing PTE from the Page table
3. Accessing actual information from main memory
4. Time spent updating TLB
Assuming that 3 and 4 are parallel activities
access time in case of TLB miss = 10 ns + 200 ns + 200 ns = 410 ns
Average memory access time
= 0.8 * 210 + 0.2 * 410 = 250 ns
An aside on Paged- segmentation

 In paged-segmentation, programmer divides the VAS into multiple segments which are
subdivided in to pages by the system. For each and every segment, a page table is
constructed.
 One process has multiple segments
 One segment comprises multiple pages
 There is a page table maintained for each segment
 One process has a single segment table and multiple page tables (One for each
segment)

 Logical Address (VA) has three fields:


1. Segment #( determined from the number of segments the process has)
2. Page # (determined form the number of pages a particular segment has)
3. Offset (determined from the page size)
The benefits of segmentation were:
 Protection information was to be stored once for each segment
not for all individual pages. Protection and sharing was easier.

The benefits of Paging were:


 Easy memory allocation
 No external fragmentation

We combine the benefits of both the worlds in paged-segmentation.


 Sharing is easier. Sharing a segment means simply sharing the page
table of that segment. Sharing a page means simply copying the
page table entry in the page table of the segment.

You might also like