modus
Menu
On this page

The entry flow

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

A check and a measure of one ring: the ring is the base interface of the kernel and the one way that processes communicate.

One thread writes records in a ring as fast as it can. A second thread reads them. No queue operation enters the kernel: a thread enters the kernel only to wait, and to wake the other thread. The check sends a fixed count of records and counts the records that did not arrive in order. In a measure run the threads go on for one second, and the process writes the records in one second. In the two runs it asks the kernel how many times the process entered it.

It runs four rings: two capacities, and two ways to wait. A thread that waits at once enters the kernel each time the queue is full or empty. A thread that first reads the counters for a short time (system.wait_spin) finds most of the time that the other thread continued.

What it is for. It shows that a ring is a non-blocking queue in shared memory: the records move with no kernel entry, and the count of kernel entries for one million records shows how rarely a thread must wait.

What a reader sees. Start it from the start menu, or with start("flow") in the console. The window shows the four rings: the records read in order, and the kernel entries for one million records. The log gets one line for each ring (flow: capacity 32, wait at once: 200000 records read in order, 0 lost, ...), then flow: ok, 4 rings, 0 records lost, or flow: wrong: .... In a measure run (modustool measure flow) the window and the lines have the records in one second.

Its grant: Inspect: the machine handle reads the kernel entries of this process, which the measure counts.

What it does not prove. The rates are measures of the host of the run, printed and never compared to a bound.

flow module with an entry

Hash
867ca5f1f98bb6b33abc5aded8cd1ee6028f3e97e66db5658e0eb01c4dd990e6
Size
151383 bytes
Exports
0
Imports
1
Imported by
0
License
MIT

A check and a measure of one ring: the ring is the base interface of the kernel and the one way that processes communicate

FactValue
KindModules with an entry
Sourcesrc/modules/demonstrations/flow
Boot imageyes: in the boot image, 151383 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.

flow drawing

Exports

ExportWhat it does
entry()finds its own slot with the machine handle, runs the four rings (run), and writes the summary line

entry

entry()

entry finds its own slot with the machine handle, runs the four rings (run), and writes the summary line. A ring is wrong when a record is lost, when the check did not read each record, or when the process found no slot. The process then keeps its window open until it is stopped; with no window, it stops with the code 1.

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

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 reads the kernel entries of the process for its measures.
Other terms of its start grant setnone
Budget that it asks for
  • working memory pages 1829
  • pages of its threads 110
  • pages of the pictures of its window 1647
  • pages of the module and its imports from the files of the build
  • processes 1
  • threads 3
The working memory: the rest of the pages that the root service gave it by its name, once the tool counts its module, its threads and its window: 1475 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). 1475 + 354 = 1829.

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).