The entry date
The date of the machine: this service reads the real-time clock of the machine (the CMOS clock, ports 0x70 and 0x71) at its start and each 10 seconds, and writes in the date page the date of the time 0 of the system. Each process reads the date from the page and the time page, with no kernel entry and no call (src/library/modus/contract/date).
A driver of a clock is a process, not a part of the kernel: the root service gives this process the two ports and the page with the right Write, and nothing else.
The clock gives whole seconds. The service waits for the clock to change its second, so the date of the time 0 is exact to about one millisecond. The clock of the machine keeps UTC (QEMU: -rtc base=utc). Leap seconds are not counted. The year has two digits: the dates are from 2020 to 2099 (src/library/modus/calendar, clock_seconds).
What it is for. It gives the system a date with no kernel entry for a read: the service writes once, in the date page, the date of the time 0 of the system; a process adds the time of the time page to it. The bar of the compositor shows the date and the time this way.
The time zone. The principal chooses it with the setting time_zone of the process settings. This process waits on the settings page, which it reads as each process does, and copies the zone into the date page: the page then holds the whole local time, and the root service, which waits on the date page, moves the next edge of the rule of the day at once.
What a reader sees. No window. The root service starts it at each boot, before the console. The log gets date: ok, <date> UTC, seconds since 1970 <count>, from the real-time clock at the time <time> ms of the system; ..., then, after a new read of the clock, a line with the correction (date: the clock read again ... the date moved by <count> ms): after the first read, after each 30th read, and after a move of one second or more. With no valid clock, the log says the system has no date at the level error, and the bar shows the time since boot. At each new zone: date: the time zone of the date page is +08:00, from the setting time_zone.
Its grants: Clock, the date page with the right Write and the two ports of the clock (the one writer of the date), and Serve, its export now. The settings page, read-only, as each process that is not a terminal.
connect("date")
date.now()
date module with an entry
- Hash
fd7f979d23feb799bf82321d9cb2121abcdec38b7606f81c15b195b305297fbd- Size
77824 bytes- Exports
1- Imports
0- Imported by
0- License
- MIT
The date of the machine: this service reads the real-time clock of the machine (the CMOS clock, ports 0x70 and 0x71) at its start and each 10 seconds, and writes in the date page the date of the time 0 of the system
| Fact | Value |
|---|---|
| Kind | Modules with an entry |
| Source | src/modules/system/date |
| Boot image | yes: in the boot image, 77824 bytes in this build |
| Build settings | none: the defaults of the source |
| Imports | none |
| Imported by | none |
Neighbours
It imports no module, and no module imports it. The module graph shows it with the other modules that have no edge.
Exports
| Export | What it does |
|---|---|
now() -> Date | gives the date and the time of day in UTC, from the date page and the time page: the same value that each process reads with no call |
entry() | maps the date page, reads the clock and writes the first date, then reads the clock again each 10 seconds and serves now, until the machine stops |
now
now() ->
now gives the date and the time of day in UTC, from the date page and the time page: the same value that each process reads with no call. All zero: the machine has no date.
What it is for. A caller with no date page (the console, the host through the remote service) reads the date as one record, with its fields already split.
The record (Date): milliseconds since 1970-01-01 00:00:00 UTC; year, month (1 to 12), day, hour, minute, second; weekday, 1 for Monday to 7 for Sunday (ISO 8601). Leap seconds are not counted.
Errors: none. A record of zeros means that the date page has no date yet: the clock was not read, or gave no valid date. The export needs no grant beyond a connection to the service.
connect("date")
date.now().year
entry
entry()
entry maps the date page, reads the clock and writes the first date, then reads the clock again each 10 seconds and serves now, until the machine stops.
The first read waits for the clock to change its second (synchronize), so the date of the time 0 is exact to about one millisecond. Each next read corrects the page: the time of the system comes from the cycle counter, with a frequency that the kernel measured at boot, and it drifts from the clock.
The stop: with no date page or no ports, it writes date: no date page or no ports of the clock: the system has no date at the level error, and stops with Refused when its context names no such handle or a page that it cannot map, else with Failed. A clock that gives no valid date does not stop it: it writes the error, and tries again at the next read.
- Form
- The entry of the module: one parameter, an address, fixed by the contract.
src/modules/system/date/main.odin:222
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
| What | Value | As the root service says |
|---|---|---|
| Grants | It reads the real-time clock, writes the date page, and serves now(). | |
| Other terms of its start grant set | none | |
| Budget that it asks for |
| 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).
Date record of a module
A record of the module date: 64 bytes, aligned on 8 bytes, 0 bytes of padding.
millisecondsi6408 bytesyeari6488 bytesmonthi64168 bytesdayi64248 byteshouri64328 bytesminutei64408 bytessecondi64488 bytesweekdayi64568 bytes
