From 18f69783996c83d999ffbf9ed718b5ac39693a12 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Fri, 25 Dec 2020 16:43:20 -0500 Subject: [PATCH] Make FLUSH also invalidate the blk cache --- blk.fs | 2 +- doc/dict.txt | 3 ++- doc/usage.txt | 8 ++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/blk.fs b/blk.fs index a929d08..5d9c8eb 100644 --- a/blk.fs +++ b/blk.fs @@ -1939,7 +1939,7 @@ SYSVARS 0x0c + :** C<* : BLK! ( -- ) BLK> @ BLK!* @ EXECUTE 0 BLKDTY ! ; -: FLUSH BLKDTY @ IF BLK! THEN ; +: FLUSH BLKDTY @ IF BLK! THEN -1 BLK> ! ; : BLK@ ( n -- ) DUP BLK> @ = IF DROP EXIT THEN FLUSH DUP BLK> ! BLK@* @ EXECUTE ; diff --git a/doc/dict.txt b/doc/dict.txt index c0158cb..097bc3d 100644 --- a/doc/dict.txt +++ b/doc/dict.txt @@ -264,7 +264,8 @@ BLK> -- a Address of the current block variable. BLK( -- a Beginning addr of blk buf. BLK) -- a Ending addr of blk buf. COPY s d -- Copy contents of s block to d block. -FLUSH -- Write current block to disk if dirty. +FLUSH -- Write current block to disk if dirty and inval- + idates current block cache. LIST n -- Prints the contents of the block n on screen in the form of 16 lines of 64 columns. LOAD n -- Interprets Forth code from block n diff --git a/doc/usage.txt b/doc/usage.txt index 7342876..0cb05c9 100644 --- a/doc/usage.txt +++ b/doc/usage.txt @@ -108,6 +108,8 @@ Many blocks contain code. That code can be interpreted through LOAD. Programs stored in blocks frequently have "loader blocks" that take care of loading all blocks relevant to the program. +# Spanning multiple disks + Blocks spanning multiple disks are tricky. If your media isn't large enough to hold all Collapse OS blocks in one unit, you'll have to make it span multiple disks. Block reference in @@ -123,6 +125,12 @@ Although the usage of absolute LOAD calls are minimally used When you span Collapse OS over multiple disks, don't forget to adjust those absolute LOADs. +When you work with multiple disks, you have to remember to FLUSH +before swapping the disk. This will write current block if it's +dirty and also invalidate the cache. This way, you're not at +risk of either overwriting a block on your other disk or LOADing +cached contents without noticing. + # How blocks are organized Organization of contiguous blocks is an ongoing challenge and