2.Lab-8 locks

Memory allocator (moderate)

代码地址

https://github.com/INnoVationv2/xv6-labs-2023/commit/6a93f5a9a5fca0627f9d44f185a33f30f3b8cd16

Buffer cache (hard)

创建多个桶

#define NBUCKET 13
struct {
  struct buf buf[NBUF];
  
  struct spinlock bucket_lock[NBUCKET];
  struct buf bucket[NBUCKET];
} bcache;
  1. 初始将所有缓冲区放入0号桶中
  2. 获取时,不够就从其他桶去借

代码地址

https://github.com/INnoVationv2/xv6-labs-2023/commit/de3808b0a83a4b9b7fe572701b63ccf2546aeaee

image-20240402223825946
posted @ 2024-04-21 00:14  INnoVation-V2  阅读(7)  评论(0编辑  收藏  举报