A simple buffer cache implementation for simulation of getblk and brelse algorithms.
In this implementation, the main program act as kernel and manipulates the buffer cache, while processes are being created by using the fork () command. It controls which block to get and release. User can manipulate buffer status. This gives us complete control over the simulation. Also, we can view the buffer cache, free list, buffer list, and sleeping processes at all times. This is a multi-process synchronous program using fork (), so there is no added complexity of managing threads. We can focus on getblk and buffer cache.
The idea was to simulate getblk and brelse algorithms that handle the allocation and release of buffers to processes. The key requirement was to be able to visualize all 5 scenarios of getblk and clearly identify the working of getblk in all of those scenarios.
We want a simulation slow enough to analyse the working details of getblk.
C++ is the chosen language. Because we are implementing buffer cache, which is a lower level algorithm, it needs to be fast though C provides the fastest system calls but C++ gives us object-oriented approach.
- Multiprogramming concept using forks
- Locking unlocking mechanism