Hardware Reference
In-Depth Information
A program that generates page faults frequently and continuously is said to be
thrashing . Needless to say, thrashing is an undesirable characteristic to have in
your system. If a program uses a large amount of virtual address space but has a
small, slowly changing working set that fits in available main memory, it will give
little trouble. This observation is true, even if, over its lifetime, the program uses
hundreds of times as many words of virtual memory as the machine has words of
main memory.
If a page about to be evicted has not been modified since it was read in (a like-
ly occurrence if the page contains program rather than data), it is not necessary to
write it back onto disk, because an accurate copy already exists there. If it has
been modified since it was read in, the copy on the disk is no longer accurate, and
the page must be rewritten.
If there is a way to tell whether a page has not changed since it was read in
(page is clean) or whether it, in fact, has been stored into (page is dirty), all the
rewriting of clean pages can be avoided, thus saving a lot of time. Many com-
puters have 1 bit per page, in the MMU, which is set to 0 when a page is loaded
and set to 1 by the microprogram or hardware whenever it is stored into (i.e., is
made dirty). By examining this bit, the operating system can find out if the page is
clean or dirty, and hence whether it need be rewritten or not.
6.1.5 Page Size and Fragmentation
If the user's program and data accidentally happen to fill an integral number of
pages exactly, there will be no wasted space when they are in memory. Otherwise,
there will be some unused space on the last page. For example, if the program and
data need 26,000 bytes on a machine with 4096 bytes per page, the first six pages
will be full, totaling 6
×
4096 = 24,576 bytes, and the last page will contain 26,000
24576 = 1424 bytes. Since there is room for 4096 bytes per page, 2672 bytes
will be wasted. Whenever the seventh page is present in memory, those bytes will
occupy main memory but will serve no useful function. The problem of these
wasted bytes is called internal fragmentation (because the wasted space is inter-
nal to some page).
If the page size is n bytes, the average amount of space wasted in the last page
of a program by internal fragmentation will be n /2 bytes—a situation that suggests
using a small page size to minimize waste. On the other hand, a small page size
means many pages, as well as a large page table. If the page table is maintained in
hardware, a large page table means that more registers are needed to store it, which
increases the cost of the computer. In addition, more time will be required to load
and save these registers whenever a program is started or stopped.
Furthermore, small pages make inefficient use of disk bandwidth. Given that
one is going to wait 10 msec or so before the transfer can begin (seek + rotational
delay), large transfers are more efficient than small ones. With a 100-MB/sec
transfer rate, transferring 8 KB adds only 70 μ sec compared to transferring 1 KB.
 
 
Search WWH ::




Custom Search