Skip to content

Commit

Permalink
prefer discarded buffers when searching for a buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
boeckmann committed Oct 20, 2024
1 parent a027cb8 commit 4246b8b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions drdos/buffers.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1060,10 +1060,21 @@ locate20: ; MRU buffer doesn't match

cmp cl,0 ; shall we only tag an existing buffer?
je locate50 ; yes, then do not sacrifice this one

; find cheap buffer to recycle
mov si,es:BCB_PREV[si] ; start with LRU
mov di,si
locate23:
cmp es:BCB_DRV[si],0ffh ; discarded buffer?
je locate25 ; happily use discarded
mov si,es:BCB_PREV[si]
cmp si,di ; back at LRU?
jne locate23 ; if not inspect previous buffer

locate25:
push ax
push cx
push dx ; save all registers
mov si,es:BCB_PREV[si] ; recycle least recently used buffer
push dx ; save all registers
call flush_buffer ; write buffer to disk
pop dx
pop cx
Expand Down

0 comments on commit 4246b8b

Please sign in to comment.