![]() |
Contur 2
Educational OS kernel simulator
|
Optimal page replacement (Belady's algorithm). More...
#include <optimal_replacement.h>
Public Member Functions | |
| OptimalReplacement (std::vector< FrameId > futureAccesses) | |
| Constructs with a known future access sequence. | |
| ~OptimalReplacement () override | |
| Destroys optimal replacement policy. | |
| OptimalReplacement (const OptimalReplacement &)=delete | |
| Copy construction is disabled. | |
| OptimalReplacement & | operator= (const OptimalReplacement &)=delete |
| Copy assignment is disabled. | |
| OptimalReplacement (OptimalReplacement &&) noexcept | |
| Move-constructs policy state. | |
| OptimalReplacement & | operator= (OptimalReplacement &&) noexcept |
| Move-assigns policy state. | |
| std::string_view | name () const noexcept override |
| Returns the name of the algorithm (e.g., "FIFO", "LRU"). | |
| FrameId | selectVictim (const PageTable &pageTable) override |
| Selects a victim frame to evict. | |
| void | onAccess (FrameId frame) override |
| Notifies the policy that a frame was accessed (read or write). | |
| void | onLoad (FrameId frame) override |
| Notifies the policy that a new page was loaded into a frame. | |
| void | reset () override |
| Resets the policy's internal state. | |
| Public Member Functions inherited from contur::IPageReplacementPolicy | |
| virtual | ~IPageReplacementPolicy ()=default |
Private Attributes | |
| std::unique_ptr< Impl > | impl_ |
Optimal page replacement (Belady's algorithm).
Evicts the page that will not be used for the longest time in the future. Requires the complete future access sequence to be known in advance. This is impractical for real systems but serves as a theoretical baseline for comparing other algorithms' performance.
Definition at line 19 of file optimal_replacement.h.
|
explicit |
Constructs with a known future access sequence.
| futureAccesses | Ordered list of FrameIds that will be accessed. |
Referenced by operator=(), operator=(), OptimalReplacement(), and OptimalReplacement().
|
override |
Destroys optimal replacement policy.
|
delete |
Copy construction is disabled.
References OptimalReplacement().
|
noexcept |
Move-constructs policy state.
References OptimalReplacement().
|
nodiscardoverridevirtualnoexcept |
Returns the name of the algorithm (e.g., "FIFO", "LRU").
Implements contur::IPageReplacementPolicy.
References name().
Referenced by name().
|
overridevirtual |
Notifies the policy that a frame was accessed (read or write).
Implements contur::IPageReplacementPolicy.
References onAccess().
Referenced by onAccess().
|
overridevirtual |
Notifies the policy that a new page was loaded into a frame.
Implements contur::IPageReplacementPolicy.
References onLoad().
Referenced by onLoad().
|
delete |
Copy assignment is disabled.
References OptimalReplacement().
|
noexcept |
Move-assigns policy state.
References OptimalReplacement().
|
overridevirtual |
Resets the policy's internal state.
Implements contur::IPageReplacementPolicy.
References reset().
Referenced by reset().
|
nodiscardoverridevirtual |
Selects a victim frame to evict.
| pageTable | The current page table state. |
Implements contur::IPageReplacementPolicy.
References selectVictim().
Referenced by selectVictim().
|
private |
Definition at line 57 of file optimal_replacement.h.