Shared memory
A neighbour's variables are visible to nobody. A cell is visible to everyone linked to it — and that is what division of labour is built on
Processors have no shared variables. None at all: copper in one and copper in the other
are two different values, and there is nothing that lets you learn the other one. A memory
cell, though, is an ordinary block, and both of them can connect to it.
There are two processors on the map. The upper one asks the store and puts the answer into the cell; the lower one takes it out and prints it. Their links differ: the upper has the store and the cell, the lower has the cell and the board. The only thing they share is the cell.
Why divide the work
Section titled “Why divide the work”A processor’s budget of instructions is its own — @ipt per tick — and it can only be spent
on itself. Two processors work in parallel, and that is the only way to make logic faster:
- the slow part (walking links, searching with a radar) lives in one processor and puts the result into memory;
- the fast part (drawing on a display, leading a unit) lives in another and takes what is ready.
The second one does not wait for the first: it reads what is there, and if that is last iteration’s value, it works with that.
The agreement is yours to make
Section titled “The agreement is yours to make”A cell cannot say “the data is fresh” or “a write is in progress”. All there is are slots and values; the meaning is an agreement between the programs, and it is written down only in the author’s head.
Hence a simple rule: label the addresses — in a comment in the program or on paper.
| Address | What lies there |
|---|---|
| 0 | copper in the store |
| 1 | how much we want |
| 2 | flag: a delivery is needed |
What else can be shared
Section titled “What else can be shared”- A memory cell — 64 slots, size 1×1: enough for an agreement of a few numbers.
- A memory bank — 512 slots: lists, queues, tables.
- The processor itself — a neighbour’s variables by name, with no extra block on the map; that is the next lesson.
- A message block — text only, and for a human only: a program cannot read it.
The other side of it: any processor linked to a cell can write to it. There is no protection, and an accidental write to someone else’s address looks like “the data corrupts itself”.
Unofficial fan project, not affiliated with Anuke. Mindustry sprites, fonts and translations © Anuke, used under GPL-3.0; Fira Code under OFL-1.1. Site code is GPL-3.0.