xv6-simplified 0.1
简化版xv6
Loading...
Searching...
No Matches
Functions | Variables
bio.c File Reference

磁盘缓存管理模块,维护了一个buf结构体数组,实现了缓存的分配、读写、释放等功能 More...

#include "include/types.h"
#include "include/param.h"
#include "include/riscv.h"
#include "include/defs.h"
#include "include/buf.h"
Include dependency graph for bio.c:

Functions

void binit (void)
 初始化缓冲区缓存,创建一个缓冲区的链表
 
struct bufbread (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 
 

Detailed Description

磁盘缓存管理模块,维护了一个buf结构体数组,实现了缓存的分配、读写、释放等功能

Date
23.05.26
Author
lyp、xin
Version
0.2 @status Stable

Function Documentation

◆ binit()

void binit ( void  )

初始化缓冲区缓存,创建一个缓冲区的链表

最近使用的缓冲区在链表头部,最不常用的缓冲区在链表尾部,LRU

Here is the caller graph for this function:

◆ bpin()

void bpin ( struct buf b)

增加引用计数值

Parameters
b缓冲区

◆ bread()

struct buf * bread ( uint  dev,
uint  sectorno 
)

将指定设备上指定扇区的内容存储在buffer中

Parameters
dev设备号
sectorno扇区号
Returns
缓冲区
Here is the call graph for this function:
Here is the caller graph for this function:

◆ brelse()

void brelse ( struct buf b)

释放一个缓冲区,若当前的引用计数为0,则会被头插到空闲缓冲池中

Parameters
b待释放的缓冲区
Here is the caller graph for this function:

◆ bunpin()

void bunpin ( struct buf b)

减少引用计数值

Parameters
b缓冲区

◆ bwrite()

void bwrite ( struct buf b)

将一个缓冲区的内容写入到磁盘中

Parameters
b缓冲区
Here is the call graph for this function:

Variable Documentation

◆ [struct]

struct { ... } bcache

◆ buf

struct buf buf[NBUF]

◆ head

struct buf head