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 user input acts as coming and going processes
. User controls which block to get and release. User can also manipulate buffer status. This gives us complete control over the simulation. Also we can view the buffer cache, freelist, buffer list, and sleeping processes at all times.
This is a single-process synchronous program, so there is no added complexity of managing threads.
Read the project writeup to know more about the current implementation.
For a multi-threaded implementation, visit this repository.
- Compile using
make
- Then you can simply run the executable
./bufcache
- Alternatively, use
make run
- Run tests and see scenarios by executing test script
./test.sh
- Alternatively, use
make test
- In the logs folder, you can find the testlogs.
Checkout the logs folder for demo program runs.
Directly from the help section of the program.
help
buf
Display the status of all the buffers.
hash
Display all the Hash Queues.
free
Display free list
wait
Display waiting Queue
exit
To exit the simulation
getblk <blockNumber>
Take the blockNumber from the user, execute getblk(n)
brelse <blockNumber>
Take the blockNumber from the user, execute brelse()
set <blockNumber> <statusCode>
Set the status of the buffer to status code
B : Buffer Busy
V : Buffer Data is Valid
D : Buffer is marked delayed write
K : Kernet is reading/writing buffer to disk
W : Buffer is awaited by some other process
O : Buffer Data is OLD
reset <blockNumber> <statusCode>
Reset the status of the buffer to status code
B : Buffer Busy
V : Buffer Data is Valid
D : Buffer is marked delayed write
K : Kernet is reading/writing buffer to disk
W : Buffer is awaited by some other process
O : Buffer Data is OLD