Contur 2
Educational OS kernel simulator
Loading...
Searching...
No Matches
optimal_replacement.h
Go to the documentation of this file.
1
3
4
#pragma once
5
6
#include <memory>
7
#include <vector>
8
9
#include "
contur/memory/i_page_replacement.h
"
10
11
namespace
contur
{
12
19
class
OptimalReplacement
final :
public
IPageReplacementPolicy
20
{
21
public
:
24
explicit
OptimalReplacement
(std::vector<FrameId> futureAccesses);
25
27
~OptimalReplacement
()
override
;
28
30
OptimalReplacement
(
const
OptimalReplacement
&) =
delete
;
31
33
OptimalReplacement
&
operator=
(
const
OptimalReplacement
&) =
delete
;
35
OptimalReplacement
(
OptimalReplacement
&&) noexcept;
36
38
OptimalReplacement
&operator=(
OptimalReplacement
&&) noexcept;
39
41
[[nodiscard]] std::string_view
name
() const noexcept override;
42
44
[[nodiscard]]
FrameId
selectVictim
(const
PageTable
&pageTable) override;
45
47
void
onAccess
(
FrameId
frame) override;
48
50
void
onLoad
(
FrameId
frame) override;
51
53
void
reset
() override;
54
55
private:
56
struct Impl;
57
std::unique_ptr<Impl>
impl_
;
58
};
59
60
}
// namespace contur
contur::IPageReplacementPolicy
Abstract interface for page replacement algorithms.
Definition
i_page_replacement.h:20
contur::OptimalReplacement::onAccess
void onAccess(FrameId frame) override
Notifies the policy that a frame was accessed (read or write).
contur::OptimalReplacement::~OptimalReplacement
~OptimalReplacement() override
Destroys optimal replacement policy.
contur::OptimalReplacement::onLoad
void onLoad(FrameId frame) override
Notifies the policy that a new page was loaded into a frame.
contur::OptimalReplacement::name
std::string_view name() const noexcept override
Returns the name of the algorithm (e.g., "FIFO", "LRU").
contur::OptimalReplacement::impl_
std::unique_ptr< Impl > impl_
Definition
optimal_replacement.h:57
contur::OptimalReplacement::operator=
OptimalReplacement & operator=(const OptimalReplacement &)=delete
Copy assignment is disabled.
contur::OptimalReplacement::reset
void reset() override
Resets the policy's internal state.
contur::OptimalReplacement::OptimalReplacement
OptimalReplacement(std::vector< FrameId > futureAccesses)
Constructs with a known future access sequence.
contur::OptimalReplacement::OptimalReplacement
OptimalReplacement(OptimalReplacement &&) noexcept
Move-constructs policy state.
contur::OptimalReplacement::selectVictim
FrameId selectVictim(const PageTable &pageTable) override
Selects a victim frame to evict.
contur::OptimalReplacement::OptimalReplacement
OptimalReplacement(const OptimalReplacement &)=delete
Copy construction is disabled.
contur::PageTable
Page table mapping virtual page numbers to physical frames.
Definition
page_table.h:27
i_page_replacement.h
IPageReplacementPolicy interface — pluggable page replacement algorithms.
contur
Definition
block.h:15
contur::FrameId
std::uint32_t FrameId
Frame number in physical memory.
Definition
types.h:43
include
contur
memory
optimal_replacement.h
Generated by
1.16.1