modus
Menu
On this page

The entry rings

The source src/modules/demonstrations/rings built with the setting DRAWING_THROUGH_MODULE=true. The text after this paragraph is the comment of that source.

A demonstration of communication between processes: a ring is the one way that processes communicate, and a process reaches only the rings that it was given.

Each square is a process with its own address space. Each line between two squares is a ring: two pages of shared memory. A small colored square is a record. A node takes a record from the ring before it, works on it for some time, and puts it in the ring after it. No record goes through the kernel: the kernel only wakes a process that waits.

This process starts the nodes and gives each one its rings. It maps the same rings, so the picture is the real content of the queues.

left button on a node, or a: add a record
right button on a node, or 1 to 6: stop the process, or start it again

A stopped node takes no record: the records wait in the ring before it. A ring holds 32 records. When it is full, the node before keeps its record and waits.

What it is for. It makes the base interface of the kernel visible: six isolated processes in a circle, each with four memory objects and no other handle. The picture is not a model: it is the content of the real queues, which this process maps too. A stopped node shows that the others go on, and that its records wait for it in its ring.

Start: start("rings") in the console, or the bar of the desktop. It starts its six nodes from the boot image (the module node), each with its own work time: 260, 420, 180, 700, 240 and 340 ms. Its budget has room for seven processes: itself and the six nodes.

Grants, as the root service gives them:

  • Image: the boot image, read-only, to start the nodes from it.

What a reader sees: the circle of nodes, the records in each ring, an arrow on each ring from the node that writes it to the node that reads it, the record that each node holds, and its work time. The log has "rings: ok, 6 processes, 6 rings, 5 records", "rings: node N stopped" or "started" after a key, "rings: the key a adds a record: N records in all", "rings: node N stopped alone" when the kernel stopped it, and "rings: node N does not run: M records wait in the ring before it".

rings module with an entry

Hash
305b7c7a02196456c0bee3507d79f8f83f42a73727d0108368a4cf2638684fc5
Size
243299 bytes
Exports
0
Imports
1
Imported by
0
License
MIT

A demonstration of communication between processes: a ring is the one way that processes communicate, and a process reaches only the rings that it was given

FactValue
KindModules with an entry
Sourcesrc/modules/demonstrations/rings
Boot imageyes: in the boot image, 243299 bytes in this build
Build settings
  • DRAWING_THROUGH_MODULE=true
Imports
Imported bynone

Neighbours

What it imports, at its left, and what imports it, at its right: the part of the module graph that touches it.

rings drawing

Exports

ExportWhat it does
entry()The entry of rings: it makes the rings, starts the six nodes, puts five records in the circle, then draws and answers keys and clicks for ever

entry

entry()

The entry of rings: it makes the rings, starts the six nodes, puts five records in the circle, then draws and answers keys and clicks for ever.

It takes its random generator: each node gets its seed from it. With no seed, it stops with Refused; with no window, no boot image, no memory for the rings or a node that does not start, with Failed (fail). Each turn of the loop takes the events, looks for a node that stopped (watch), draws the rings, and waits 33 ms or until the next event.

Form
The entry of the module: one parameter, an address, fixed by the contract.
Source
src/modules/demonstrations/rings/main.odin:171

Read from the source of the module, as the build reads it to describe the exports (tools/modustool/build/describe.odin).

What the root service gives it

WhatValueAs the root service says
GrantsIt starts its nodes from the boot image, and its nodes write on the log.
Other terms of its start grant setlog_gives = true
Budget that it asks for
  • working memory pages 4468
  • pages of its threads 186
  • pages of the pictures of its window 3038
  • pages of the module and its imports from the files of the build
  • processes 7
  • threads 7
Six nodes: 4114 pages. And the glyph memory of the copy of the text rendering of the drawing module, which draws its text: 354 pages (display.TEXT_MEMORY_PAGES). 4114 + 354 = 4468.

The start grant set is read from start_grant_sets in src/modules/system/root/start_grant_sets.odin. The stated budget is read from the constant MODULE_BUDGET of the source of the module (its line); the build adds the counted parts and writes the sum in the module (tools/modustool/build/budget_count.odin); the root service accepts it up to the largest budget of a process, and adds the limits of processor time and of log records (src/modules/system/root/budgets.odin).