contur2
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
10
11namespace contur {
12
20 {
21 public:
24 explicit OptimalReplacement(std::vector<FrameId> futureAccesses);
26
30 OptimalReplacement &operator=(OptimalReplacement &&) noexcept;
31
32 [[nodiscard]] std::string_view name() const noexcept override;
33 [[nodiscard]] FrameId selectVictim(const PageTable &pageTable) override;
34 void onAccess(FrameId frame) override;
35 void onLoad(FrameId frame) override;
36 void reset() override;
37
38 private:
39 struct Impl;
40 std::unique_ptr<Impl> impl_;
41 };
42
43} // namespace contur
Abstract interface for page replacement algorithms.
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.
std::string_view name() const noexcept override
Returns the name of the algorithm (e.g., "FIFO", "LRU").
std::unique_ptr< Impl > impl_
OptimalReplacement & operator=(const OptimalReplacement &)=delete
void reset() override
Resets the policy's internal state.
OptimalReplacement(std::vector< FrameId > futureAccesses)
Constructs with a known future access sequence.
OptimalReplacement(OptimalReplacement &&) noexcept
FrameId selectVictim(const PageTable &pageTable) override
Selects a victim frame to evict.
OptimalReplacement(const OptimalReplacement &)=delete
Page table mapping virtual page numbers to physical frames.
Definition page_table.h:27
IPageReplacementPolicy interface — pluggable page replacement algorithms.
Definition block.h:15
std::uint32_t FrameId
Frame number in physical memory.
Definition types.h:43