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:
co-authored by
Claude Opus 5
parent
e0cf0a9a25
commit
d4cba36c5e
@@ -18,6 +18,8 @@ void printHelp(const char *programName) {
|
||||
printf(" -c, --cycles N Stop after N cycles instead of running until the program halts.\n");
|
||||
printf(" -f, --fast Run as fast as possible, ignoring the emulated cycle rate.\n");
|
||||
printf(" -D, --disk FILE Attach a disk image, making one if it is not there.\n");
|
||||
printf(" -L, --disk-cycles N How many cycles a block read or write takes. Zero, the\n");
|
||||
printf(" default, finishes before the next instruction starts.\n");
|
||||
printf(" -W, --write-protect Attach the disk read only. A disk the host will not let\n");
|
||||
printf(" you write is read only whether you ask for this or not.\n");
|
||||
printf(" -h, --help Display this help message.\n");
|
||||
@@ -30,6 +32,7 @@ uint8_t parseOptions(int argc, char *argv[], EmulatorOptions *options) {
|
||||
{"fast", no_argument, 0, 'f'},
|
||||
{"disk", required_argument, 0, 'D'},
|
||||
{"write-protect", no_argument, 0, 'W'},
|
||||
{"disk-cycles", required_argument, 0, 'L'},
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{0, 0, 0, 0 }
|
||||
};
|
||||
@@ -41,9 +44,10 @@ uint8_t parseOptions(int argc, char *argv[], EmulatorOptions *options) {
|
||||
options->cycles = 0;
|
||||
options->disk = NULL;
|
||||
options->writeProtect = 0;
|
||||
options->diskCycles = 0;
|
||||
|
||||
// Parse options
|
||||
while ((opt = getopt_long(argc, argv, "dc:fhD:W", long_options, &option_index)) != -1) {
|
||||
while ((opt = getopt_long(argc, argv, "dc:fhD:WL:", long_options, &option_index)) != -1) {
|
||||
switch (opt) {
|
||||
case 'd':
|
||||
options->debug = 1;
|
||||
@@ -70,6 +74,9 @@ uint8_t parseOptions(int argc, char *argv[], EmulatorOptions *options) {
|
||||
case 'W':
|
||||
options->writeProtect = 1;
|
||||
break;
|
||||
case 'L':
|
||||
options->diskCycles = strtoul(optarg, NULL, 0);
|
||||
break;
|
||||
case 'h':
|
||||
printHelp(argv[0]);
|
||||
return OPTIONS_HELP;
|
||||
|
||||
Reference in New Issue
Block a user