modus
Menu
On this page

The entry log_reader

A test of the log scope: a process that reads its own log records back through the log service, with a connection that does not act for the principal, and the records of the two children that it starts.

What it is for. The memory of the log holds the records of every process, and a process sees no other process. So the log service gives a caller that does not act for the principal its own records only: the records of its process slot with its process serial, which the root service writes in the grant of the connection (log scope). This process proves it: it writes one record before it connects, reads the log from the own number 0, and checks that it receives that one record, as the own number 0, and no other row. A row of another process, or of an earlier run of this process in the same slot, would be a second row.

A starter sees the processes that it started. Before it connects, this process starts two children, log_reader child 1 and log_reader child 2, which each write one record and stop. It lends the process handle of each child to log.process_records and log.process_value_runs, and checks that it receives the one record of that child, as the own number 0: no record of the other child, of this process, or of a child of an earlier run, which has the same name and the same text. The records of its children are not in its own records. It also lends a memory object in place of a process handle, and the process handle of the log service that connect gave it with Read and no Give, and checks both refusals.

The kernel keeps the records of each process in its own log ring, which only the records of that process fill. So after the two children, this process starts a third child, log_reader storm, which writes more records than the whole log keeps and pushes the records of this process and of its two children out of the whole log. Each check above runs after that storm, and still finds each record, with nothing lost. The machine test starts it two times. The designs: and .

What a reader sees. It has no window. Start it with start("log_reader") in the console. It writes on the log the lines below. Most lines with a value are log facts of facts.odin, whose sentence a reader writes from their fields; the record of this process and the record of each child stay text, because the test reads their text and their value run back:

  • log_reader: the record that this process reads back, with the value 42;
  • its storm child writes log_reader storm: a record many times, then log_reader storm: the last record, after more records than the whole log keeps;
  • log_reader: its own records: 1 rows from the own number 0, its first record, in the slot <slot>, lost 0: no row of another process or of an earlier run: as it must;
  • log_reader: the value runs: <count> rows, each of a record of this process, with the run of its value 42: as it must;
  • for each child, log_reader: the records of log_reader child 1: 1 rows from the own number 0, its one record, lost 0: no row of this process, of the other child or of an earlier run: as it must, and log_reader: the value runs of log_reader child 1: 1 rows, the run of its value 1: as it must;
  • log_reader: a child wrote <count> records after the records of this process and of its two children, more than the <capacity> that the whole log keeps, and the own log ring of each one kept its records: as it must;
  • log_reader: the storm child took 900 of the 1000 log records of each second of this process, which kept 100, and each child gave its records back at its stop: as it must: a budget holds its log records as it holds its pages, and counts only its own, so the storm never makes the kernel refuse a line of this process ;
  • log_reader: a memory object in place of a process handle: the log service refused it with Handle_Kind: as it must;
  • log_reader: the process handle of the log service from connect, with Read and no Give: the lend failed with No_Right, and it reads no record of the service: as it must;
  • log_reader: Log refused 12 wrong calls, each with its status and its error record: the level word, the runs and the length past their bounds, an address that the process cannot read, and a text or its runs past the end of what it can read; the own log ring kept the same <count> records, and the budget the same log records and the same refused count: as it must: it calls the kernel operation Log itself (log_operation_check);
  • log_reader: Log wrote a text of 0 bytes, of 1 byte and of 4096 bytes in 1, 1 and 25 records, a text at the level Error, a text with 32 runs that keeps 8, and one byte on the last byte of a page: as it must;
  • log_reader: Log refused 11 wrong facts, each with its status and its error record: ...: as it must: the calls of Log of the form Fact that the kernel refuses (log_fact_check);
  • the raw lines of two facts that it gives to Log itself, then its log fact log_reader.Fact_Probe, which the tool writes on the host as log_reader: a log fact with the value 42, the mark 0x4c4f4746 and the number 7;
  • log_reader: the three facts read back: the form Fact, no next record, the reserved bytes 0, the key of each writer, 0, 144 and 16 value bytes, and the hash of this module in the fact of system.log_fact: as it must: it reads the bytes that the kernel wrote through log.fact_records;
  • log_reader: Log wrote a fact of 48 bytes and a fact of 192 bytes, and system.log_fact the fact Fact_Probe, each in one record: as it must;
  • log_reader: a fact of 145 value bytes in 2 records and a fact of 1168 value bytes in 9 records, at the bound of a call, read back: ...: as it must: it gives Log two facts of several records and reads each record back, joined (long_facts.odin);
  • log_reader: a child whose log limit holds 4 records: ...: as it must: its child log_reader fact budget gives Log facts of more records than its limit has left, which the kernel refuses whole, and this process reads the records of the child (long_facts.odin);
  • in a measure run only, three measures of the log facts, printed and not checked (measures.odin): log_reader: measure: the write of one line, ..., the time of system.log and of system.log_fact for the line of a bad block and of a connection; log_reader: measure: the operation Log, ..., the time of Log for a text, for a fact, and for a call that the kernel refuses at the border of the form; and log_reader: measure: the render of a log fact by module.fact_sentence_write, ..., over the records of a whole log;
  • log_reader: ok, then it stops with Done.

