feat(v4.0.0): the wait in the engine -- a node offers a word and sleeps
A node stores a word to offer on any of its ports and fetches the wait: it is blocked until a word comes for it or one of its offers is taken, and the fabric does the handing over in one step. The port block moves in the nucleus's map to make room for the new addresses. Nothing uses it yet. MESH.md 7c; plan step 6d task 1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
dfabfa46f6
commit
075385ab63
@@ -43,6 +43,8 @@
|
||||
#define V4_PORTS 8u
|
||||
#endif
|
||||
#define V4_PORT_ANY V4_PORTS /* not a port: "whichever port has a neighbour writing" */
|
||||
#define V4_PORT_OFFER (V4_PORTS + 4u) /* not a port: the offer on port 0; the offer on port k is k further (the wait, below) */
|
||||
#define V4_PORT_WAIT (2u * V4_PORTS + 4u) /* not a port: the wait */
|
||||
|
||||
#ifndef V4_NODE_WORDS
|
||||
#define V4_NODE_WORDS 1024u
|
||||
@@ -112,6 +114,10 @@ typedef struct {
|
||||
unsigned writers; /* bit k: the neighbour on port k is blocked writing to this node */
|
||||
unsigned readers; /* bit k: the neighbour on port k is blocked reading from this node */
|
||||
unsigned since_look; /* words taken from this node since it last fetched either of those */
|
||||
unsigned offers; /* bit k: a word is offered on port k (the wait: docs/v4.0.0/MESH.md 7c) */
|
||||
v4_cell offer[V4_PORTS]; /* the words offered */
|
||||
int waiting; /* non-zero: the read it is blocked in is the wait */
|
||||
int offer_asked; /* non-zero: `asking` stands for the offer on `ask_port` (v4_node_offer_as_write) */
|
||||
|
||||
/* DSTACK-DEPTH and RSTACK-DEPTH (D-16). See v4_node_stack_regs_attach. */
|
||||
v4_cell dstack_reg; /* its word address, or -1 */
|
||||
@@ -236,6 +242,34 @@ unsigned v4_node_words_since_look(const v4_node *n);
|
||||
* that is not blocked at a port, or is reading "any port". */
|
||||
int v4_node_port_gone(v4_node *n, v4_cell code);
|
||||
|
||||
/* THE WAIT (docs/v4.0.0/MESH.md 7c). After the addresses above come
|
||||
* base + V4_PORT_OFFER + k the offer on port k: a store here is the word
|
||||
* the node offers to write to that port. It is
|
||||
* remembered and waits for nothing.
|
||||
* base + V4_PORT_WAIT the wait: a fetch here blocks the node until a
|
||||
* word comes for it on any port, or one of its
|
||||
* offers is taken, whichever is first.
|
||||
* A word that came is fetched as from "any port", and "which port" says
|
||||
* where from. When an offer was taken the fetch gives 0 and "which port"
|
||||
* gives V4_PORTS + k: the offer on port k. Either way every offer the node
|
||||
* had is withdrawn. Whoever connects the ports does the handing over
|
||||
* (fabric.h); a node in the wait is blocked reading "any port" as far as a
|
||||
* writer to it can tell.
|
||||
*
|
||||
* 1 if the node is blocked in the wait with nothing given yet. */
|
||||
int v4_node_in_wait(const v4_node *n);
|
||||
|
||||
/* The offer on port k has been taken: the node is unblocked and will fetch
|
||||
* 0, from V4_PORTS + k. 0 if it is not in the wait or has no offer there. */
|
||||
int v4_node_offer_taken(v4_node *n, unsigned k);
|
||||
|
||||
/* For a host with one node, whose devices always take what is written: if
|
||||
* the node is in the wait with an offer, it becomes a blocked write of the
|
||||
* word offered on the lowest such port -- asking, request, ask_port -- and
|
||||
* v4_node_port_served then completes the wait as v4_node_offer_taken would.
|
||||
* 1 if it did. */
|
||||
int v4_node_offer_as_write(v4_node *n);
|
||||
|
||||
/* The neighbour on `port` writes `value`: the node, blocked reading that
|
||||
* port or "any", is unblocked and will fetch it. */
|
||||
void v4_node_port_give(v4_node *n, unsigned port, v4_cell value);
|
||||
|
||||
Reference in New Issue
Block a user