modus
Menu
On this page

The entry processors

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

A demonstration of several processors.

First, the process asks the kernel what each processor runs, while four of its threads compute: the kernel answers that all the processors run threads of this one process at the same time.

Then 1, 2 and 4 threads compute the same picture, one row at a time. Each row has the tint of the thread that computed it. The panel shows the time of each picture, and the load of each processor.

The process needs the grant to inspect the machine.

What it is for. It shows that the kernel runs the threads of one process on several processors at one time, and what that gives on a job that divides well. A lock guards the next row to compute: the panel counts its waits, so a reader sees the cost of the shared state.

Start: start("processors") in the console, or the bar of the desktop. Its budget has room for 9 threads: the main thread, the 4 threads that compute, and the threads of the first part.

Grants, as the root service gives them:

  • Inspect: the machine with the right Inspect, for the processor reports (what each processor runs) and the system report (how many processors exist). With no such grant it writes "processors: no grant to inspect the machine" and stops with Refused.

What a reader sees: the picture in the tints of the threads, the time of each of the three pictures, the load of each processor and the waits of the lock. The log has "processors: ok, N processors ran the process at the same time" (or "at most N of M"), then once "processors: the picture took A ms with 1 thread, B ms with 2 threads, C ms with 4 threads".

What it does not prove: the times depend on the machine and on QEMU; the process prints them as measures and asserts no speed-up.

processors module with an entry

Hash
d998fbb5f6242c1f9557019dc390b60d041ff9d34914d562a7b331f3f1d1ac9f
Size
153075 bytes
Exports
0
Imports
1
Imported by
0
License
MIT

A demonstration of several processors

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

processors drawing

Exports

ExportWhat it does
entry()The entry of processors: the test of the processors at one time, then the pictures with 1, 2 and 4 threads in a loop for ever

entry

entry()

The entry of processors: the test of the processors at one time, then the pictures with 1, 2 and 4 threads in a loop for ever.

With no window, it stops with Failed; with no grant to inspect the machine, with Refused. It runs run_together once and writes its result. Then it starts 4 threads that compute rows, and the main thread gives them the same picture with 1, then 2, then 4 of them at work, and starts again. The main thread draws the panel at the rate of the screen.

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

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 shows what each processor runs.
Other terms of its start grant setnone
Budget that it asks for
  • working memory pages 1466
  • pages of its threads 224
  • pages of the pictures of its window 2174
  • pages of the module and its imports from the files of the build
  • processes 1
  • threads 9
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: 1112 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). 1112 + 354 = 1466.

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

run_together procedure of the package processors

run_together :: proc "contextless" ()

run_together runs one thread per processor, and waits until the kernel.

src/modules/demonstrations/processors/main.odin:149