Midterm 51-69 Flashcards
What is the job of a “page table”?
It contains a translation (mapping) of virtual to physical addresses.
Assume that the logical address is 24 bits and the physical memory is 1MB. Also, assume that each page or frame is 4KB.
a) Show how the logical and physical addresses are partitioned.
b) What is the size of the page table?
c) Assume the logical address is ABCDEF, the content of the page table in line DEF is AB, and in line ABC is F5. Where in the physical memory, this logical address is mapped?
a) physical: 20 bits, frame: 8 bits, offset: 12 bits
virtual: 24 bits, page: 12 bits, offset: 12 bits
b) Page table has 2^12 lines.
c) Virtual address ABCDEF is at address F5DEF.
Imagine that we have fixed block sizes of size 2048 bytes. Also, imagine that the process size is P. Write a C code that, for 10000 times, randomly generates an integer P, between 1 and 20000. Then for each value of P, determine the amount of internal fragmentation and calculate the mean value of that. Copy/paste your code in your solution file. Also, report the average value of internal fragmentation.
See code on review Q53.
Fragmentation = block size - used bytes
Accessing the page table may have considerable delays. What is a solution to reduce the average delay of the page address mapping?
Use of TLB.
Practice Q55!!
On review!
What is the purpose of using “valid bit” in the page memory table?
This bit is just for protection purposes. The “valid” bit indicates that the associated page is in the process’s logical address space and is thus a legal page. When the bit is set to invalid, the page is not in the process’s logical address space. Illegal addresses are trapped by the use of the valid-invalid bit. The operating system sets this bit for each page to allow or disallow access to the page.
What is a “reentrant”page? Usually, reentrant pages belong to some specific processes. Name two examples of such processes.
The Reentrant code is non-self-modifying: it never changes during execution. Thus, two or more processes can execute the same code at the same time. Each process has its own copy of registers and data storage to hold the data for the process’s execution. The data for two different processes will, of course, be different. The reentrant page is a read-only copy of code shared among processes. Examples are text editors, compilers, C libraries, and windows systems.
Name three strategies that are used to reduce the size of page tables when the logical address is large.
Hierarchical Paging, Hashed Page Tables, Inverted Page Tables
Suppose that the logical address is 32 bits and the page offset is 12 bits. Show an example of a hierarchical page address.
Page number: p1 10 bits, p2 10 bits
Offset: 12 bits.
Why a hierarchical page addressing is not possible for 64-bit logical addressing? What are the two alternative methods?
Even a three- level page table requires a 2^32 line third-level table. If we use more page table layers, for example, eight layers, then going through all layers to find the address of a page would be prohibitively long. Alternative approaches are using hash tables and TLBs.
Explain the following diagram. What are p, q, s, r, and d? Suppose the 64-bit logical address of F1234567890ABCDE is mapped into the physical address of 4FFCDE. What are the values of p, d, and r? Also, give an example of the value of q.
Go to Q61 in review.
We see that pages are 4KB since the low significant 12 bits of the physical and logical addresses are the same. P is the page number which is 52 bits, and the first 13 Hex digits of the address. r is 4FF, and d is CDE. q is another 52-bit page number that is hashed into the same place as p is hashed to. Since we don’t know the hash function, we can throw in any 52-bit number as q. For example, CADF13571234F is q.
a) What is an “inverted page table?”
b) How can we limit the search process?
a) The page table is as big as the number of physical pages. This method makes the page table size much smaller than using a table that has 2^(number of virtual pages).
b) hashing could be used to limit the search. For example, the virtual page number is hashed in three different methods to restrict the search to only three entries of the inverted table.
The 64-bit Sparc Solaris uses two hash tables. What are these two tables? What is “page walk” in the memory mapping process of this system?
Two hash tables are used. One table is used for the user codes, and one table for the OS. Also, a TLB is used for fast search. Page walk: If the address is not in the TLB, the system “walks back” and searches the hash tables.
Some operating systems occasionally deactivate “swapping.” What is the purpose, and what are the occasions?
Swapping requires the transfer of data and code from the main memory to the backing store. The data transfer is time-consuming. In UNIX, swapping is disabled until the number of allocated pages becomes higher than a threshold.
Suppose that a process takes 200MB of the main memory. This process has to be swapped by sending it to the backing memory and bringing a new process, of the same size, into the main memory. The transfer rate is 150MB/sec. How long does this context switch will take?
200MB + 200MB = 400MB –> (400MB/150MB/sec) = 2.67 sec