- Least Recently Used (LRU)
- Clock Page Replacement
- 2Q
- Adaptive Replacement Cache (ARC)
- This repository aims to analyse different page replacement algorithms.
- This repository contains implementations of the said page replacement algorithms, created in accordance with the relevant research papers.
- Paging Experiment with the Multics System
- Least Recently Used
- 2Q - A Low Overhead High Performance Buffer Management Replacement Algorithm
- A Cache Algorithm for Disk-backed Databases
- ARC: A Self-tuning, Low Overhead Replacement Cache
- Google benchmark
- Clone this Repository.
$ git clone [email protected]:Inamul07/Cache_Analysis.git $ cd Cache_Analysis
- Edit the main.c file to include the required replacement algorithm.
- Then run this command in terminal,
$ make
Algorithm | cache_name |
---|---|
Least Recently Used | LRU |
Clock Page Replacement | CLOCK |
Two Queue | TWO_QUEUE |
Adaptive Replacement Cache | ARC |
cache_init(cacheType cache_name, int capacity)
- Initializes the respective cache with given capacity.
- returns
generic_cache*
.
cache_access(generic_cache* cache, int page)
- Performs the relevant cache operation.
- Keeps an internal count of number of hits and misses.
- returns
void
.
cache_analysis(generic_cache* cache)
- Prints the buffer, total references, number of hits and misses and hit ratio.
- returns
void
.
cache_print_buffer(generic_cache* cache)
- Prints the buffer at that current state.
- returns
void
.
cache_put_array(generic_cache* cache, int pages[], int size)
- Performs the relevant cache operation for each data item from
pages
in a linear fashion. - returns
void
.
- Performs the relevant cache operation for each data item from
cache_destroy(generic_cache* cache)
- free the memory allocated by the
cache
. - returns
void
.
- free the memory allocated by the
For Cache Initialisation, Pass the appropriate
cache_name
to thecache_init()
method. ( Refer Table for appropriatecache_name
)
Example:
- For Initialising LRU with a capacity of 3,
cache_init(LRU, 3);
- For Initialising TWO_QUEUE with a capacity of 5,
cache_init(TWO_QUEUE, 5);
.
- The
data
folder, at the root, contains test data generated by DataGenerator.java. - We use Google benchmark to benchmark the Cache Replacement Algorithms.
- To run bench mark, execute the following command
$ make benchmark
- This prints the time taken by the cache algorithms along with their respective
Hit Ratio
.