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
10
11namespace contur {
12
20 {
21 public:
24 explicit OptimalReplacement(std::vector<FrameId> futureAccesses);
25
28
31
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
Abstract interface for page replacement algorithms.
void onAccess(FrameId frame) override
Notifies the policy that a frame was accessed (read or write).
~OptimalReplacement() override
Destroys optimal replacement policy.
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
Copy assignment is disabled.
void reset() override
Resets the policy's internal state.
OptimalReplacement(std::vector< FrameId > futureAccesses)
Constructs with a known future access sequence.
OptimalReplacement(OptimalReplacement &&) noexcept
Move-constructs policy state.
FrameId selectVictim(const PageTable &pageTable) override
Selects a victim frame to evict.
OptimalReplacement(const OptimalReplacement &)=delete
Copy construction is disabled.
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