diff options
Diffstat (limited to 'kernel')
| -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)  { | 
