33#include "params/SecondChanceRP.hh"
38namespace replacement_policy
48 const std::shared_ptr<SecondChanceReplData>& replacement_data)
const
54 replacement_data->hasSecondChance =
false;
59 const std::shared_ptr<ReplacementData>& replacement_data)
64 std::static_pointer_cast<SecondChanceReplData>(
65 replacement_data)->hasSecondChance =
false;
70 const std::shared_ptr<ReplacementData>& replacement_data)
const
75 std::static_pointer_cast<SecondChanceReplData>(
76 replacement_data)->hasSecondChance =
true;
81 const std::shared_ptr<ReplacementData>& replacement_data)
const
86 std::static_pointer_cast<SecondChanceReplData>(
87 replacement_data)->hasSecondChance =
false;
94 assert(candidates.size() > 0);
97 for (
const auto& candidate : candidates) {
99 std::shared_ptr<SecondChanceReplData> candidate_replacement_data =
100 std::static_pointer_cast<SecondChanceReplData>(
101 candidate->replacementData);
104 if ((candidate_replacement_data->tickInserted ==
Tick(0)) &&
105 !candidate_replacement_data->hasSecondChance) {
112 bool search_victim =
true;
113 while (search_victim) {
118 std::shared_ptr<SecondChanceReplData> victim_replacement_data =
119 std::static_pointer_cast<SecondChanceReplData>(
123 if (victim_replacement_data->hasSecondChance) {
127 search_victim =
false;
134std::shared_ptr<ReplacementData>
A replaceable entry is a basic entry in a 2d table-like structure that needs to have replacement func...
std::shared_ptr< replacement_policy::ReplacementData > replacementData
Replacement data associated to this entry.
void reset(const std::shared_ptr< ReplacementData > &replacement_data) const override
Reset replacement data.
ReplaceableEntry * getVictim(const ReplacementCandidates &candidates) const override
Find replacement victim using insertion timestamps.
void invalidate(const std::shared_ptr< ReplacementData > &replacement_data) override
Invalidate replacement data to set it as the next probable victim.
void touch(const std::shared_ptr< ReplacementData > &replacement_data) const override
Touch an entry to update its replacement data.
std::shared_ptr< ReplacementData > instantiateEntry() override
Instantiate a replacement data entry.
ReplaceableEntry * getVictim(const ReplacementCandidates &candidates) const override
Find replacement victim using insertion timestamps and second chance bit.
void reset(const std::shared_ptr< ReplacementData > &replacement_data) const override
Reset replacement data.
SecondChance(const Params &p)
void useSecondChance(const std::shared_ptr< SecondChanceReplData > &replacement_data) const
Use replacement data's second chance.
SecondChanceRPParams Params
void touch(const std::shared_ptr< ReplacementData > &replacement_data) const override
Touch an entry to update its re-insertion tick and second chance bit.
void invalidate(const std::shared_ptr< ReplacementData > &replacement_data) override
Invalidate replacement data to set it as the next probable victim.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
uint64_t Tick
Tick count type.
Copyright (c) 2018-2020 Inria All rights reserved.
Second-Chance-specific implementation of replacement data.