<feed xmlns='http://www.w3.org/2005/Atom'>
<title>pub/teachos/kernel.git, branch develop</title>
<subtitle>An educational OS kernel</subtitle>
<link rel='alternate' type='text/html' href='http://source.arknet.ch/pub/teachos/kernel.git/'/>
<entry>
<title>build/x86_64: add missing -ffreestanding flag</title>
<updated>2026-09-17T12:17:22+00:00</updated>
<author>
<name>Felix Morgner</name>
<email>felix.morgner@ost.ch</email>
</author>
<published>2026-09-17T12:17:22+00:00</published>
<link rel='alternate' type='text/html' href='http://source.arknet.ch/pub/teachos/kernel.git/commit/?id=5bad38935238da045d9fd467eae9dfd958deea34'/>
<id>5bad38935238da045d9fd467eae9dfd958deea34</id>
<content type='text'>
Enable the '-ffreestanding' flag in the x86_64 toolchain file to inform
the compiler about the fact that it cannot rely on the presence of a
standard library implementation, thereby suppressing some optimizations
designed for regular user applications.

GCC supports a number of clever optimizations, some of which rely on the
presence of a standard library. One of them is
"-ftree-loop-distribute-patterns". This optimization performs detection
of certain loop patterns, replacing them with library calls when
applicable. This is problematic for cases in which we implement the
standard library functionality. Consider, a schematic, `memset``:

```c++
void memset(void * d, int v, size_t n)
{
  for(auto i = 0uz; i &lt; n: ++i)
  {
    d[i] = static_cast&lt;std::byte&gt;(v);
  }
}
```

GCC recognizes this loop, and similar versions of it, as an
implementation of `memset`. In a hosted implementation, this is an
important optimization, since a standard library may be able to provide
a specifically optimized version of `memset``. So the compiler replaces
this `memset` loop with a call to `memset`, since it is not aware of the
fact we are currently implementing `memset`. Interestingly, tail
recursion optimization eliminates the call, transforming it into a jump
to the start of `memset`. This leads to execution getting stuck inside
`memset` with no way of exiting and no stack usage increase, thus
causing an infinite lockup.

While we could suppress the specific optimization, it is more effective
to tell the compiler "why" it can emit a call to memset in those cases.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Enable the '-ffreestanding' flag in the x86_64 toolchain file to inform
the compiler about the fact that it cannot rely on the presence of a
standard library implementation, thereby suppressing some optimizations
designed for regular user applications.

GCC supports a number of clever optimizations, some of which rely on the
presence of a standard library. One of them is
"-ftree-loop-distribute-patterns". This optimization performs detection
of certain loop patterns, replacing them with library calls when
applicable. This is problematic for cases in which we implement the
standard library functionality. Consider, a schematic, `memset``:

```c++
void memset(void * d, int v, size_t n)
{
  for(auto i = 0uz; i &lt; n: ++i)
  {
    d[i] = static_cast&lt;std::byte&gt;(v);
  }
}
```

GCC recognizes this loop, and similar versions of it, as an
implementation of `memset`. In a hosted implementation, this is an
important optimization, since a standard library may be able to provide
a specifically optimized version of `memset``. So the compiler replaces
this `memset` loop with a call to `memset`, since it is not aware of the
fact we are currently implementing `memset`. Interestingly, tail
recursion optimization eliminates the call, transforming it into a jump
to the start of `memset`. This leads to execution getting stuck inside
`memset` with no way of exiting and no stack usage increase, thus
causing an infinite lockup.

While we could suppress the specific optimization, it is more effective
to tell the compiler "why" it can emit a call to memset in those cases.
</pre>
</div>
</content>
</entry>
<entry>
<title>ide: silence LTRANS job server warning</title>
<updated>2026-09-14T10:35:50+00:00</updated>
<author>
<name>Felix Morgner</name>
<email>felix.morgner@ost.ch</email>
</author>
<published>2026-09-14T10:35:50+00:00</published>
<link rel='alternate' type='text/html' href='http://source.arknet.ch/pub/teachos/kernel.git/commit/?id=bc31452b02c938ab522ace77f3da99f70c087f3b'/>
<id>bc31452b02c938ab522ace77f3da99f70c087f3b</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>kstd: fix doc comment</title>
<updated>2026-09-10T14:46:51+00:00</updated>
<author>
<name>Felix Morgner</name>
<email>felix.morgner@ost.ch</email>
</author>
<published>2026-09-10T14:46:51+00:00</published>
<link rel='alternate' type='text/html' href='http://source.arknet.ch/pub/teachos/kernel.git/commit/?id=7c299dab6436c3ee1ed2cf5154c8b20a92d23cd9'/>
<id>7c299dab6436c3ee1ed2cf5154c8b20a92d23cd9</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>kapi/system: reduce panic buffer size</title>
<updated>2026-09-10T14:38:41+00:00</updated>
<author>
<name>Felix Morgner</name>
<email>felix.morgner@ost.ch</email>
</author>
<published>2026-09-10T14:38:41+00:00</published>
<link rel='alternate' type='text/html' href='http://source.arknet.ch/pub/teachos/kernel.git/commit/?id=c63a0f8e7ed7a2d88cb24a46a6fd8e409f35756b'/>
<id>c63a0f8e7ed7a2d88cb24a46a6fd8e409f35756b</id>
<content type='text'>
Previously, we allocated a 512-byte buffer for every call of the
formatted panic function. This was heavily increasing the stack size for
a number of functions.

We now don't print to a statically allocated buffer, but rather use the
iterator-based formatting facility and a proxy iterator with a small,
self-flushing buffer. This reduces that static overhead of the formatted
panic function to by almost 500 bytes, while increasing possible message
fidelity, since we are not longer arbitrarily limited by the buffer.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously, we allocated a 512-byte buffer for every call of the
formatted panic function. This was heavily increasing the stack size for
a number of functions.

We now don't print to a statically allocated buffer, but rather use the
iterator-based formatting facility and a proxy iterator with a small,
self-flushing buffer. This reduces that static overhead of the formatted
panic function to by almost 500 bytes, while increasing possible message
fidelity, since we are not longer arbitrarily limited by the buffer.
</pre>
</div>
</content>
</entry>
<entry>
<title>kernel: replace some more plain pointers</title>
<updated>2026-09-10T13:08:37+00:00</updated>
<author>
<name>Felix Morgner</name>
<email>felix.morgner@ost.ch</email>
</author>
<published>2026-09-10T13:08:37+00:00</published>
<link rel='alternate' type='text/html' href='http://source.arknet.ch/pub/teachos/kernel.git/commit/?id=3ce0197e99ecea7be66decc2c3c6f785497ef862'/>
<id>3ce0197e99ecea7be66decc2c3c6f785497ef862</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>kstd/memory: introduce observer_ptr casts</title>
<updated>2026-09-10T12:33:19+00:00</updated>
<author>
<name>Felix Morgner</name>
<email>felix.morgner@ost.ch</email>
</author>
<published>2026-09-10T12:33:19+00:00</published>
<link rel='alternate' type='text/html' href='http://source.arknet.ch/pub/teachos/kernel.git/commit/?id=14ec8e92b45a2eae5bdb3d459cee9633ea129359'/>
<id>14ec8e92b45a2eae5bdb3d459cee9633ea129359</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>docs: add size estimates to project ideas</title>
<updated>2026-09-10T11:52:22+00:00</updated>
<author>
<name>Felix Morgner</name>
<email>felix.morgner@ost.ch</email>
</author>
<published>2026-09-10T11:52:22+00:00</published>
<link rel='alternate' type='text/html' href='http://source.arknet.ch/pub/teachos/kernel.git/commit/?id=fcc2527351589b6e3a85e88d01f1d310165aa8af'/>
<id>fcc2527351589b6e3a85e88d01f1d310165aa8af</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>build: enable coverage in release test builds</title>
<updated>2026-09-10T09:13:52+00:00</updated>
<author>
<name>Felix Morgner</name>
<email>felix.morgner@ost.ch</email>
</author>
<published>2026-09-10T09:13:52+00:00</published>
<link rel='alternate' type='text/html' href='http://source.arknet.ch/pub/teachos/kernel.git/commit/?id=faebda2a8255b18b7a8b341b365e8cfecffe8882'/>
<id>faebda2a8255b18b7a8b341b365e8cfecffe8882</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>kernel/vfs: reduce number registry pruning</title>
<updated>2026-09-10T08:03:46+00:00</updated>
<author>
<name>Felix Morgner</name>
<email>felix.morgner@ost.ch</email>
</author>
<published>2026-09-10T08:03:46+00:00</published>
<link rel='alternate' type='text/html' href='http://source.arknet.ch/pub/teachos/kernel.git/commit/?id=00f2a986760c7720fac58c365f427720bd71b755'/>
<id>00f2a986760c7720fac58c365f427720bd71b755</id>
<content type='text'>
Previously, the number registry did a pruning pass whenever elements,
either all or a filtered subset, were queried by a consumer. This meant,
that every access to elements did an additional O(n) scan of the entire
registry, to ensure no expired devices were still registered. This used
to be necessary, when the ownership model for devices was still in flux.

With the established device ownership model, this has become obsolete.
Additionally, devices get numbered automatically when a device gains a
facet the is observed by the device number registry. Since registering
this type of facet is the responsibility of the device driver, since
only a driver can know how to implement that facet for any given device,
it also becomes the responsibility of the driver to revoke that facet
if and when a device is detached from the system. Any device is always
owned by the bus it is attached to. This means it is the bus'
responsibility to inform drivers about devices disappearing. This closes
the chain of responsibility cleanly, meaning the device number registry
will never have to prune itself in any accessors. Instead, it will be
informed by the facet registry that a facet for a device has been
revoked, allowing it to un-number that device if applicable.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously, the number registry did a pruning pass whenever elements,
either all or a filtered subset, were queried by a consumer. This meant,
that every access to elements did an additional O(n) scan of the entire
registry, to ensure no expired devices were still registered. This used
to be necessary, when the ownership model for devices was still in flux.

With the established device ownership model, this has become obsolete.
Additionally, devices get numbered automatically when a device gains a
facet the is observed by the device number registry. Since registering
this type of facet is the responsibility of the device driver, since
only a driver can know how to implement that facet for any given device,
it also becomes the responsibility of the driver to revoke that facet
if and when a device is detached from the system. Any device is always
owned by the bus it is attached to. This means it is the bus'
responsibility to inform drivers about devices disappearing. This closes
the chain of responsibility cleanly, meaning the device number registry
will never have to prune itself in any accessors. Instead, it will be
informed by the facet registry that a facet for a device has been
revoked, allowing it to un-number that device if applicable.
</pre>
</div>
</content>
</entry>
<entry>
<title>ci: enable release tests</title>
<updated>2026-09-10T07:48:42+00:00</updated>
<author>
<name>Felix Morgner</name>
<email>felix.morgner@ost.ch</email>
</author>
<published>2026-09-10T07:48:42+00:00</published>
<link rel='alternate' type='text/html' href='http://source.arknet.ch/pub/teachos/kernel.git/commit/?id=ae3c7b2026011a6e31a2fd9eb1cd1a68faf462a7'/>
<id>ae3c7b2026011a6e31a2fd9eb1cd1a68faf462a7</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
