0% found this document useful (0 votes)
27 views11 pages

22bi13022 hw5 13 16

The document contains the student's homework on virtual memory systems. It includes: 1) Analyzing a virtual address and determining the page number and offset 2) Calculating the number of bits needed for a virtual address space 3) Determining the minimum number of page faults for code that accesses an array 4) Describing the virtual address format, virtual address space size, page table size, and minimum/maximum memory access times for a system with given parameters.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views11 pages

22bi13022 hw5 13 16

The document contains the student's homework on virtual memory systems. It includes: 1) Analyzing a virtual address and determining the page number and offset 2) Calculating the number of bits needed for a virtual address space 3) Determining the minimum number of page faults for code that accesses an array 4) Describing the virtual address format, virtual address space size, page table size, and minimum/maximum memory access times for a system with given parameters.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Homework 5

ex13-16
Nguyễn Hoàng Anh
22bi13022
13
• A computer uses pages of 8 KB. Given the following virtual address: 0x20018004, indicate the
virtual address size, the page number, and the displacement of this address.
• a virtual address space (VAS) or 
address space is the set of ranges
of virtual addresses that an 
operating system makes available
to a process.
• The virtual address size depends on the specific architecture, but assuming a 32-bit architecture,
the size would be 4 bytes (32 bits).

To find the page number and displacement of the virtual address, we need to split it into two
parts: the most significant bits represent the page number, and the least significant bits represent
the displacement within the page.

In this case, the virtual address is 0x20018004. Converting to binary, we get:


```
00100000000000011000000000000100
```

Since each page is 8 KB or 2^13 bytes, we can split the binary address into the page number and
displacement by taking the most significant 20 bits as the page number and the least significant
13 bits as the displacement:
```
Page number: 00100000000000011000 (0x20018)
Displacement: 000000000100 (0x004)
```

Therefore, the page number for this virtual address is 0x20018, and the displacement within the
page is 0x004. 
14
• A computer has a virtual address space of 256 Kpages of 8 KB each
one, and a physical memory of 128 MB. How many bits does the
virtual address have?
• To calculate the bits needed for the virtual address, we need to first calculate the total virtual address space:
256 Kpages x 8 KB/page = 2,048 MB

• Since 2,048 MB is greater than the physical memory of 128 MB, it means that the virtual address space
cannot fit entirely in physical memory. This also means that some form of memory management such as
paging or segmentation must be used.

• To determine the bits needed for the virtual address, we can use the formula:
bits = log2(size)
where "size" is the size of the virtual address space in bytes.

• Converting the 2,048 MB to bytes:


2,048 MB x 1024 KB/MB x 1024 B/KB = 2,147,483,648 bytes

• Calculating the bits needed:


bits = log2(2,147,483,648)
bits = 31

Therefore, the virtual address of this computer must have at least 31 bits
15
Consider a computer with virtual addresses of 32 bits and pages of 8 KB.
• a) Describe the virtual address format.
• b) What if the maximum number of entries included in the page table (one level page table)? Why?
• c) Given the following code fragment:
int a[1000000];
for (j = 1; j < 890000; j++) {
a[j] = a[j-1] + 1;
}
And assuming that the main memory is empty, what is the minimum page faults produced when this code is executed.
Data and instructions are stored in different pages.
a) The virtual address format in this case will consist of 32 bits, divided into a page number and
page offset. The page number will occupy the most significant bits, while the page offset will occupy
the least significant bits.

b) The maximum number of entries included in the page table would be 2^20, since there are 2^32
possible virtual addresses with a page size of 8 KB. Each page table entry would store the physical
address corresponding to the virtual address, as well as any additional flags or information about
the page.

c) In this code fragment, the array 'a' has a million elements, but only 890,000 of them are accessed
in the loop. Assuming that each page can hold 8 KB of data, this means that the array 'a' would be
divided into 125 pages, each containing 8,000 elements. The loop accesses 890,000 elements,
which is equivalent to accessing 111.25 pages.

Since the main memory is empty, the first access to each page will result in a page fault. Therefore,
there will be a total of 112 page faults produced when this code is executed. This is because the first
access to the first page of the array will cause a page fault, and each subsequent access to a new
page will also cause a page fault until all 112 pages have been accessed at least once.
16
A virtual memory system has the following features:
1. The total page number is 512 and the page size is 8 KB.
2. Memory addressed by bytes.
3. Physical memory size: 1MB
4. The memory system does not have cache memory, but it includes a TLB.
5. The page table is not paged nor segmented.
6. The disk access time in 12 ms, memory access time is 40 ns, and the TLB access time is 20ns.
• a) Describe the virtual address format.
• b) What is the size of the virtual address space?
• c) What is the page table size? Assume that there are 3 control bits in each entry.
• d) What is the maximum and minimum memory access time?
• a) The virtual address format consists of two parts: the page number and the offset within the
page. With a page size of 8 KB, the offset requires 13 bits (2^13=8,192). Since there are 512
pages, the page number requires 9 bits (2^9=512). Thus, the virtual address format is 22 bits,
with the first 9 bits representing the page number and the last 13 bits representing the offset.

b) The size of the virtual address space is determined by the number of bits in the virtual address
format. Since the format is 22 bits, the virtual address space is 2^22 bytes, or 4,194,304 bytes (or
4MB).

c) The page table size is determined by the number of entries needed to map all 512 pages. Since
each entry requires 3 control bits, the total size of the page table is (512 x 3) bits, or 192 bytes.

d) The maximum memory access time occurs when a page fault occurs and the system must
retrieve a page from disk. In this case, the access time is the sum of the TLB access time (20ns),
the disk access time (12ms or 12,000,000ns), and the memory access time (40ns), or
approximately 12,020,060ns.

The minimum memory access time occurs when the requested page is already in physical
memory and is located in the TLB. In this case, the access time is the sum of the TLB access time
(20ns) and the memory access time (40ns), or 60ns.

You might also like