modus
Menu
On this page

The entry host

The call host: a process that loads one module and executes the isolated calls of its exports (package isolated): the arguments travel as records, not as text.

The caller starts one call host per module, with two grants: the call ring and the call region. The call host has no other handle, so the module can reach nothing else: a process holds only the handles that it was given. A fault in the module stops this process only.

What it is for. It makes an isolated call possible: the same export, with the same record description, runs in another process with nothing of the caller. A module that the caller does not trust cannot read its memory, use its handles, or stop it: a fault, or a call that never returns, ends the call host, and the caller goes on.

Who starts it. Not the input: a process that wants an isolated call. The console starts one for isolate("name"), in one of its sandboxes; the process tables starts one of the module sample. The starter maps, read-only, the file of the module, the files of its imports, and the replacements that apply, and gives the call ring and the call region.

What a reader sees. No window. The log gets host: ready, <count> exports when the module is loaded, or host: cannot load the module: <the load error>.

Its grants: none of the root service. Its two handles come from its starter.

The design: Module contract: The isolated call, as implemented.

host module with an entry

Hash
1308958b7f036ac3d3a7e1b714668ff52aa90d385d1a5be4f05880555ff5f491
Size
106496 bytes
Exports
0
Imports
0
Imported by
0
License
MIT

The call host: a process that loads one module and executes the isolated calls of its exports (package isolated): the arguments travel as records, not as text

FactValue
KindModules with an entry
Sourcesrc/modules/system/host
Boot imageyes: in the boot image, 106496 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()loads the module of its starter, tells the starter the result of the load, then runs each call of the call ring, until the starter stops it

entry

entry()

entry loads the module of its starter, tells the starter the result of the load, then runs each call of the call ring, until the starter stops it.

The load. The loader checks the hash of each file, applies the replacements, and maps the segments in this process. A failure writes the load error in the call region, sends the completion Load_Failed, and stops with Failed. A success sends the completion Ok.

The loop. It takes up to one ring of commands at a time; each one is a call of an export with its argument records in the call region (system.export_serve), and gets one completion. It then waits for the next command.

The stop: with no call ring or no call region, it writes host: no call ring or no call region and stops with Refused when its context names no such handle or a handle that it cannot use, else with Failed (system.stop_outcome_of_grant). A fault of the module stops it with the stop report of the fault.

Form
The entry of the module: one parameter, an address, fixed by the contract.
Source
src/modules/system/host/main.odin:66

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
GrantsnoneThe call host: its starter gives it the call ring and the call region.
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).

export_serve procedure of the package system

export_serve :: proc "contextless" (file: []u8, base: u64, region: []u8, ring_memory: Handle, command: ring.Record, memory_objects_allowed: bool) -> (completion: ring.Record)

export_serve executes one isolated call: it calls the export that the.

src/library/modus/system/service.odin:279