CS 481: Solutions for Test #2 |
Problem 1. Suppose you have a byte-addressed computer system with a 44-bit logical address. The page size is 64Kbytes and each page entry takes 4 bytes.
64Kbytes is 2**16 bytes; thus there are (2**44)/(2**16)=2**28 (roughly a quarter billion) pages in the logical address space.
64Kbytes is 2**16 bytes; since each page entry takes 4 bytes, a page of 2**16 bytes can store 2**14 page entries. Since the machine is byte addressed, the displacement within a page of 2**16 bytes requires a 16-bit field. Since the full logical address has 44 bits, everything works out just right: we use a 14-bit master page index, a 14-bit secondary page index, and a 16-bit displacement, for a total of 44 bits.
4Gbytes is 2**32 bytes; since the size of a page is 2**16 bytes, we will need a total of (2**32)/(2**16)=2**16 page frames. A secondary page table (which fits within one frame) can address 2**14 page frames, so we will need (2**16)/(2**14)=4 such page tables, plus the master page table itself, for a total of 5 additional page frames. So the program needs (2**16)+5=65541 page frames in all.
Problem 2. You have a RISC machine with a paged virtual memory system. Because the machine is a RISC architecture, every machine instruction references at most one location in memory---of course, you also have to bring in the next instruction. Moreover, these instructions cannot branch---they are simply transfers between a CPU register and a memory location. Assume that, in a typical program, 30% of the instructions reference a memory location and 20% are branching instructions (i.e., cause the program counter to change drastically).
The TLB takes 20ns to respond; a memory access costs you 200ns; and a disk access costs you 10ms.
Further assume that the address decoding is serial: we first go to the TLB; if it fails, we go to the page table; if it fails, we go to the disk. In all cases, we go to the memory last to get what we need. Then the average time for one memory access is
This should improve things, but of course not enough, since it cannot do better than cut in half the contribution of page faults -- which would still leave us in the neighborhood of 16 microseconds... Let us carry out the exact computation. This time, we divide the instructions into three categories: the branching instructions, the memory transfer instructions, and all others.
The branching instructions (20% of the running code) are not affected at all: the one memory access they cause still takes an average of 25.23 microseconds and so they contribute 0.2*25.23=5.046 microseconds to the average. The "other" instructions (50% of the running code) are improved the most: their one memory access (for the next instruction) has half the original page fault rate and so takes an average of
Thus the overall average time spent in memory access per instruction is now 5.046+6.365+9.888=21.299 microseconds. Compare this figure with the best we could do: 100% hit in the TLB and thus 220ns per memory access and thus 1.3*210=286ns per instruction. The ratio remains very high: we are about 74 times slower than the optimal.
Problem 3. Which of the following programs are likely to do well in a paging environment and which are likely to do poorly (assume that all operate on very large data sets)? For each, indicate briefly why.
Problem 4. Your paged computer system is performing miserably. On measuring various parameters, you find the following: CPU utilization is 20%, swap device utilization is 98%, and other I/O device utilization is 5%. Which of the following measures (if any) would be likely to improve your system and why?
Problem 5. You find out that the page fault rate in your paging system is extremely low -- say on the order of 0.00001%. Is that entirely good news? Can you think of reasons why you might want to take another look at your system and perhaps modify it?
That was something of a bonus question, because there is no single good answer. If paging is that low, there is some reason to think things are just cool; but you may also suspect that the degree of multiprogramming is lower than it could be -- that you could raise it and increase responsiveness without seriously affecting performance. A "back-of-the-envelope" calculation shows that, even with fast 100ns memory and average 10ms disk, we can afford a page fault rate on the order of 100ns/10ms or about 1 in 100,000, or about 0.001%; that exact page fault rate would roughly double the memory access time, so something like 0.0001% would be utterly safe, adding only 10% to the memory access time. That is 10 times the observed rate, so there is quite a margin for increasing the degree of multiprogramming.
Another suspiscion is that your paging system is so good because it adopts the old IBM philosophy, soaking up 90% of the resources of your system to do a superb job of managing what's left. (It might spend enormous amounts of time running intricate prediction schemes, running various diligent daemons, prepaging, etc.) So you should check on speed/turnaround time/throughput and see where your other resources go.
Then there are other observations: a system that is nearly that quiescent may in fact have serious problems! For instance, there is only one job running and it is caught in a tight infinite loop -- no paging at all! Or one big job somehow hogged all page frames, runs comfortably with little or no I/O, and has not yet been swapped out -- very little paging. Other less likely failures may suggest themselves as well.
| Back to CS 481 home page |