Java Reference
In-Depth Information
of a buffer pool to store data read from blocks on slower, secondary memory (such
as on the disk drive). The disk stores the complete contents of the virtual memory.
Blocks are read into main memory as demanded by memory accesses. Naturally,
programs using virtual memory techniques are slower than programs whose data
are stored completely in main memory. The advantage is reduced programmer ef-
fort because a good virtual memory system provides the appearance of larger main
memory without modifying the program.
Example8.2 Consider a virtual memory whose size is ten sectors, and
which has a buffer pool of five buffers (each one sector in size) associated
with it. We will use a LRU replacement scheme. The following series of
memory requests occurs.
9017668135171
After the first five requests, the buffer pool will store the sectors in the order
6, 7, 1, 0, 9. Because Sector 6 is already at the front, the next request can be
answered without reading new data from disk or reordering the buffers. The
request to Sector 8 requires emptying the contents of the least recently used
buffer, which contains Sector 9. The request to Sector 1 brings the buffer
holding Sector 1's contents back to the front. Processing the remaining
requests results in the buffer pool as shown in Figure 8.5.
Example8.3 Figure 8.5 illustrates a buffer pool of five blocks mediating
a virtual memory of ten blocks. At any given moment, up to five sectors of
information can be in main memory. Assume that Sectors 1, 7, 5, 3, and 8
are currently in the buffer pool, stored in this order, and that we use the
LRU buffer replacement strategy. If a request for Sector 9 is then received,
then one sector currently in the buffer pool must be replaced. Because the
buffer containing Sector 8 is the least recently used buffer, its contents will
be copied back to disk at Sector 8. The contents of Sector 9 are then copied
into this buffer, and it is moved to the front of the buffer pool (leaving the
buffer containing Sector 3 as the new least-recently used buffer). If the next
memory request were to Sector 5, no data would need to be read from disk.
Instead, the buffer already containing Sector 5 would be moved to the front
of the buffer pool.
When implementing buffer pools, there are two basic approaches that can be
taken regarding the transfer of information between the user of the buffer pool and
the buffer pool class itself. The first approach is to pass “messages” between the
two. This approach is illustrated by the following abstract class:
 
Search WWH ::




Custom Search