modus
Menu
On this page

The entry time_page

The source src/modules/demonstrations/time_page 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 time page.

The kernel writes the time in one page. Each process has this page and can only read it: a process reads the time with one load from memory. This process reads the time in the two ways: from the time page, and with a kernel entry. It counts the kernel entries of each way. The check reads a fixed count of times. In a measure run it reads as often as it can for one second, and writes the reads in one second.

It checks that the time never goes back, that the two ways give the same time, that the milliseconds of the page follow the cycle counter (the kernel writes them from it at each tick: a late tick loses no time), and that the kernel refuses to remove the time page.

What it is for. It shows that the kernel is off the path of a read of the time: the time page gives the time with one load from memory, and one million reads make 0 kernel entries. The read with a kernel entry is measured too, for comparison.

What a reader sees. Start it from the start menu, or with start("time_page") in the console. The window shows the two ways: the reads of the check and their kernel entries. The log gets one line for each way (time_page: the check of the time page: 1000000 reads, 0 kernel entries), the comparison with the cycle counter, then time_page: ok, the time never went back, ..., or time_page: wrong: .... In a measure run (modustool measure time_page) the window and the log have the reads in one second (time_page: the time page: <rate> reads in one second, 0 kernel entries for one million reads).

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

What it does not prove. The rates are measures of the host of the run: no test compares them to a bound.

time_page module with an entry

Hash
ecd00a2fd0420ed573c6254cafee8f58cb6cb6abd626df0bc2a080cf30b688ee
Size
167768 bytes
Exports
0
Imports
1
Imported by
0
License
MIT

A check and a measure of the time page

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

time_page drawing

Exports

ExportWhat it does
entry()finds its own slot with the machine handle, reads the time in the two ways (run), compares the two ways and the cycle counter, tries to remove the time page, and writes the summary line

entry

entry()

entry finds its own slot with the machine handle, reads the time in the two ways (run), compares the two ways and the cycle counter, tries to remove the time page, and writes the summary line. It then draws the window at each event, and measures the time of a draw. It never returns; with no window, it stops with Failed.

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

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 3386
  • pages of its threads 72
  • pages of the pictures of its window 6080
  • pages of the module and its imports from the files of the build
  • processes 1
  • threads 1
The window is counted at its largest size: 1216 x 640 pixels, 4 bytes each, two pictures, 6 225 920 bytes, 1520 pages. A resize holds the old surface and the new one together until the compositor shows the new one, so the working memory holds a second surface at the largest size: 1520 pages. It also holds what time_page used before it stated a budget: the least budget of 2048 pages less its window of 816 x 336 (2 193 408 bytes, 536 pages), 1512 pages, for its module, its stack, the glyphs that it draws itself and its tables. 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). 1520 + 1512 + 354 = 3386.

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