xv6-simplified 0.1
简化版xv6
|
磁盘缓存管理模块,维护了一个buf结构体数组,实现了缓存的分配、读写、释放等功能 More...
#include "include/types.h"
#include "include/param.h"
#include "include/riscv.h"
#include "include/defs.h"
#include "include/buf.h"
Functions | |
void | binit (void) |
初始化缓冲区缓存,创建一个缓冲区的链表 | |
struct buf * | bread (uint dev, uint sectorno) |
将指定设备上指定扇区的内容存储在buffer中 | |
void | bwrite (struct buf *b) |
将一个缓冲区的内容写入到磁盘中 | |
void | brelse (struct buf *b) |
释放一个缓冲区,若当前的引用计数为0,则会被头插到空闲缓冲池中 | |
void | bpin (struct buf *b) |
增加引用计数值 | |
void | bunpin (struct buf *b) |
减少引用计数值 | |
Variables | ||
struct { | ||
struct buf buf [NBUF] | ||
struct buf head | ||
} | bcache | |
磁盘缓存管理模块,维护了一个buf结构体数组,实现了缓存的分配、读写、释放等功能
void binit | ( | void | ) |
初始化缓冲区缓存,创建一个缓冲区的链表
最近使用的缓冲区在链表头部,最不常用的缓冲区在链表尾部,LRU
void bpin | ( | struct buf * | b | ) |
增加引用计数值
b | 缓冲区 |
将指定设备上指定扇区的内容存储在buffer中
dev | 设备号 |
sectorno | 扇区号 |
void brelse | ( | struct buf * | b | ) |
释放一个缓冲区,若当前的引用计数为0,则会被头插到空闲缓冲池中
b | 待释放的缓冲区 |
void bunpin | ( | struct buf * | b | ) |
减少引用计数值
b | 缓冲区 |
void bwrite | ( | struct buf * | b | ) |
将一个缓冲区的内容写入到磁盘中
b | 缓冲区 |
struct { ... } bcache |
struct buf head |