|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sun.jimi.core.vmem.PageMapper
A class for managing the swapping of paged virtual memory. The PageMapper is responsible for providing access to arbitrary fixed-size areas, or "pages", of image data through in-memory buffers, or "page frames". The page mapper maintains a set of page frames which are accessed one at a time, pages of data are then "swapped" in and out of page frames as required. The specific algorithm is this: A set of page frames are created, and when a page is requested it is loaded into one of the frames and passed out. The request will have to ask for a frame explicitly for reading or writing, if it is accessed for writing the page frame is marked as modified so that when it has to be reused, its page data will be committed to secondary storage. When a page is requested and there are no empty page frames, the least-recently-used frame will be swapped out (written if modified, otherwise simply overwritten in memory) and replaced with the data for the requested page. Some useful terms defined: Page: a fixed-size rectangular logical area of data, numbered from from left to right, top down. Page Frame: an in-memory buffer representing a page of data. Page Mapper: object responsible for providing page frames to access paged data in secondary storage and keeping modifications in sync. Page Fault: if a requested page does not exist in memory and has to be read in from disk, a page fault is said to have occured.
Field Summary | |
protected java.io.InputStream |
input
InputStream representation of the secondary storage |
protected java.awt.Dimension |
logicalSize
logical image dimensions in pixels |
protected int |
numberOfPageFrames
|
protected java.io.OutputStream |
output
OutputStream representation of the secondary storage |
protected java.awt.Dimension |
pageDimensions
|
protected int |
pageFaults
|
protected int |
pageFrameMemory
how many kbytes of memory to use for page frames |
protected RandomAccessStorage |
storage
secondary storage to swap to/from |
Constructor Summary | |
PageMapper(RandomAccessStorage storage,
java.awt.Dimension logicalSize,
int pageFrameMemory)
Construct a page mapper with specified secondary storage and size. |
Method Summary | |
void |
commitPage(PageFrame pageFrame)
Commit a page to secondary storage. |
protected void |
configurePageFrames()
Determine how many page frames to use, and what sizes they will be. |
java.awt.Dimension |
getLogicalSize()
Get the logical size of the image data. |
PageFrame |
getPageFrame(int logicalPageNumber)
Return a PageFrame representing a specified logical page number. |
PageFrame |
getPageFrameForReading(int logicalPageNumber)
Return a PageFrame representing a specified logical page for read-only use. |
PageFrame |
getPageFrameForWriting(int logicalPageNumber)
Return a PageFrame representing a specified logical page for read-write use. |
abstract PageFrame[] |
getPageFrames()
Return the page available page frames. |
abstract int |
getPageSize()
Return the size in bytes of a page. |
protected abstract int |
getPixelSize()
Return the byte-size required to store one pixel. |
int |
howManyPageFaults()
Find out how many page faults have occured. |
void |
readPageIntoFrame(PageFrame pageFrame,
int logicalPageNumber)
Read a page in from secondary storage. |
void |
resetPageFaultCount()
Reset the page fault count. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected RandomAccessStorage storage
protected java.awt.Dimension logicalSize
protected int pageFrameMemory
protected int pageFaults
protected java.io.OutputStream output
protected java.io.InputStream input
protected int numberOfPageFrames
protected java.awt.Dimension pageDimensions
Constructor Detail |
public PageMapper(RandomAccessStorage storage, java.awt.Dimension logicalSize, int pageFrameMemory)
storage
- the storage object to swap pages intologicalSize
- the logical size in pixels of the imageMethod Detail |
protected void configurePageFrames()
public java.awt.Dimension getLogicalSize()
public PageFrame getPageFrameForReading(int logicalPageNumber) throws java.io.IOException
logicalPageNumber
- the number of the pagepublic PageFrame getPageFrameForWriting(int logicalPageNumber) throws java.io.IOException
logicalPageNumber
- the number of the pagepublic PageFrame getPageFrame(int logicalPageNumber) throws java.io.IOException
logicalPageNumber
- the number of the pagepublic void commitPage(PageFrame pageFrame) throws java.io.IOException
public void readPageIntoFrame(PageFrame pageFrame, int logicalPageNumber) throws java.io.IOException
pageFrame
- the page frame to read data intologicalPageNumber
- the logical page number to read data forpublic int howManyPageFaults()
public void resetPageFaultCount()
public abstract int getPageSize()
public abstract PageFrame[] getPageFrames()
protected abstract int getPixelSize()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |