> What would you say that were most important aspects of re-implementing (subset of?) C++ runtime that must be appropriate for in-kernel usage?
Something that I messed up originally and we're now correcting incrementally is the handling of allocation failures. There are many places in a kernel where errors don't have a natural propagation path (IRQ handling for example), so operations that may fail (like allocation) must be avoided.
In general, heavy use of C++ features like templates and RAII has been very helpful for making kernel development productive.
> Where would I look in the source code to learn about SerenityOS paging algorithms, and virtual memory management in general?
You'll find the kernel memory management code in https://github.com/SerenityOS/serenity/tree/master/Kernel/Me...
Quick breakdown:
- Every Process has an AddressSpace.
- An AddressSpace has a number of Region objects, each with a virtual base address, size, permission bits, etc.
- Every Region has an underlying VMObject.
- VMObject is virtual and can be AnonymousVMObject (MAP_ANONYMOUS) or InodeVMObject (MAP_FILE).
- Cross-process memory sharing occurs when two or more Regions in separate AddressSpaces use the same underlying VMObject.
- MemoryManager handles physical page allocation, fault handling, page tables, etc.