Devices that take time, and a filesystem that waits for one

The disk's status has always had a bit meaning "still going", and the header
beside it has always said to honour it. Nothing did, because nothing could: the
host finished the transfer inside the instruction that asked for it, so the bit
could never be seen up and asking about it was asking about something that
cannot happen.

--disk-cycles gives it a latency. The command is still checked at once, because
a refusal is not work - a block that is not there fails before any head moves -
but the transfer is remembered and done when the machine has run that far. Until
then the buffer holds the block BEFORE this one.

That last part is the point. A program that does not wait gets the wrong bytes
rather than an error, which is the failure the bit exists to prevent and the one
that would never have shown up. With a latency of two thousand, CosmOS could not
even mount: sbfsMount reads block zero and looks straight at the buffer.

deviceTick is the general shape rather than a disk feature. Called once per
instruction with the machine's clock, it lets anything whose moment has come
finish - which is what a display that refreshes, or a port that waits on the
host, would want in exactly the same way.

The filesystem watches the bit now, in one small routine reached with RCAL. That
is not decoration: what it hands back is the settled status in A, and CALL puts A
back the way it found it, so an ordinary call cannot carry the one thing this
exists to carry. Two bytes of Stack rather than ten, in a routine that runs on
every block the machine ever touches - the first place in the system where the
new call is the right one rather than merely a cheaper one.

The manifest takes a @N after a disk, the way it already takes :ro, so a test can
ask for a slow one. cosmosSlowDisk lists a directory at two thousand cycles a
block and gets the same listing as everything else, which is the whole assertion:
a filesystem that did not wait would print nonsense rather than fail.

Zero is the default and every other test runs at it. What waiting costs, on a
directory heavy run: 229k cycles at zero, 275k at five hundred, 415k at two
thousand, 1.16M at ten thousand.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
This commit is contained in:
Anachronaut
2026-08-25 21:29:57 -04:00
co-authored by Claude Opus 5
parent e0cf0a9a25
commit d4cba36c5e
11 changed files with 161 additions and 15 deletions
+16
View File
@@ -0,0 +1,16 @@
CosmOS
> greet.sbx 210
hello.sbx 52
Life.sbx 1411
Snake.sbx 2175
Keys.sbx 663
Say.sbx 155
Break.sbx 148
notes.txt 21
8 files
> loaded, starting at 4000
> it says: the disk took its time
finished
> halted
Execution halted.
[exit 0]
+4
View File
@@ -0,0 +1,4 @@
dir
load Say.sbx
run the disk took its time
exit
+9
View File
@@ -369,6 +369,15 @@ cosmosTreeWrite | CosmOS/Source/cosmos.asm | run | cosmosTre
# The listing at the end is the point: 266 bytes, which is what was reserved and what was
# written, after the refusal and the honest commit that follows it.
cosmosClaim | CosmOS/Source/cosmos.asm | run | cosmosClaim.in | - | disks/claim.img
# The filesystem waiting for a disk that takes time. Every other test here runs with the
# disk finishing before the next instruction starts, which is what it has always done and
# what hides whether anything honours the busy bit. This one gives it a latency.
#
# It is the same directory listing as any other; the point is that it is the SAME. A
# filesystem that did not wait would read the block before the one it asked for, which is
# not an error anywhere - just quietly the wrong bytes - and this listing would be nonsense
# rather than a failure with a message.
cosmosSlowDisk | CosmOS/Source/cosmos.asm | run | cosmosSlowDisk.in | - | disks/cosmos.img@2000
# The machine building its own tree. It starts with a blank version one disk and makes
# every directory on it, which is the half of the filesystem the machine could only read
# until now.
+10 -1
View File
@@ -205,6 +205,14 @@ while IFS='|' read -r name src mode stdin limit disk; do
# A trailing :ro attaches the image write protected, so that a test can
# check the device bars writes rather than the filesystem asking nicely.
DISKFILE="${disk%:ro}"
# And a trailing @N gives the disk a latency, so that a test can check the
# filesystem waits for it. Every other test runs with the answer there
# before the next instruction, which is the one condition under which not
# waiting looks like working.
DISKWAIT=""
case "$DISKFILE" in
*@*) DISKWAIT="${DISKFILE##*@}"; DISKFILE="${DISKFILE%@*}" ;;
esac
# A name with a directory in it is one of the images makedisks.sh built,
# and is used as it stands. A bare name is scratch: it is removed first so
# that nothing a test writes can be seen by the next one, and the emulator
@@ -214,7 +222,8 @@ while IFS='|' read -r name src mode stdin limit disk; do
*) rm -f "$BUILD/$DISKFILE" ;;
esac
EMUARGS+=(--disk "$BUILD/$DISKFILE")
[ "$disk" != "$DISKFILE" ] && EMUARGS+=(--write-protect)
[ -n "$DISKWAIT" ] && EMUARGS+=(--disk-cycles "$DISKWAIT")
case "$disk" in *:ro) EMUARGS+=(--write-protect) ;; esac
fi
timeout "$RUN_TIMEOUT" "$EMULATOR" "${EMUARGS[@]}" "$BIN" <"$IN" >"$OUT" 2>&1
STATUS=$?