mention LRU list a bit more in comments.
This commit is contained in:
parent
9de9211b11
commit
028af27646
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue