IBM 000-8697 Server User Manual


 
2-62 IBM Informix OnLine Database Server Administrator’s Guide
How a User Process Acquires a Buffer
Step 4: Read the Page in from Disk
If the requested page must be read from disk, the user process first locates a
usable buffer in the FLRU queues. (Refer to page 2-57.) OnLine selects an
FLRU queue at random and tries to acquire the latch associated with the
queue. If the latch can be acquired, the buffer at the “least-recently used” end
of the queue is used. If another process holds the FLRU queue latch, the user
process tries to acquire a latch associated with another FLRU queue.
After a usable buffer is found, the buffer is temporarily removed from the
linked list that is the
FLRU queue. The user process acquires a latch on the
buffer table hash structure and creates an entry in the buffer table as the page
is read from disk into the buffer.
Steps 5-7: Lock Buffer, Release Lock, and Wake Waiting Processes
If the user process reads the buffer without modifying the data, it releases the
buffer as unmodified. If the user process had acquired the buffer with an
update or exclusive lock, other user processes may be waiting to read the
buffer.
The release of the buffer occurs in steps. First, the releasing user process
acquires a latch on the buffer table that enables it to modify the buffer entry.
Next, it looks to see if other user processes are sleeping or waiting for this
buffer. If so, the releasing user process wakes the first process in the wait-list
queue that has a compatible lock-access type. The waiting processes are
queued according to priorities that encompass more than just “first-come,
first served” hierarchies. (Otherwise, user processes waiting for exclusive
access could wait forever.)
If no user process in the wait-list queue has a compatible lock-access type,
any user process waiting for that buffer can receive access.
If no process is waiting for the buffer, the releasing process tries to release the
buffer to the FLRU queue where it was found. If the latch for that FLRU queue
is unavailable, the process tries to acquire a latch for a randomly selected
FLRU queue. When the FLRU queue latch is acquired, the unmodified buffer
is linked to the “most-recently used” end of the queue.
After the buffer is returned to the FLRU queue or the next user process in the
wait list is awakened, the releasing process removes itself from the user list
bit map for the buffer and decrements the shared-user count by one.