diff options
author | Robert Morris <[email protected]> | 2019-10-29 04:32:55 -0400 |
---|---|---|
committer | Robert Morris <[email protected]> | 2019-10-29 04:32:55 -0400 |
commit | 028af2764622d489583cd88935cd1d2a7fbe8248 (patch) | |
tree | 56e95c19ce3f65ec67418190b5dd8bf923aa1e3a /kernel/bio.c | |
parent | 9de9211b1158bfbe169c5099dae11432d5950105 (diff) | |
download | xv6-labs-028af2764622d489583cd88935cd1d2a7fbe8248.tar.gz xv6-labs-028af2764622d489583cd88935cd1d2a7fbe8248.tar.bz2 xv6-labs-028af2764622d489583cd88935cd1d2a7fbe8248.zip |
mention LRU list a bit more in comments.
Diffstat (limited to 'kernel/bio.c')
-rw-r--r-- | kernel/bio.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/kernel/bio.c b/kernel/bio.c index a1074f2..60d91a6 100644 --- a/kernel/bio.c +++ b/kernel/bio.c @@ -28,7 +28,8 @@ struct { struct buf buf[NBUF]; // Linked list of all buffers, through prev/next. - // head.next is most recently used. + // Sorted by how recently the buffer was used. + // head.next is most recent, head.prev is least. struct buf head; } bcache; @@ -71,7 +72,8 @@ bget(uint dev, uint blockno) } } - // Not cached; recycle an unused buffer. + // Not cached. + // Recycle the least recently used (LRU) unused buffer. for(b = bcache.head.prev; b != &bcache.head; b = b->prev){ if(b->refcnt == 0) { b->dev = dev; @@ -110,7 +112,7 @@ bwrite(struct buf *b) } // Release a locked buffer. -// Move to the head of the MRU list. +// Move to the head of the most-recently-used list. void brelse(struct buf *b) { |