modus
Menu
On this page

The entry shortage

The real shortage of page frames: the frame caches of the processors drained so that a take that cannot fail succeeds (Architecture, "The frame caches"). This process runs alone, on a machine of the test whose boot image has no desktop: the root service gives it nearly all of its pages.

The frame table becomes empty only when the unspent pages of all the budgets and the reserved pages are fewer than the frames in the stacks of the processors. Here the budget of this process holds nearly all of them. Four threads make memory objects until the budget pays no more, and write one byte in each page: each first use is a take that cannot fail. Near the end the frame table is empty while the stacks of the other processors hold frames: the take drains the stacks and succeeds. Then the process checks, with the exact difference of System_Report, that no frame is free anywhere that a budget can pay, that a Memory_Create fails with its error record, frees everything, and checks that the sums are those of the start. It stops the machine with the code 0.

What it is for. It proves a rule of the kernel that no other test can reach: a page that a budget paid for is always there when the process uses it, even when every free frame sits in the cache of another processor. On a machine with a desktop the other processes hold the pages, so the frame table never becomes empty.

Start: no reader starts it. The root service starts it in place of the desktop when the boot image has the module shortage and no module input: the tool builds that image for the test of the shortage. Its row of start_grant_sets has no grant: shortage_start in the root service gives it the machine and nearly all the pages of the root service.

What a reader sees: no window. The log has three lines of counts, "shortage: start: ...", "shortage: full: ..." and "shortage: freed in ...", then "shortage: ok, the stacks were drained for takes that cannot fail, a new object failed only when its budget could pay no page, and each frame returned", or "shortage: wrong". Then the machine stops.

shortage module with an entry

Hash
cd8fa78082f9cd491d7f1eca917dfd397ac36a39082512dd39637f4ee5649fd5
Size
45056 bytes
Exports
0
Imports
0
Imported by
0
License
MIT

The real shortage of page frames: the frame caches of the processors drained so that a take that cannot fail succeeds

FactValue
KindModules with an entry
Sourcesrc/modules/tests/shortage
Boot imageno: not in the boot image
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()The entry of shortage: fill all the memory that its budget pays, check the counts, free it all, check again, and stop the machine

entry

entry()

The entry of shortage: fill all the memory that its budget pays, check the counts, free it all, check again, and stop the machine.

In order:

  1. 1. it reads the system report and its budget, and writes the start line;
  2. 2. 4 threads create memory objects and write one byte in each page, until the budget pays no more; the last pages of the budget become one object that is never used;
  3. 3. it checks that no free frame is left that a budget can pay, and that a new object of one page fails with the error kind Budget;
  4. 4. it closes everything, and waits (with the hang bound) until its budget holds again what it held at the start;
  5. 5. it writes "shortage: ok, ..." or "shortage: wrong", and stops the machine with the code 0 in both cases: the test reads the log.
Form
The entry of the module: one parameter, an address, fixed by the contract.
Source
src/modules/tests/shortage/main.odin:122

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
GrantsnoneOnly the image of the test of a shortage of frames holds it: its start list asks for it, and shortage_start gives it the machine with Inspect and Stop; a command Start of another sender gives it no grant.
Other terms of its start grant setnone
Budget that it asks for
  • the least budget
No MODULE_BUDGET in its source: it asks for the least budget.

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

start_grant_sets global variable of the package root

start_grant_sets := [?]Start_Grant_Set_Row {...}

The start grant set of each module of the boot image, with the reason of each.

src/modules/system/root/start_grant_sets.odin:73

shortage_start procedure of the package root

shortage_start :: proc "contextless" () -> system.Status

The start list of the machine of the shortage asks for it: this service.

src/modules/system/root/main.odin:489