contur2
Loading...
Searching...
No Matches
contur::OptimalReplacement Class Referencefinal

Optimal page replacement (Belady's algorithm). More...

#include <optimal_replacement.h>

Inheritance diagram for contur::OptimalReplacement:
Collaboration diagram for contur::OptimalReplacement:

Public Member Functions

 OptimalReplacement (std::vector< FrameId > futureAccesses)
 Constructs with a known future access sequence.
 ~OptimalReplacement () override
 OptimalReplacement (const OptimalReplacement &)=delete
OptimalReplacementoperator= (const OptimalReplacement &)=delete
 OptimalReplacement (OptimalReplacement &&) noexcept
OptimalReplacementoperator= (OptimalReplacement &&) noexcept
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_

Detailed Description

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.

Constructor & Destructor Documentation

◆ OptimalReplacement() [1/3]

contur::OptimalReplacement::OptimalReplacement ( std::vector< FrameId > futureAccesses)
explicit

Constructs with a known future access sequence.

Parameters
futureAccessesOrdered list of FrameIds that will be accessed.

◆ ~OptimalReplacement()

contur::OptimalReplacement::~OptimalReplacement ( )
override

◆ OptimalReplacement() [2/3]

contur::OptimalReplacement::OptimalReplacement ( const OptimalReplacement & )
delete

◆ OptimalReplacement() [3/3]

contur::OptimalReplacement::OptimalReplacement ( OptimalReplacement && )
noexcept

Member Function Documentation

◆ name()

std::string_view contur::OptimalReplacement::name ( ) const
nodiscardoverridevirtualnoexcept

Returns the name of the algorithm (e.g., "FIFO", "LRU").

Implements contur::IPageReplacementPolicy.

◆ onAccess()

void contur::OptimalReplacement::onAccess ( FrameId frame)
overridevirtual

Notifies the policy that a frame was accessed (read or write).

Implements contur::IPageReplacementPolicy.

◆ onLoad()

void contur::OptimalReplacement::onLoad ( FrameId frame)
overridevirtual

Notifies the policy that a new page was loaded into a frame.

Implements contur::IPageReplacementPolicy.

◆ operator=() [1/2]

OptimalReplacement & contur::OptimalReplacement::operator= ( const OptimalReplacement & )
delete

◆ operator=() [2/2]

OptimalReplacement & contur::OptimalReplacement::operator= ( OptimalReplacement && )
noexcept

◆ reset()

void contur::OptimalReplacement::reset ( )
overridevirtual

Resets the policy's internal state.

Implements contur::IPageReplacementPolicy.

◆ selectVictim()

FrameId contur::OptimalReplacement::selectVictim ( const PageTable & pageTable)
nodiscardoverridevirtual

Selects a victim frame to evict.

Parameters
pageTableThe current page table state.
Returns
The FrameId of the frame to evict.

Implements contur::IPageReplacementPolicy.

Member Data Documentation

◆ impl_

std::unique_ptr<Impl> contur::OptimalReplacement::impl_
private

Definition at line 40 of file optimal_replacement.h.


The documentation for this class was generated from the following file: