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 |
|
LRU cache class.
Definition at line 68 of file lru_cache.cpp.
◆ 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. |
Definition at line 85 of file lru_cache.cpp.
uint64_t pageFrame
Page frame, or total size of the cache.
◆ display()
void others::lru_cache::LRUCache::display |
( |
| ) |
|
|
inline |
A function to display the current cache.
- Returns
- Void
Definition at line 121 of file lru_cache.cpp.
121 {
122 for (uint64_t &it :
cache) {
123 std::cout << it << " ";
124 }
125 std::cout << std::endl;
126 }
std::list< uint64_t > cache
Cache linked list (using the STL)
◆ getHits()
uint64_t others::lru_cache::LRUCache::getHits |
( |
| ) |
const |
|
inline |
A function to get page hits.
- Returns
- int
Definition at line 131 of file lru_cache.cpp.
uint64_t hits
was found in cache.
◆ getPageFault()
uint64_t others::lru_cache::LRUCache::getPageFault |
( |
| ) |
const |
|
inline |
A function to get page fault.
- Returns
- int
Definition at line 136 of file lru_cache.cpp.
◆ 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.
Definition at line 92 of file lru_cache.cpp.
92 {
93
96
97
99
100 uint64_t lastPage =
cache.back();
103 }
104 }
105
106 else {
108
110 }
111
112
113 cache.push_front(page);
115 }
std::unordered_map< uint64_t, std::list< uint64_t >::iterator > pageMap
Hash map containing pages and their addresses.
◆ cache
std::list<uint64_t> others::lru_cache::LRUCache::cache |
|
private |
◆ 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
Definition at line 74 of file lru_cache.cpp.
◆ 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
Definition at line 77 of file lru_cache.cpp.
◆ pageFrame
uint64_t others::lru_cache::LRUCache::pageFrame |
|
private |
Page frame, or total size of the cache.
Definition at line 69 of file lru_cache.cpp.
◆ pageMap
std::unordered_map<uint64_t, std::list<uint64_t>::iterator> others::lru_cache::LRUCache::pageMap |
|
private |
Hash map containing pages and their addresses.
Definition at line 72 of file lru_cache.cpp.
The documentation for this class was generated from the following file: