Commit 43aa11a
openkal-macos 0.3.0: implement on the kernel, and correct the direction of the suspension primitive (#1)
* probe: measure what this system offers before writing against it
* probe: report every answer rather than stopping at the first refusal
* probe: declare usleep
* probe: one runner, so that the answers arrive
* openkal-macos 0.3.0: implement on the kernel, so that the program above may supply its own runtime
Version 0.2 was written upon the system's C library. That is a correct
implementation of openkal for a program that borrows nothing, and it is wrong
for the program clause 1 names first among the consumers the specification
expects: openkal says nothing about what else a program contains, and a program
above it may define every name the system's library defines. If it does, this
implementation's calls resolve to the program's and the program's resolve back
here. The recursion is unbounded and it appears in neither side's source.
This version issues the kernel's own calls. Two names remain and both were
chosen for one property --- no C library defines them, so a program that defines
every ordinary name still leaves them reachable:
clock_gettime_nsec_np this system counts elapsed time in a unit of
the processor's and the conversion lives in
a library rather than in the kernel
pthread_create_from_mach_thread creating an execution context here means
arranging state the kernel does not arrange
Which names were reachable was measured on the system rather than remembered.
.github/workflows/probe.yml asked it and the sources are written against its
answers.
Three findings are worth recording because they are the return on writing a
third implementation.
The suspension primitive exists on this kernel too, under a different name and
with no shared ancestry with the one Linux offers. openkal.task declares its
boundary as a wait upon a word; version 0.2 built that primitive out of a mutex
and a condition variable, which had the relation backwards. That two unrelated
kernels provide the operation is the evidence that it is the shape of the thing
rather than the shape of one kernel.
This kernel has no call that suspends for a duration --- what its own library
uses is a wait upon an object a program carrying no other runtime does not have
--- so kal_time_sleep is the wait openkal.task already requires, upon an address
nothing ever wakes. That is not a substitute for a sleep; it is a sleep,
expressed with the operation this system has.
This kernel has no call that starts a program relative to a directory, so the
directory is entered by the duplicate before it replaces itself. That duplicate
exists for the length of two calls and is not a resource the caller receives,
which is exactly what openkal declines to offer as an operation of its own.
The `standalone' feature states whether this implementation is the whole of the
program's environment, in the same terms the Linux implementation states it: it
is a statement about the program rather than a smaller variant of the
implementation, and the consumer that knows which arrangement holds declares it.
Continuous integration runs the specification's own suite on both architectures,
compares the exported names against SURFACE.txt, and asserts that the objects
reference nothing of a C library but the two names that are named --- with a
probe that the assertion fails when it should.
* ci: the shared suite, both architectures, and the toolchain named once
* probe: read the kernel's numbers from the system's own table
* probe: three more names the file-system interface needs
* openkal-macos: set a file's modification time, with the resolution this kernel's call has
* ci: the Intel runner under the label it now has
* openkal-macos: report the working directory the way this system reports it, and measure which numbers the kernel serves
This kernel has no call that reports the working directory. The measurement is
in the system's own table: SYS___getcwd is absent. What it has instead is an
enquiry upon an open file that reports the name it was reached by, and that is
what a program on this system uses --- so the directory is opened and asked.
A number that is in the system's table and not in the kernel's is not a failed
call: the kernel raises a signal whose name is "bad system call" and the program
stops, so the diagnostic names the program rather than the number. Reading the
table cannot distinguish the two. numbers.yml now also issues every call this
implementation makes, with arguments that cannot do harm, and reports which the
kernel refuses to recognise.
The Intel runner is named for the release it now belongs to. Under the label it
had, every job that asked for it stayed queued and never started, which reads as
a slow build rather than as an absent machine.
* openkal-macos: this kernel tells the duplicate apart by the second register
Duplicating the calling image is the one call whose result does not fit the
convention the rest of this file meets. This kernel reports which image is which
in the second register: both receive the same first value, and the second is
zero in the original and one in the duplicate. The other kernel tells the
duplicate by giving it a first value of zero, and this implementation was
written against that.
The consequence was not a failed call. Both images took the original's branch,
so the duplicate carried on running the program instead of replacing itself, and
the original waited for a program that never started --- which the conformance
suite reported as "a copy of this program could not be started", four words away
from where the fault was.
This system's own C library hides the difference by forcing the duplicate's
first value to zero in its wrapper. There is no wrapper here, so the difference
is met rather than hidden.
* openkal-macos: this kernel refuses to commit a stream that is not a file, and says so with its own value
* ci: name the object that references a symbol it must not
* ci: examine this package's own objects, and not the ones the build tool emits beside them
* ci: tell this package's objects from the build tool's by name, since both are in one directory
* ci: the build tool has no release for the other architecture, so reach it another way
Every job that asked for an Intel runner failed at the first step: the
installer answers "Unsupported release target: macosx-x86_64", so the suite
cannot be built there at all. That is a property of the tooling and not of this
implementation, and a row that always fails says nothing about either.
What can be done there is done instead. The `numbers' workflow reads that
kernel's own table on both architectures and issues every call this
implementation makes on both, and the conformance job now compiles every source
for the other architecture with the system's own compiler. The three things that
differ between the two --- the calling convention, the register the current
context is reached through, and one field of a signal context --- are all in
src/sys.h, and all three are compiled.
* openkal-macos: ask the kernel which context this is, rather than a register that does not always say
Version 0.3 read the identity from the register each architecture reserves for
the current thread's own record. That is one instruction and it is wrong for a
context created by the one route a program carrying no other runtime can use:
such a context observes zero there.
openkal requires the identity to be distinct per context and stable within one,
and zero for every started context satisfies neither. The way it failed is worth
recording: a C library above openkal keys its per-context state on this value,
zero is that table's word for "no entry", and what a reader saw was the library
reading its own state through a null pointer --- four layers from the register.
The kernel is asked instead. It answers with the identity it gave the context,
which is never zero and never shared. The cost is a call where a load would have
done, which is the right trade for a value whose wrongness the caller cannot
detect.
---------
Co-authored-by: mcpplibs <noreply@mcpplibs.org>1 parent 4cfcba6 commit 43aa11a
16 files changed
Lines changed: 1862 additions & 589 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
3 | 18 | | |
4 | 19 | | |
5 | 20 | | |
6 | 21 | | |
7 | 22 | | |
8 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
9 | 29 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
22 | 46 | | |
23 | 47 | | |
24 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
25 | 63 | | |
26 | 64 | | |
27 | 65 | | |
| |||
35 | 73 | | |
36 | 74 | | |
37 | 75 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
42 | 81 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
47 | 89 | | |
48 | | - | |
| 90 | + | |
49 | 91 | | |
50 | | - | |
| 92 | + | |
51 | 93 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
64 | 107 | | |
65 | | - | |
| 108 | + | |
66 | 109 | | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
| 110 | + | |
75 | 111 | | |
76 | 112 | | |
77 | | - | |
78 | | - | |
| 113 | + | |
| 114 | + | |
79 | 115 | | |
80 | 116 | | |
81 | | - | |
82 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
83 | 126 | | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
92 | 131 | | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
102 | 135 | | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
0 commit comments