Pipes and interprocess communication
One blocking byte FIFO connecting two independently scheduled contexts.
Supported syntax
producer [arguments] | cat
producer [arguments] | lessAllowed producers are help, ls, pwd, cat, echo, uname, mem, time, date and ps. The consumer must be bare CAT or LESS. Case-insensitive command matching applies on both sides.
There is one pipe system-wide, with exactly two stages. A free or finished slot 1/2 must be available for the consumer. MBC, EXEC, EDIT and other unlisted commands are rejected as producers. The PIPE command itself displays usage; it is not the operator.
Startup and lifetime
| Step | Dispatcher / process action |
|---|---|
| 1 | PID 0 verifies the producer and loads the pager consumer module into its separate application window. |
| 2 | The dispatcher validates syntax, activates the pipe and creates its consumer in slot 1 or 2. |
| 3 | The consumer gets an initial yield to set up display state and wait for input. |
| 4 | The producer starts as foreground PID 3; PID 0 waits for its child. |
| 5 | Both endpoints run cooperatively. The consumer owns keyboard/display; the producer owns filesystem operations. |
| 6 | Producer completion closes the write endpoint. The consumer drains bytes and receives EOF. |
| 7 | PID 0 waits for consumer completion, clears the active pipe state, then resumes the prompt. |
The native application windows stay loaded for the whole pipeline. While the active flag is set, the loader rejects replacement requests; a task cannot resume into overwritten code.
FIFO and blocking behavior
The ring buffer holds 256 bytes at RAM 0x0100–0x01FF, reusing bootstrap storage after the kernel has been loaded. Indices wrap modulo 256; an explicit count distinguishes a full ring from an empty one.
Writing to a full FIFO sets WAIT_WRITE and yields. Reading one byte makes room and wakes the writer. Reading an empty FIFO with an open writer sets WAIT_READ and yields. Writing a byte wakes the reader.
The producer’s normal putc/puts output is bound to the FIFO. The consumer receives bytes in order; no temporary file, batch spool or source-text substitution is involved. The ring operations themselves do not yield midway, and interrupt handlers do not modify it.
EOF, early close and errors
Closing the writer wakes a blocked reader. The reader receives all remaining bytes before EOF; EOF is a separate return value, not a reserved byte within the stream.
Closing the reader wakes a blocked writer with EPIPE, status 21. The producer’s output routine aborts its foreground command immediately, releases file handles and does not continue reading the rest of an unwanted file.
A normal early quit from LESS is treated as a successful user action: if the producer ended with EPIPE, the pipeline returns the consumer’s result. Other producer errors are reported after pipeline completion. On an ordinary non-EPIPE path, the returned pipeline status is the producer’s status, not a generalized combination of every process result.
Consumer task return closes its endpoint. A detected consumer stack fault also closes it and wakes the writer, preventing a producer from sleeping forever on a reader that can no longer run.
Paging and keyboard ownership
Piped LS suppresses its built-in eight-entry pause. The LESS consumer chooses when to stop for a page. BK or space advances; lowercase q or SU+C closes the consumer. There is no backward paging on a pipe. At the final page, an advance or quit action exits.
The CAT consumer simply forwards bytes to the console and yields frequently. A console-input CAT producer is disallowed, because the consumer owns keyboard/display during a pipeline.
Boundaries
- One FIFO, one writer, one reader; no multi-stage chains or multiple simultaneous pipelines.
- No named pipes, duplicated handles, stderr channel, tee, redirection to files, shell filters loaded from disk or arbitrary consumer arguments.
- No fork, signals, process groups or detached pipelines. The foreground shell cannot accept a new command while the pipeline runs.
- Other native workers can continue if a slot remains; there is no BASIC producer or consumer in this release.
Examples
ls /mnt/smp1 | less
cat /mnt/smp1/demo.bas | less
echo Hello MK90 | cat
help | less
ps | cat