September 18, 2016
Categorised in: Operating System Design
- When a process wants to access data from a file, the kernel brings the data into main memory, alters it and then request to save in the file system
- Example: copy cp one.c two.c
- To increase the response time and throughput, the kernel minimizes the frequency of disk access by keeping a pool of internal data buffer called buffer cache.
- Buffer cache contains the data in recently used disk blocks
- When reading data from disk, the kernel attempts to read from buffer cache.
- If data is already in the buffer cache, the kernel does not need to read from disk
- If data is not in the buffer cache, the kernel reads the data from disk and cache it
- A buffer consists of two parts:
- A memory array
- Buffer header
- Device num
- Logical file system number
- Block num
- Block number of the data on disk
- Buffer is currently locked
- Buffer contains valid data
- Kernel is reading/writing from/to disk
- A process is currently waiting for the buffer to become free.
- Kernel identifies the buffer content by examining device num and block num.