Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Q1. Suppose we have a virtual memory of size 2 Terabytes (2048GB, or 241 bytes),

ID: 3702246 • Letter: Q

Question

Q1. Suppose we have a virtual memory of size 2 Terabytes (2048GB, or 241 bytes), where pages
are 8KB (213 bytes) each, and the machine has 4GB (232 bytes) of physical memory.
a) Compute the number of page table entries needed if all the pages are being used.
b) Compute the size of the page table if each page table entry also required 4 additional bits
(valid, protection, dirty, use).
Q2. For this problem, you are given a system with a virtual memory. The virtual memry hads
the following configuration –
• Physical addresses are 8 bits long, but only 27 = 128 bytes of physical memory is
installed, at physical addresses 0 up to 127.
• Pages are 24 = 16 bytes long. Virtual addresses are 10 bits long.
• An exception will be raised if a program accesses a virtual address whose virtual page
has no mapping in the page table. Exception will also be raise if this is mapped to a
physical page outside of installed physical memory.
• The main memory contents are shown in Table 1. To find the physical address of a byte,
you need to read the least significant digit from the column label and the most significant
digit from the row label. For example, the shaded byte in the second row is at physical
address 0x12. All entries are in hexadecimal.

Problem 2 [12 points]
Consider a tiny system with virtual memory. Physical addresses are 8 bits long,
but only 27 = 128 bytes of physical memory is installed, at physical addresses 0
up to 127. Pages are 24 = 16 bytes long. Virtual addresses are 10 bits long. An
exception is raised if a program accesses a virtual address whose virtual page
has no mapping in the page table, or is mapped to a physical page outside of
installed physical memory.
The contents of main memory are shown in Table . To find the physical address
of a byte, read the least significant digit from the column label and the most
significant digit from the row label. For example, the shaded byte in the second
row is at physical address 0x12. All entries are in hexadecimal.

0x0


The page table is shown in Table 2. The virtual page number in the left column
is mapped to the physical page number in the second column. Virtual page
numbers are listed in binary.


a) List the four bytes in the word beginning at physical address 0x34.
b) How many virtual addresses refer to the first byte of the shaded word in row 0x2 ? List
them ALL.
c) How many virtual addresses refer to the first byte of the shaded word in row 0x4 ? List
them ALL.
d) List all virtual addresses that refer to the first byte of the shaded word in row 0x6.
e) If the program loads a word from virtual address 0x5C (01011100), write down what
data is returned?
f) What is the result if the program loads a word from virtual address 0x64 (01100100)?

0 1 2 3 4 5 6 7 8 9 A B C D E F

0x0

4e 65 76 65 72 20 67 6f 6e 6e 61 20 67 69 76 65 0x1 20 79 6f 75 20 75 70 0a 4e 65 76 65 72 20 67 6f 0x2 6e 6e 21 20 6c 65 74 20 79 6f 75 20 64 6f 77 6e 0x3 0a 4e 65 76 65 77 20 67 6f 6e 6e 61 20 72 75 6e 0x4 20 61 72 6f 75 6e 64 20 61 6e 64 20 64 65 73 65 0x5 72 74 20 79 6f 75 0a 4e 65 76 65 72 67 6f 6e 6e 0x6 6e 61 20 6d 61 6b 65 20 79 6f 75 20 63 72 79 0a 0x7 4e 65 76 65 72 20 67 6f 6e 6e 61 20 73 61 79 20

Explanation / Answer

ANSWER:

              Now we have to find the virtual memory

              Number of pages in virtual memory

                =size of virtual memory/page size

                   =2^10/2^4=2^6 pages.

                    =(2^8 / 2^4)

                         =2^(8-4)

                            =2^4 pages

                    No of pages frames in main memory = 2^8 / 2^4 Pages = 2^4 page frames.

              The following steps are to be followed in a calculating page table entries for virtual memory:

Log2(2^4)=4. So, the page offset is 4 bits.

finally, The total number of page table entries to represent all virtual addresses is 2^6 entries.