I would recommend forking and replacing the child. Should be fairly easy to do actually. You can either cleanly discard the inherited data (open file descriptors and whatever else is passed from parent to child) or you can just ignore it and initialise your own data structures. Then you can either implement fork in your own operating system for standalone use or replace the process loader.
Something makes me think that there should be an exec that operates on memory rather than files, but obviously (for security reasons, I assume) most kernel developers decided that it would be better to avoid relying on processes correctly loading and executing an executable image (which, if it went wrong, could have drastic consequences) and rather try to enforce that the kernel does it itself.
_________________ When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.
Syntax checkup: Wrong: OS's, IRQ's, zero'ing Right: OSes, IRQs, zeroing
|