fix(v4.0.0): step 6e review round 1 -- a take that does not take does nothing; output and answers wait at a middle node; no queue on the kernel's port; a printing wait is not interrupted

- The result of every take is looked at: a wire cut between the look and
  the take leaves nothing acted on (the text before run again, a refusal
  counted, a wait ended by an old answer, a way forgotten).
- A node with no room to pass on what another printed, or its word of how
  text ended, leaves it on the wire it came by and moves it when there is
  room; what is behind it for the same port waits too.  Sleep for room (9)
  is woken by room on any of the node's wires (engine; MESH.md 7d.3).
- The lone node's host keeps no queue for the kernel's port: a message to
  it is error 18.  The step limit is counted while the node waits for room.
- A text waiting for room to print is not interrupted by console text;
  AWAIT is, as before.  (BREAK?) is gone.
- A GONE is believed only by the centre's port; unawaited answers let go
  are counted; nothing past a message's last character goes on a wire;
  AWAIT sets (AWAIT-FROM) only once the stack has been tried.
- test_host_depth.c: ten paths, each run works or ends in one named stack
  error; it fails with (ROOM) or (ROOM-SERVE) taken out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rajames
2026-10-08 20:01:11 -04:00
co-authored by Claude Opus 5.5
parent b1d09af043
commit 6a7d0aa27f
16 changed files with 624 additions and 182 deletions
+14 -1
View File
@@ -316,6 +316,17 @@ static int arrived(const v4_fabric *f, unsigned id)
return 0;
}
/* has a message come off any of the wires that lead from the node since it was last woken by that */
static int freed(const v4_fabric *f, unsigned id)
{
unsigned k;
for (k = 0; k < V4_PORTS; k++) {
const v4_wire_queue *q = f->place[id].wire[k].tx;
if (q && q->freed) return 1;
}
return 0;
}
/* Node `id` is doing an operation. Returns 1 and puts how it went in
* *how, or returns 0: it waits (8 and 9 only). Nothing is copied, put or
* taken unless the answer is 0 -- done. */
@@ -372,7 +383,9 @@ static int operate(v4_fabric *f, unsigned id, v4_cell *how)
if (!tx) { *how = V4_WIRE_NO_ONE; break; }
if (a < 0 || a > (v4_cell)V4_WIRE_CELLS) { *how = V4_WIRE_NO_ROOM; break; } /* no waiting can make that room */
if (v4_wire_room(tx, (unsigned)a) == V4_WIRE_DONE) { *how = V4_WIRE_DONE; break; }
if (!arrived(f, id)) return 0;
if (!arrived(f, id) && !freed(f, id)) return 0;
for (cells = 0; cells < V4_PORTS; cells++) /* woken: the room that has come on any of its wires is seen */
if (f->place[id].wire[cells].tx) f->place[id].wire[cells].tx->freed = 0;
*how = V4_WIRE_NO_ROOM;
break;
case 10: /* room */
+2
View File
@@ -13,6 +13,7 @@ void v4_wire_reset(v4_wire_queue *q)
q->used = 0;
q->mark = 0;
q->arrived = 0;
q->freed = 0;
}
unsigned v4_wire_cells(v4_cell length)
@@ -89,6 +90,7 @@ static void remove_marked(v4_wire_queue *q)
for (i = q->mark; i + n < q->used; i++) q->cell[slot(q, i)] = q->cell[slot(q, i + n)];
}
q->used -= n;
q->freed = 1;
}
int v4_wire_take(v4_wire_queue *q, v4_cell *header7, v4_cell *text, unsigned text_cap)