Synopsis
PDX_MSGT dof_GetPage(DOF_FILE *file, DOF_OFF_T page, DOF_BUFFER **buffer)
Purpose
Bring a page into a buffer.
Description
Routine to return the buffer number containing the specified page. This routine is responsible for maintaining the cache buffers and determining which should be flushed in the event that the requested page is not in memory. The algorithm used in this routine takes both frequency of access and time since last access into account when determining which buffer to flush. The algorithm is: .IP 1) 4 Update the age of the file by incrementing bcb.age .IP 2) 4 If the file age is equal to DOF_DECAYCNT, cycle through the bcb.frequency array and right shift each value (i.e. divide each value) by DOF_FREQSHFT. This prevents heavily accessed buffers from becoming permanently locked in the cache. This also allows buffers which are heavily accessed in cycles from being locked in the buffer during non-heavy accessing of them. .IP 3) 4 Cycle through the list of current page pointers to see if the requested page is already in memory. If it is found, increment the frequency of use for the buffer by either DOF_WRITEINC or DOF_READINC depending on the buffer having been modified or not. Return the page number to the caller. .IP 4) 4 If step 3 did not locate the requested page in memory, it will be neccessary to determine which buffer should be flushed. If one or more non-modified (read) buffers are available, use the one which has the lowest frequency of use and the oldest age (in that order). The time is set to the current age and the frequency of use to DOF_INITFREQ. If no read buffers are available, do the same with a modified buffer except flush it via fm_flush before resetting the age and frequency information.
Input
file
File to get page from
page
Page within file to get
Output
buffer
Buffer containing page
Return
DOF error code