Each child writes log_reader child: the record that the starter reads back, with the value <n>, its number, and stops with Done.

A check that fails writes a line with WRONG, and the process stops with Failed.

Its grants: Connect, to the log service only, with no grant to act for the principal; Image, for the description of the exports of the log service and for the module of its children; and the log with the right Give, so that each child writes its records. A child receives the log only.

See: The log scope of a reader in the repository, The own log ring of a process in the repository, The log limit and the time of a `Log` in the repository

log_reader module with an entry

Hash
c21810f2f773991cd27d41a6cc1d98f2bb1a5efacfa161b689c77d6bf712af99
Size
225280 bytes
Exports
0
Imports
0
Imported by
0
License
MIT

A test of the log scope: a process that reads its own log records back through the log service, with a connection that does not act for the principal, and the records of the two children that it starts

FactValue
KindModules with an entry
Sourcesrc/modules/tests/log_reader
Boot imageyes: in the boot image, 225280 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()

entry

entry()
Form
The entry of the module: one parameter, an address, fixed by the contract.
Source
src/modules/tests/log_reader/main.odin:1137

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
GrantsThe test of the own records and of the records of its children: a connection to the log service and to no other service, with no grant to act for the principal, and the boot image for the description of the exports of that service and for the module of its children. It starts them on its own budget, and the handle of each child is its grant to read the records of that child; each child writes the records that its starter reads back, one of them more than the whole log keeps . See: The log scope of a reader in the repository, The own log ring of a process in the repository
Other terms of its start grant setcallable = {0 = "log"}, log_gives = true
Budget that it asks for
  • working memory pages 1152
  • pages of its threads 129
  • pages of the pictures of its window 0
  • pages of the module and its imports from the files of the build
  • processes 4
  • threads 4
Its rows and its call region, 64 pages, the budgets of its two children, CHILD_PAGES each, and the budget of its storm child, STORM_PAGES: no window, its one thread and the thread of each child. The child of the log limit runs after the storm child stopped, and takes CHILD_PAGES of the pages that the storm gave back, its process and its thread.

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

Error_Record struct

A struct of the package errors: 56 bytes, aligned on 8 bytes, 0 bytes of padding. The error record: what a call that failed says about why, as seven integers.

  • kindi6408 bytes
  • uniti6488 bytes
  • operationi64168 bytes
  • argumenti64248 bytes
  • valuei64328 bytes
  • limiti64408 bytes
  • foundi64488 bytes

process_records procedure of the package log

process_records :: proc "c" (process: system.Lent({.Read}), after: i64, result: ^[]Record, error: ^errors.) -> i64

process_records gives the log records of one process whose process handle the caller lends, from the own number after on, one row each, as records() gives its own records to a caller.

src/modules/system/log/exports.odin:271

process_value_runs procedure of the package log

process_value_runs :: proc "c" (process: system.Lent({.Read}), after: i64, result: ^[]Value_Run, error: ^errors.) -> i64

process_value_runs gives the value runs of the log records of one process whose process handle the caller lends, from the own number after on, as value_runs() gives the runs of its own records.

src/modules/system/log/exports.odin:384

Fact_Probe type of the package log_reader

Fact_Probe :: struct {...}

The log fact of this process.

src/modules/tests/log_reader/main.odin:490

fact_records procedure of the package log

fact_records :: proc "c" (after: i64, result: ^[]Fact_Row) -> i64

fact_records gives the log facts of the log scope of the caller from the number after on, one row each, with the bytes that its writer gave: the record form, the fact key, the module hash, the count of the value bytes, its part and its count of parts, and the value bytes of the record.

src/modules/system/log/exports.odin:491

log_fact procedure of the package system

log_fact :: proc "contextless" (level: op.Log_Level, value: $T, texts: ..string) where intrinsics.type_is_struct(T) && !intrinsics.type_struct_has_implicit_padding(T) && size_of(T) <= op.LOG_FACT_VALUE_CAPACITY

log_fact writes one log fact on the log of the kernel, with a level: the.

src/library/modus/system/text.odin:181