The context of a process
The one record that a process receives when it starts: 20 handles and 24 values. A role is a place of the record with a meaning.
The context: the one record that a process receives when it starts, in place of text arguments that it must parse. The address of the record is the parameter of the entry.
The record has 18 handles and 24 values of 64 bits. Its starter writes it and maps it read-write at
CONTEXT_ADDRESSbefore the first thread runs (the kernel does both for the root service, which has no starter). A process finds each thing at a fixed place: the index of a handle or of a value is its role. So a process needs no name, no path and no parser to find what it was given:ctx.handles[CONTEXT_LOG]is its log, and a handle that its starter did not give is 0. A process that starts with a context of zeros has no handle: it can compute and stop, and reach nothing.Three groups of places exist:
- The places that the system fixes for every process: the log, the budget, the wiring ring, the seed, the fixed ranges that the starter mapped. Every starter writes them in the same way.
- The places of the first process, the root service: the kernel writes them at boot, with every handle that exists then (the machine, the framebuffer, the boot image, the records of the log).
- The places that a starter and its process agree on: the handles 0 to 13 and the values 0 to 8. The root service gives each process the handles of its grants there (
src/library/modus/system,GRANT_...); a call host receives its call ring at 0 and its call region at 1.A handle of the context has the rights that the starter chose, never more than the starter holds. Who starts a process decides what it can reach: the context is the whole of its authority at its start. The design:.
The handles 0 to 13 are the places of a starter and its process, and each is taken by some role. The handles 14 to 18 have the roles of the system below; a new role of the system takes the handle 19, never under
- 14. The handle 19 has no role yet.
The comment above CONTEXT_HANDLES in src/library/modus/contract/operation/operation.odin.
The roles that the system fixes for each process
The values 0 to 15 began as free values, and the roles of the system took 9 to 15 one after the other until two roles wanted one number. The values 16 to 23 are for the roles that the system fixes for every process: a new role of the system takes a number there, never under 16. A starter and its process use 0 to 8 for their own values.
The comment above CONTEXT_VALUES in src/library/modus/contract/operation/operation.odin.
| Constant | Place | Handle or value | What the file says |
|---|---|---|---|
CONTEXT_LOG | 14 | handle | The roles of the handles that the system fixes for each process. A handle that the process was not granted is 0. The handle 14: the log of the kernel, with the right Write. A process writes its lines with the kernel operation |
CONTEXT_VALUE_SEED | 9 | value | The values 9 to 12: the random seed of the process, 32 bytes, that its starter writes. A start with a seed of zeros is refused. The root service has none: it gathers its own. A process does not use the values 9 to 12 for another role. The generator of the process ( |
CONTEXT_VALUE_SEED_STRENGTH | 16 | value | The value 16: the strength of the seed of the system, from which the seed of the process comes: the word of a Seed_Strength. The starter writes it with the seed. The seed itself cannot say how it was made: the generator of the process keeps this value. The handshake of |
CONTEXT_VALUE_SETTINGS_PASS | 17 | value | The value 17: the pass that the process The root service writes it when it starts |
CONTEXT_VALUE_SECOND_POINTER_THEME_ADDRESS | 18 | value | The values 18 and 19: the address and the size of the second pointer theme file that the root service gives the compositor (the theme of the system, beside the theme of the owner at the values 6 and 7 of the compositor). The setting "pointer_theme" chooses between the two. The value 18 is the address where the root service mapped the file, read-only, in the compositor; 0 when it mapped none. |
CONTEXT_VALUE_SECOND_POINTER_THEME_SIZE | 19 | value | The value 19: the size in bytes of the second pointer theme file at the address of the value 18. The compositor reads no byte past it. |
CONTEXT_VALUE_FIXED_RANGES_MAPPED | 20 | value | The value 20: a set of bits, bit n for the member n of the fixed ranges (modus:contract/fixed_addresses, Fixed_Range): the ranges that the starter mapped for this process. A set bit is the statement of the starter that the range is mapped; a process reads nothing at a fixed range whose bit is clear. It is a value of the context, which only the starter writes, and not a field of a shared page, which another process can write. |
CONTEXT_VALUE_DEBUG_IMAGE_SIZE | 21 | value | The value 21: the size in bytes of the debug image, which the starter mapped at the fixed range Debug_Image (modus:contract/fixed_addresses) when its bit of the value 20 is set. The value 23 has no role. A process that prints a stop report (the console) reads the names of the procedures there; with no debug image, a report names offsets only. |
CONTEXT_VALUE_MEASURE_RUN | 22 | value | The value 22: the machine runs for a measure (1), or not (0). See measure run. The root service writes 1 in the context of each process that it starts when the boot image holds the resource A process that measures a rate over a duration (reads in one second, records in one second) does so only when the value is 1 ( |
CONTEXT_BUDGET | 15 | handle | The handle 15: the budget that pays for the process, with the rights Give, Read and Spend. Each page and each object that the process makes is paid from it; Memory_Create and Process_Create name it. The loader of the starter gives it, and a starter cannot put another handle at this place: the process receives its new budget here. The root service receives the root budget with Commit too. When the process stops, what the budget still holds returns to the budget of its starter. The budget of the process. |
CONTEXT_WIRING_RING | 16 | handle | The handle 16: the wiring ring, a memory object with Read and Write, for a process whose module declares a record output or a record input; 0 for each other process. The root service gives each end of a wiring of the process on it (modus:contract/output, Wiring_Command), and gives the handle of each end through its memory, so the process proves that the handle came through it. See wiring ring. The wiring ring. |
CONTEXT_LOG_OUTPUT | 17 | handle | The handle 17: the output ring of the record output log, a memory object with Read and Write, when the wiring list of the start of the process wires log; 0 for each other process. The library writes there each log record that the kernel took, or refused for its budget alone, after it gave it to the kernel (modus:contract/output, Log_Output_Record). The end of log never goes through the wiring ring: a process whose only wiring is log has none. See record output log. The output ring of the record output log. |
CONTEXT_LOG_OUTPUT_END | 18 | handle | The handle 18: the end page of the wiring of log, with Read only: the root service alone writes its end words, so the writer learns that its reader stopped or closed, and no side forges the end of the other. 0 when the handle 17 is 0. The end page of the record output log. |
Read from src/library/modus/contract/operation/operation.odin.
The roles of the first process, the root service
| Constant | Place | Handle or value | What the file says |
|---|---|---|---|
ROOT_MACHINE | 0 | handle | The roles of the first process (the root service). The handle 0: the machine, with every right of the machine. The kernel gives it at boot to the root service only. The root service gives a part of its rights to a process that has a grant for it (Inspect, Stop, Schedule, Physical): a machine handle reaches each process, so no other process receives it whole. |
ROOT_FRAMEBUFFER | 1 | handle | The handle 1: the memory of the framebuffer that the firmware set up, with Give, Read and Write; 0 when the firmware gave no framebuffer. The root service draws the boot display there, then gives it to the compositor, which owns the screen. |
ROOT_BOOT_IMAGE | 2 | handle | The handle 2: the memory of the boot image, with Give and Read: every module and resource that the boot program checked. The root service starts each process from it, and gives it read-only to a process that has the grant image. |
ROOT_LOG_RECORDS | 3 | handle | The handle 3: the memory of the records of the log of the kernel, with Give and Read. The root service gives it, read-only, to a process that has the grant log_records, as the process that shows the log. Memory, with Read: the records of the log. |
ROOT_DEBUG_IMAGE | 4 | handle | The handle 4: the memory of the debug image that the boot program read, with Give and Read: the names of the procedures for the stop reports. The kernel reads none of its pages. Memory, with Read: the debug image that the boot program read. 0: none. |
ROOT_VALUE_WIDTH | 0 | value | The value 0: the width of the framebuffer in pixels; 0 with no framebuffer. The values 0 to 3 describe the handle 1. |
ROOT_VALUE_HEIGHT | 1 | value | The value 1: the height of the framebuffer in pixels. |
ROOT_VALUE_PIXELS_PER_LINE | 2 | value | The value 2: the pixels from the start of one line of the framebuffer to the start of the next, which can be more than the width. |
ROOT_VALUE_FORMAT | 3 | value | The value 3: the order of the bytes of a pixel, a Pixel_Format of the boot information (red first or blue first). |
ROOT_VALUE_BOOT_IMAGE_SIZE | 4 | value | The value 4: the size in bytes of the boot image of the handle 2. |
ROOT_VALUE_DEBUG_IMAGE_SIZE | 5 | value | The value 5: the size in bytes of the debug image of the handle 4. 0: no debug image. |
Read from src/library/modus/contract/operation/operation.odin.
The roles of a process that the root service starts
| Constant | Place | Handle or value | What the file says |
|---|---|---|---|
GRANT_DISPLAY | 0 | handle | The handle 0: the display ring to the compositor, a memory object with Read and Write. A process with a window sends its commands there, and receives its input as completion records (src/library/modus/display). Memory: the ring to the compositor. |
GRANT_ROOT | 1 | handle | The handle 1: the root ring, a memory object with Read and Write, for a process with a start grant of root_ring.ROOT_RING_GRANTS, as the console. It sends Root_Command records on it: start, stop, connect, grants, revoke, replace, and the commands of the principals. The root service checks each command against the start grants of the sender. Memory: the ring to the root service, to start and stop processes. |
GRANT_TERMINAL_PROCESS | 1 | handle | The handle 1 of a terminal, which has no root ring: the process that writes in it, with the right Read (package terminal). A terminal: the process that writes, with Read. |
GRANT_TERMINAL_DEVICE | 0 | handle | The handle 0 of a terminal that draws no window (package terminal, renderer_context_of): the ports of the second serial port for serial_terminal, the framebuffer for grid_terminal. A terminal with a window has its display ring there. Ports, or memory: the device that the terminal draws on. |
GRANT_TERMINAL_INPUT | 2 | handle | The handle 2 of grid_terminal: the input ring of the input service, which it reads in place of the compositor. Memory: the input ring. |
GRANT_MACHINE | 2 | handle | The handle 2: the machine, with only the rights of the grants of the process: Inspect to read the reports of the processes and of the kernel, Stop to stop the machine, Schedule to change the scheduling strategy. The machine, with the rights of the start grant set: Inspect, or Inspect and Stop. |
GRANT_IMAGE | 3 | handle | The handle 3: the memory of the boot image, with Read, for a process with the grant Image: it lists the modules, loads them, and reads the descriptions of their exports. Its size is the value 0. Memory: the boot image, to list the modules. |
GRANT_LOG_RECORDS | 4 | handle | The handle 4: the memory of the records of the log of the kernel, with Read only, for a process with the grant Log_Records: it reads the lines of every process, and writes none. Memory, with Read: the records of the log. |
GRANT_TERMINAL_TEXT | 4 | handle | The handle 4 of a process with the grant Terminal, and of its terminal: the text region (package terminal). The one process with Log_Records, the log service, has a window. Memory: the text region of a terminal. |
GRANT_SERVICE | 5 | handle | The handle 5: the service ring of a service, a memory object with Read and Write. The root service names each new connection of a caller on it, with the call ring and the call region of that caller (src/library/modus/system/service.odin). The file of the service is at the value 1. Memory: the service ring. The root service names each connection of a caller on it. |
GRANT_TERMINAL_RING | 6 | handle | The handle 6 of a process with the grant Terminal, and of its terminal: the terminal ring (package terminal). Memory: the terminal ring. |
GRANT_DEVICE_RING | 6 | handle | The handle 6 of the client of a device service: the block ring of the grant Data_Disk or Scratch_Disk (modus:contract/block), the frame ring of the grant Network_Device (modus:contract/frame), or the stream ring of the grant Sound_Device (modus:contract/timed_stream). A client has one device service, and no terminal. Memory: the block ring, the frame ring or the stream ring. |
GRANT_DATE_PAGE | 6 | handle | The handle 6 of the process date: the date page, with Write (modus:contract/date). Memory: the date page. |
GRANT_STORAGE_RING | 7 | handle | The handle 7 of a process with the grant Store: the call ring of its private store (package storage). Memory: the call ring of the private store. |
GRANT_DATE_PORTS | 7 | handle | The handle 7 of the process date: the two ports of the real-time clock. Ports: the real-time clock. |
GRANT_STORAGE_REGION | 8 | handle | The handle 8 of a process with the grant Store: the call region of its private store. Memory: the call region of the private store. |
GRANT_STORAGE_SERVICE | 9 | handle | The handle 9 of a process with the grant Store: the storage service, with the right Read: its state. The storage service, with Read. |
GRANT_REPLACEMENTS | 10 | handle | The handle 10: the replacement table of the machine, with Read only, for a process that loads modules by itself: its loader reads the table before each load, so a replacement reaches the loads that follow. Memory, with Read: the replacement table of the machine (Replacement_Table). |
GRANT_DEVICE_SERVICE | 10 | handle | The handle 10 of the client of a device service: the device service of its device ring, with the right Read. Its stop is an event of the client, so a wait for an answer of the device service ends when it stops. No client of a device service loads modules by itself. The device service of the device ring, with Read. |
GRANT_DATAGRAM_RING | 11 | handle | The handle 11 of a process with the grant Network: the datagram ring of its endpoint (modus:contract/datagram). Memory: the datagram ring of the endpoint. |
GRANT_TPM_RING | 11 | handle | The handle 11 of a process with the grant Tpm: the ring of the TPM service (modus:contract/tpm_service). Memory: the ring of the TPM service. |
GRANT_NETWORK_CONTROL | 12 | handle | The handle 12 of the network service (the grant Network_Device): the control ring from the root service (modus:contract/datagram). Memory: the control ring of the network service. |
GRANT_SETTINGS_PAGE | 12 | handle | The handle 12 of the process settings: the settings page, with Write (modus:contract/settings). Memory: the settings page. |
GRANT_TPM_SERVICE | 12 | handle | The handle 12 of a process with the grant Tpm: the TPM service, with the right Read: its state. The TPM service, with Read. |
GRANT_CLIENT_TABLE | 12 | handle | The handle 12 of the process with the grant Remote_Clients: the client table, with Read (modus:contract/remote). Memory, with Read: the client table. |
GRANT_DATAGRAM_REGION | 13 | handle | The handle 13 of a process with the grant Network: the datagram region of its endpoint. Memory: the datagram region of the endpoint. |
GRANT_TPM_REGION | 13 | handle | The handle 13 of a process with the grant Tpm: the region of the TPM service. Memory: the region of the TPM service. |
GRANT_VALUE_IMAGE_SIZE | 0 | value | The value 0: the size in bytes of the boot image of the handle 3. |
GRANT_VALUE_TERMINAL_NAME | 0 | value | The values 0 to 3 of a terminal: the name of the process that writes in it, its title (package terminal). |
GRANT_VALUE_SEED_FACTS | 0 | value | The values 0 to 7 of the process randomness: the facts of the seed of the system, which only the root service has (modus:random). |
GRANT_VALUE_FILE_ADDRESS | 1 | value | The value 1, for a service: the address where the root service mapped the file of the process, read-only. The service reads the descriptions of its exports there, to check each call; the value 2 is its size. A service: where the file of the process is, read-only (the descriptions of its exports). |
GRANT_VALUE_FILE_SIZE | 2 | value | The value 2, for a service: the size in bytes of its file at the address of the value 1. |
GRANT_VALUE_STORAGE_FILE_SIZE | 3 | value | The value 3 of a process with the grant Store: the size in bytes of the file of the storage service, which its client reads (package storage). |
GRANT_VALUE_SERVICE_PRINCIPAL | 4 | value | The value 4 of the module file service module_files: the principal of its store (modus:disk_process). |
GRANT_VALUE_TERMINAL_COLUMNS | 4 | value | The value 4 of a terminal: its columns. |
GRANT_VALUE_UNLOCK_MODE | 5 | value | The value 5 of unlock: what this start does, the word of an Unlock_Mode (modus:principals). |
GRANT_VALUE_TERMINAL_ROWS | 5 | value | The value 5 of a terminal: its rows. |
GRANT_VALUE_UNLOCK_NAME | 6 | value | The values 6 to 8 of unlock: the name of the principal to create. |
GRANT_VALUE_UNLOCK_PRINCIPAL | 14 | value | The value 14 of unlock: the number of the principal that asked for a change. |
GRANT_VALUE_TERMINAL_MEASURE | 6 | value | The value 6 of a terminal: 1 when it shows the rates of its process. |
GRANT_VALUE_TERMINAL_SCREEN_WIDTH | 7 | value | The values 7, 8 and 13 of grid_terminal: the width and the height of the framebuffer in pixels, and its pixels of a line. The values 9 to 12 are the seed. |
GRANT_VALUE_TERMINAL_SCREEN_HEIGHT | 8 | value | |
GRANT_VALUE_TERMINAL_SCREEN_PIXELS_PER_LINE | 13 | value | |
GRANT_VALUE_SEAL_ALLOWED | 13 | value | The value 13 of a process with the grant Tpm: 1 when a seal by the TPM is allowed, as the firmware verified the boot program. |
Read from src/library/modus/system/grants.odin.
Grant enum
An enum of the package start_grant on i64: 8 bytes, 34 members. What a process receives, by name.
Root_Ring0Inspect1Stop2Image3Log_Records4Serve5Terminal6Store7
and 26 more
CONTEXT_ADDRESS constant of the package operation
CONTEXT_ADDRESS :: 0x0000_7FFF_FFF0_0000
The address of the context of the process (Context): the starter maps one.
values_with_seed procedure of the package random
values_with_seed :: proc "contextless" (generator: ^Generator, values: [op.CONTEXT_VALUES]u64) -> (with_seed: [op.CONTEXT_VALUES]u64)
values_with_seed gives the values of a process to start with a seed for.
measure_run procedure of the package system
measure_run :: proc "contextless" () -> bool
measure_run says if this process runs for a measure: its starter wrote 1.
ROOT_RING_GRANTS constant of the package root_ring
ROOT_RING_GRANTS :: bit_set[start_grant.]{...}
The start grants that give a process a root ring.
Root_Command type of the package root_ring
Root_Command :: enum u32 {...}
The ring to the root service.
