LRU cache class.
More...
|
| LRUCache (uint64_t pf) |
| Constructor, Initialize thee LRU class with page frame.
|
|
void | refer (uint64_t page) |
| Refer to a page, or request a page from memory.
|
|
void | display () |
| A function to display the current cache.
|
|
uint64_t | getHits () const |
| A function to get page hits.
|
|
uint64_t | getPageFault () const |
| A function to get page fault.
|
|
|
uint64_t | pageFrame |
| Page frame, or total size of the cache.
|
|
std::list< uint64_t > | cache |
| Cache linked list (using the STL)
|
|
std::unordered_map< uint64_t, std::list< uint64_t >::iterator > | pageMap |
| Hash map containing pages and their addresses.
|
|
uint64_t | hits |
| was found in cache.
|
|
uint64_t | pageFault = 0 |
|
◆ LRUCache()
others::lru_cache::LRUCache::LRUCache |
( |
uint64_t | pf | ) |
|
|
inlineexplicit |
Constructor, Initialize thee LRU class with page frame.
- Parameters
-
pf | Page frame or total size of cache. |
uint64_t pageFrame
Page frame, or total size of the cache.
Definition lru_cache.cpp:68
◆ display()
void others::lru_cache::LRUCache::display |
( |
| ) |
|
|
inline |
A function to display the current cache.
- Returns
- Void
120 {
121 for (uint64_t &it :
cache) {
123 }
125 }
std::list< uint64_t > cache
Cache linked list (using the STL)
Definition lru_cache.cpp:69
◆ getHits()
uint64_t others::lru_cache::LRUCache::getHits |
( |
| ) |
const |
|
inline |
A function to get page hits.
- Returns
- int
uint64_t hits
was found in cache.
Definition lru_cache.cpp:73
◆ getPageFault()
uint64_t others::lru_cache::LRUCache::getPageFault |
( |
| ) |
const |
|
inline |
A function to get page fault.
- Returns
- int
uint64_t pageFault
Definition lru_cache.cpp:76
◆ refer()
void others::lru_cache::LRUCache::refer |
( |
uint64_t | page | ) |
|
|
inline |
Refer to a page, or request a page from memory.
- Parameters
-
page | The page that you are referring to. |
- Returns
- void
< Increase the page fault by one.
91 {
92
95
96
98
102 }
103 }
104
105 else {
107
109 }
110
111
114 }
std::unordered_map< uint64_t, std::list< uint64_t >::iterator > pageMap
Hash map containing pages and their addresses.
Definition lru_cache.cpp:71
◆ hits
uint64_t others::lru_cache::LRUCache::hits |
|
private |
Initial value:
was found in cache.
Total number of hits, or total number of times a page
◆ pageFault
uint64_t others::lru_cache::LRUCache::pageFault = 0 |
|
private |
Total number of miss/page fault, or total number of times a page was not found in cache
The documentation for this class was generated from the following file: