bustub project1整理
TASK1 实现LRUReplacer类#
LRUReplacer类继承自Replacer类。ClockReplacer类也继承自Replacer类,但本次实验不准备实现Replacer类。
类成员变量#
//都是我自己定义的
using time_stamp = uint32_t;
time_stamp cur_time_;
//unpinned_frames_保存着那些没有被Pin的Page所在的frame
std::list<std::pair<frame_id_t, time_stamp>> unpinned_frames_;
成员函数#
//构造函数
LRUReplacer::LRUReplacer(size_t num_pages);
//析构函数
LRUReplacer::~LRUReplacer();
//从frames中选出一个按最近访问时间排序排名最靠后的一个frame,成功则将该frame的id保存在frame_id中,并返回true。如果frames_为空,则返回false。
auto LRUReplacer::Victim(frame_id_t *frame_id) -> bool;
//当BufferPoolManager对某个Page进行Pin操作时,需要将该Page所在的frame从unpinned_frames_中移除。
void LRUReplacer::Pin(frame_id_t frame_id);
//当某个Page被Unpin至pin_count_将为0时,执行这个函数,将该Page对应的frame放入unpinned_frames_。
void LRUReplacer::Unpin(frame_id_t frame_id);
//返回当前LRUReplacer中保存的frame数,即unpinned_frames_的大小。
auto LRUReplacer::Size() -> size_t;
作者:yuxiayizhengwan
出处:https://www.cnblogs.com/yuxiayizhengwan/p/16485453.html
版权:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库