~vdupras/collapseos

18f69783996c83d999ffbf9ed718b5ac39693a12 — Virgil Dupras 1 year, 6 months ago 6f4f870
Make FLUSH also invalidate the blk cache
3 files changed, 11 insertions(+), 2 deletions(-)

M blk.fs
M doc/dict.txt
M doc/usage.txt
M blk.fs => blk.fs +1 -1
@@ 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 ;

M doc/dict.txt => doc/dict.txt +2 -1
@@ 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

M doc/usage.txt => doc/usage.txt +8 -0
@@ 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