so becausse the 1978 pohlig-hellman paper mentioned that one of knuth's taocp books had the sunzi remainder theorem they used, i finally cracked and opened up the knuth 1998 sorting and searching text
in fact, it's perfectly coherent to have each recursive supervisor process describe task scheduling mechanics only between its own processes and no one else's. that in fact makes it super easy for the kernel to implement timesharing by allocating time slices to the entire structured subgraph!
think of it like linux namespaces (i.e. containers)--but instead of retroactively figuring out the mapping from each process to its namespace, then calculating some sort of "quota" (while essentially retaining the global round-robin scheduler),
instead we codify being scheduled on the CPU as not only a privileged operation, but indeed a crucial security boundary in which each supervisor process becomes accountable for how much time it allocates across the subprocesses it spawns
in the kernel, we could even just do "round robin" again--but iterating over strictly nonoverlapping process groups!
this sounds really basic, but what it means is that we don't experience the awful i/o contention that linux does--because all processes blocking on each other's output can be stopped and started at once!
how does "strictly nonoverlapping process groups" work if processes need to share data ex post facto? simple! for two processes A and B, their respective supervisor processes S_A and S_Bmust both request a resource that exposes an interface to write data outside the process-local i/o space. this comes in the form of a capability, and it's the exact definition of our "named i/o sync domains"!
and alternatively but no less appropriately, we will still allow supervisors to request a shared memory buffer capability from the kernel, which it can then expose to multiple processes in its IPC graph. unlike the highly-optimized filesystem abstraction i'm providing (which adds on the concept of "i/o transactions" to negotiate the communication of data across supervisor trees in a structured way), shared memory is going to rely upon the semantics described by the C11 weak memory model for atomic operations for consistency.
the point here is absolutely not to nag applications to do "safe" i/o--all of this is purely motivated by my personal need for speed!!!!
in fact, the POSIX approach here is already perfect! https://www.man7.org/linux/man-pages/man3/shm_open.3.html
The operation of
shm_open()is analogous to that ofopen(2).namespecifies the shared memory object to be created or opened. For portable use, a shared memory object should be identified by a name of the form/somename; that is, a null-terminated string of up toNAME_MAX(i.e., 255) characters consisting of an initial slash, followed by one or more characters, none of which are slashes.
if the /somename key used by two distinct supervisor trees matches, then they can communicate through a shared memory mapping!
however, this global namespace is less than ideal. the way we would improve this is as foilows:
- any named capability (i/o sync domains, shm mappings) is local to a namespace.
- a namespace is itself a capability! but it cannot be requested by name.
instead, a namespace can be created in two ways:
- generated freshly by a supervisor process--this corresponds to randomly generating a secure cryptographic keypair (ECC or DH).
- subsequent named capabilities can be scoped to this namespace. the supervisor process who generates this can explicitly send this namespace to any process it can communicate with, and it can write the keypair to persistent storage so it can recreate it upon reboot.
this next part is a brilliant fucking idea, please get ready (cc @somebody):
- if a supervisor process wants to expose a namespace to other processes, it can do it in two ways, by exposing either:
- just the public key, which strictly supports read-only views of resources in that namespace
- the whole keypair (public & private), which allows the recipient to request named resources in that namespace which can mutate data (and therefore can communicate with others who have access to that namespace)
@somebody i can't fucking believe how naturally that corresponds to the unambiguous trust relationships of public-key cryptography (or to be precise: it maps specifically to the subgroup of unambiguous trust relationships in PKC--not all PKC is unambiguous lol). cc @ireneista
finally, how would we use this to support structured communication? well, in order to mimic an FHS system, i would create an i/o sync domain (essentially a chroot) with standard [readonly] executables mapped to /usr/bin/* (i would probably use busybox since coreutils is not a safe dependency anymore sadly).
the first supervisor process is the init system itself! but i'm thinking i would probably try to build that minimal busybox FHS into the initramfs. maybe i wouldn't even share the private key for that with the actual init system, so even an evil PID 1 written by lennart poettering can't modify its contents with evil calls to dlopen()