The entry crowd
The source src/modules/demonstrations/crowd 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 the shared queue and of the event.
Several threads write records in one queue as fast as they can, and several threads read them. The shared queue has no lock: a thread takes its place with one compare-and-exchange. The last run uses a queue with one lock, for comparison. In the check, each writer writes a fixed count of records. In a measure run the writers go on for one second, and the process writes the records in one second.
The threads of each run wait on one event. The first thread wakes the event one time: all of them start together.
Each record has the number of its writer and a count. A reader checks that the counts of each writer increase. At the end, the records that the readers took are the records that the writers wrote: no record is lost, and no record arrives two times.
What it is for. It shows the shared queue and the event: several writers and several readers on one queue with no lock and no kernel entry for a record, and one wake that starts many threads at once. The queue with one lock gives the measure to compare.
What a reader sees. Start it from the start menu, or with start("crowd") in the console. The window has one row for each run: the writers, the readers, the records that were read. The log gets one line for each run (crowd: shared queue, 2 writers, 2 readers: ...), then crowd: ok, <count> runs, each record written is read one time, each event started all the threads, or crowd: wrong: .... In a measure run (modustool measure crowd) 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. The check is of order and of count, not of speed.
crowd module with an entry
- Hash
39056d46544db931d3b4c6ac0f2c8dbf840b736588a2f22773573fdf29a1d5e4- Size
156615 bytes- Exports
0- Imports
1- Imported by
0- License
- MIT
A check and a measure of the shared queue and of the event
| Fact | Value |
|---|---|
| Kind | Modules with an entry |
| Source | src/modules/demonstrations/crowd |
| Boot image | yes: in the boot image, 156615 bytes in this build |
| Build settings |
|
| Imports | |
| Imported by | none |
Neighbours
What it imports, at its left, and what imports it, at its right: the part of the module graph that touches it.
Exports
| Export | What it does |
|---|---|
entry() | finds its own slot with the machine handle, runs each queue (run), and writes the summary line: it is wrong when a record is lost, read two times, or out of the order of its writer |
entry
entry()
entry finds its own slot with the machine handle, runs each queue (run), and writes the summary line: it is wrong when a record is lost, read two times, or out of the order of its writer. The process then keeps its window open until it is stopped; with no window, it stops with Failed.
- Form
- The entry of the module: one parameter, an address, fixed by the contract.
src/modules/demonstrations/crowd/main.odin:368
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
| What | Value | As the root service says |
|---|---|---|
| Grants | It reads the kernel entries of the process for its measures. | |
| Other terms of its start grant set | none | |
| Budget that it asks for |
| 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: 1390 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). 1390 + 354 = 1744. |
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).
