modus
Menu
On this page

The entry address_space

A process drives its own virtual memory. The design: Architecture: The virtual memory of a process.

At its start the process runs its cases, with their numbers:

an arena: a range of 1 GiB of addresses with no memory behind it, whose
  pages are committed as the arena grows, with tables of 1, 16 and 256
  ranges for each kernel entry;
a sparse table: a fixed base of 1 GiB, 1024 pages committed at random;
decommit: the frames and the pages return to the budget at once, and a
  page committed again is zero;
protection: a part of a mapping becomes read only, with the time of the
  shoot-down when 1, 2 or 4 processors run threads of the process;
a guard page: a child process writes down its stack into a page with no
  access, and the kernel stops it there;
large pages: random reads over 64 MiB of one object, through a mapping
  of large pages and through a mapping of pages of 4 KiB;
page tables: each table that a mapping made returns to the budget with
  its unmap, also while another thread uses a page of the same table;
the refusals, each with its error record.

The window shows the numbers. The log has one line for each case and a line "address_space: ok, ..." when each check holds. The checks do not depend on the load of the host.

The process needs the machine with the right Inspect (its own mappings) and the boot image (its child).

What it is for. A process that manages its own memory (an arena, a sparse table, a stack with a guard) needs to reserve addresses with no memory behind them, commit and decommit pages, change their protection, and use large pages. This process does each of these with the kernel operations of the virtual memory, and checks that the budget pays only for what the process uses, and gets each page back.

How to start it. From the start menu, or with start("address_space") in the console.

Its budget from the root service holds 40960 pages and 2 processes: 64 MiB of large pages, two ranges of 1 GiB with their page tables, and the child of the guard page.

What it does not prove. The times (a commit, a shoot-down, a read through large pages) are measures of the host of the run.

address_space module with an entry

Hash
7abb78d93a416453de109d369711cf4f9c54bfbd3ad7d7de874c911d280c7c84
Size
417015 bytes
Exports
0
Imports
0
Imported by
0
License
MIT

A process drives its own virtual memory

FactValue
KindModules with an entry
Sourcesrc/modules/demonstrations/address_space
Boot imageyes: in the boot image, 417015 bytes in this build
Build settingsnone: the defaults of the source
Importsnone
Imported bynone

Neighbours

It imports no module, and no module imports it. The module graph shows it with the other modules that have no edge.

Exports

ExportWhat it does
entry()runs each case once, checks its counts against the budget and the mappings that the kernel reports, writes one log line for each case and the summary (address_space: ok, ... or address_space: wrong: <the first problem>), then keeps the window open until the process is stopped

entry

entry()

entry runs each case once, checks its counts against the budget and the mappings that the kernel reports, writes one log line for each case and the summary (address_space: ok, ... or address_space: wrong: <the first problem>), then keeps the window open until the process is stopped. When the context names the role of the child, it only writes down its stack into the guard page, and the kernel stops it there.

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

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 its own mappings, and starts its child from the boot image.
Other terms of its start grant setnone
Budget that it asks for
  • working memory pages 40884
  • pages of its threads 167
  • pages of the pictures of its window 4800
  • pages of the module and its imports from the files of the build
  • processes 2
  • threads 6
64 MiB of large pages, two ranges of 1 GiB with their page tables, and a child: 40530 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). 40530 + 354 = 40884. With the counted parts, the pages are above the largest budget of a process: the root service has an exception for it (src/modules/system/root/budgets.odin).

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