Definition :-
The kernel could read and write directly to and from the disk for all file system accesses,but system response time and throughput would be poor because of the slow disk transfer rate . The kernel therefore attempts to minimize frequency of disk access by keeping a pool of internal data buffers,called the buffer cache which contains the data in recently used disk blocks.
A buffer contains two parts:
a memory array that contains data from the disk and
a buffer header that identifies the buffer.
The status of buffer is a combination of the following conditions:
1. The buffer is currently locked.
2. The buffer contains valid data
3. The kernel must write the buffer contents to disk before reassigning the buffer this condition is known as "delayed-write"
4. The kernel is currently reading or writing the contents of the buffer to disk.
5. A process is currently waiting for the buffer to become free
Structure of the buffer pool:
The kernel caches data in the buffer pool according to a least recently used algorithm .
The kernel maintains a free list of buffers that preserves the last recently used order.
The free list is a doubly linked circular list of buffers with a dummy buffer header that marks its beginning and end .
Kernel organizes the buffer into separate queues, hashed as a function of the device and block number.
Five typical scenarios the kernel may follow in getblk to allocate a buffer for a disk block
1. The kernel finds the block on its hash queue, and its buffer is free.
2. The kernel cannot find the block on the hash queue,so it allocates a buffer from the free list .
3. The kernel cannot find the block on the hash queue and in attempting to allocate a buffer from the free list ,finds a buffer on the free list that has been marked "delayed write." The kernel must write the "delayed write" buffer to disk and allocate another buffer.
4. The kernel cannot find the block on the hash queue , and the free list of buffers is empty.
5. The kernel finds the block on the hash queue , but its buffer is currently busy.
The kernel could read and write directly to and from the disk for all file system accesses,but system response time and throughput would be poor because of the slow disk transfer rate . The kernel therefore attempts to minimize frequency of disk access by keeping a pool of internal data buffers,called the buffer cache which contains the data in recently used disk blocks.
A buffer contains two parts:
a memory array that contains data from the disk and
a buffer header that identifies the buffer.
The status of buffer is a combination of the following conditions:
1. The buffer is currently locked.
2. The buffer contains valid data
3. The kernel must write the buffer contents to disk before reassigning the buffer this condition is known as "delayed-write"
4. The kernel is currently reading or writing the contents of the buffer to disk.
5. A process is currently waiting for the buffer to become free
Structure of the buffer pool:
The kernel caches data in the buffer pool according to a least recently used algorithm .
The kernel maintains a free list of buffers that preserves the last recently used order.
The free list is a doubly linked circular list of buffers with a dummy buffer header that marks its beginning and end .
Kernel organizes the buffer into separate queues, hashed as a function of the device and block number.
Five typical scenarios the kernel may follow in getblk to allocate a buffer for a disk block
1. The kernel finds the block on its hash queue, and its buffer is free.
2. The kernel cannot find the block on the hash queue,so it allocates a buffer from the free list .
3. The kernel cannot find the block on the hash queue and in attempting to allocate a buffer from the free list ,finds a buffer on the free list that has been marked "delayed write." The kernel must write the "delayed write" buffer to disk and allocate another buffer.
4. The kernel cannot find the block on the hash queue , and the free list of buffers is empty.
5. The kernel finds the block on the hash queue , but its buffer is currently busy.