You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This example demonstrates how to create a plugin for libCacheSim using the v2 hook-based plugin system. The plugin implements a standalone LRU (Least Recently Used) cache algorithm that integrates with libCacheSim's plugin_cache.c framework.
4
+
5
+
## Files
6
+
7
+
-`plugin_lru.cpp` - The main LRU cache plugin implementation using hooks
8
+
-`test_hooks_plugin.c` - Comprehensive test program for the plugin
9
+
-`CMakeLists.txt` - Build configuration for creating the shared library
10
+
11
+
## Building
12
+
13
+
To compile the plugin into a shared library:
14
+
15
+
```bash
16
+
mkdir build
17
+
cd build
18
+
cmake ..
19
+
make
20
+
```
21
+
22
+
This will create:
23
+
-`libplugin_lru_hooks.so` - Shared library
24
+
-`test_hooks_plugin` - Test executable for validation
25
+
26
+
## Plugin Architecture
27
+
28
+
The plugin implements a standalone LRU cache using C++ with a C interface for compatibility with libCacheSim. It uses:
29
+
30
+
-**StandaloneLRU Class**: C++ implementation with doubly-linked list and hash map
31
+
-**Hook Functions**: C interface functions that plugin_cache.c calls
32
+
33
+
### Hook Functions
34
+
35
+
The plugin implements these required hook functions:
36
+
37
+
-`cache_init_hook()` - Initialize the LRU cache data structure
38
+
-`cache_hit_hook()` - Handle cache hits (move object to head of LRU list)
39
+
-`cache_miss_hook()` - Handle cache misses (insert new object)
40
+
-`cache_eviction_hook()` - Evict least recently used object and return its ID
41
+
-`cache_remove_hook()` - Remove specific object from cache
0 commit comments