HLL kernel memory management
Posted: Sun Jan 18, 2004 12:53 pm
I got this wild idea today, that one could use a HLL like some Lisp dialect to implement an OS kernel provided that (in addition to low-level access functions) one provided the Lisp code with 2 separate heaps. One of the heaps would be temporary, the other permanent. The permanent heap could be somewhat restricted to allow reference counting, or simply manually managed, while the temporary heap could contain all the throw-away structures that Lisp code creates.
The idea is basicly, that in case of a microkernel, the kernel flow-pattern is more or less "entry->process->return". I wouldn't be surprised if many C-kernel implementations reset the stack on every entry, so why not reset the temporary part of the heap too. Effective, the automatically managed part of heap is only available until the next return to userspace. Data that will be needed after this, must be saved manually to the permanent structures. As long as we can provide memory for a single run of the microkernel without garbage collection, no sophisticated (slow) GC is needed for the temporary stuff created.
One could even give each thread a separate temporary heaps space, similar to private kernel stacks, and with little runtime support even partial resets of the temporary heap could be supported (simply reset, then allocate those parts you need to preserve explicitly before allowing any other allocations).
In short, instead of specifying what to free or writing a garbage collector to do this, how about requiring the code to explicitly say if it actually wants something preserved. No idea if this is actually useful, just my wild thoughts..
The idea is basicly, that in case of a microkernel, the kernel flow-pattern is more or less "entry->process->return". I wouldn't be surprised if many C-kernel implementations reset the stack on every entry, so why not reset the temporary part of the heap too. Effective, the automatically managed part of heap is only available until the next return to userspace. Data that will be needed after this, must be saved manually to the permanent structures. As long as we can provide memory for a single run of the microkernel without garbage collection, no sophisticated (slow) GC is needed for the temporary stuff created.
One could even give each thread a separate temporary heaps space, similar to private kernel stacks, and with little runtime support even partial resets of the temporary heap could be supported (simply reset, then allocate those parts you need to preserve explicitly before allowing any other allocations).
In short, instead of specifying what to free or writing a garbage collector to do this, how about requiring the code to explicitly say if it actually wants something preserved. No idea if this is actually useful, just my wild thoughts..