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;
- 初始将所有缓冲区放入0号桶中
- 获取时,不够就从其他桶去借
代码地址
https://github.com/INnoVationv2/xv6-labs-2023/commit/de3808b0a83a4b9b7fe572701b63ccf2546aeaee