CSE 451
Winter 2000
Homework assignment 4 solutions
8.9
A process can only use virtual addresses to talk about memory, and all those addresses are translated by the operating systems into physical pages it owns. It has no vocabulary to talk about other address spaces.
The operating system could provide system calls to access other address spaces, which would take both an address and an address space identifier. An operating system might provide such a capability to allow debugging, in which a debugger can read memory of another process, or in client-server computing, where a trusted server can copy memory from the client process. Another possibility is to allow entries for other address spaces to be put in the page table for a process, which allows it to look at that memory.
8.11
The effect of having two page table entries point to the same physical page is that both addresses refer to the same data. This might be useful to provide a quick way to copy large pieces of data that will only be written infrequently, by simply updating the PTE of the destination to point to the PTE of the source. If the data is then written, either the change will be seen at both addresses, or if the OS has marked the destination PTEs as copy-on-write, the OS can then perform the copy operation.
8.14
A reentrant module is one that is executed by multiple processes simultaneously. The advantage of segments for sharing is that independent of the size of the memory shared, only one entry, that for the segment, is needed. In addition, if addresses can be made segment-relative, it is easier to have pointers within that segment because they can all be relative to the segment base rather than to an arbitrary virtual address.
8.17
9.3
The virtual address, in binary, is "0001 0001 0001 0010 0011 0100 0101 0110". (Supposedly it should have been hex but that wasnt obvious in the problem.) Since the page size is 2^12, the page offset is the last twelve bits. The other 20 bits are the virtual page number, which are used to lookup the corresponding physical page in the page table. Most of the lookup will be done in hardware. We look in the TLB with the 20 bits of VPN (hardware). If there is a miss, we go to the OS to refill the TLB using the page table (software). In the meantime, its likely that the lower 12 bits looked up the cache in parallel (hardware) and if the tag in the TLB matched the tag in the cache, we have a hit. If not, we go out to main memory with the TLB tag and the 12 bit offset. (This probably left out some details if you have any questions, e-mail Mike or Tim).
9.7
Benefits:
Costs:
For systems where there are only a small number of programs, and their memory requirements are well defined, virtual memory may not add many benefits and may slow down the programs.
9.9
9.17
Effective access time = 80 % * 1 microsoecond + // for entries in the TLB
20% * 2 microseconds + // for all TLB misses
2% * 20 milliseconds // for page faults
= 401.2 microseconds