3 ms·
yeah, i've been thinking of doing something like your memfd thing for intranin, the bubbleos kernel, which is still vaporware: transmit one or more pages from t
by kragen 2y ago
yeah, i've been thinking of doing something like your memfd thing for intranin, the bubbleos kernel, which is still vaporware: transmit one or more pages from the sender to the receiver as part of the ipc, so they disappear from the sender's address space and appear in the receiver's address space. my theory is that, that way, you get the efficiency of shared memory (mostly, at least) without the security risks and debugging headaches. in a repetitive client/server kind of relationship, you can pass the same pages back and forth, so it's effectively just shared memory with exclusive locking, and it extends smoothly to zero-copy networking across hosts, at least if the network message size isn't small compared to a page (you don't want to have to zero a 4096-byte page in order to deliver it up to a user process with a 153-byte message in it)
obviously this is the opposite extreme from 'fit into the unix model without introducing anything too foreign' ;) and it may turn out that it's not as good an idea as it seems once i try it. but while some aspects of the unix model are very good, i suspect others were more meritorious on non-networked pdp-11
with respect to starting up a thread to run a callback registered for a message port, i feel like it could be done with a great deal less code than this, though maybe i'm being too optimistic about keeping messy real-world complexity out. in einkornix, which i've only tested as a user-level threading library under linux in emulation, my function for starting up such a thread is einspawn(), which is called (like door_create()) with a callback function and a userdata argument. __door_create() also takes a flags argument; einspawn() instead takes a pointer to the task struct it will finish initializing. it's ten instructions long: http://canonical.org/~kragen/sw/dev3/einkornix.S http://canonical.org/~kragen/sw/dev3/einkornix.S