Skip to main content

Module stream

Module stream 

Source
Expand description

stream_buffer.c: a byte ring one task writes and another reads.

A stream buffer is the only kernel object here that is not built on a queue and not built on an event list. It is a ring of bytes plus two task handles, and a task waiting on one blocks on a task notification rather than on an event list — which is why the notification API had to exist before this file could.

Two shapes share the code:

  • a stream buffer passes bytes, and a reader wakes when at least the trigger level of them have arrived;
  • a message buffer passes whole messages, by writing the length in front of each one. A read returns one message or nothing.

The length prefix is sizeof( configMESSAGE_BUFFER_LENGTH_TYPE ) wide, which is size_t unless a configuration says otherwise — eight bytes on the machine the oracle runs on. That width is in the arithmetic of every message send, so it is a Config const here rather than a guess.