3 ms·
> What’s the difference in practice compared to every other OS where app is just a “int main() { … }” function? Your premise is wrong: in, say, Windows or GNU/
by aleph_minus_one 3y ago
> What’s the difference in practice compared to every other OS where app is just a “int main() { … }” function?
Your premise is wrong: in, say, Windows or GNU/Linux an application is, say, a PE/COFF or ELF executable, both non-trivial file formats. The int main(...) function in C is just a very leaky abstraction of all this.
- optymizer 3y agoAs opposed to what? Code that can be directly loaded into memory with no headers? That's how .COM files worked. There is no such thing as "program is just a function" unless it's compiled with the OS, like on some microcontrollers. For programs residing on storage, the OS needs a way to load them into memory along with its resources which means it needs to read some kind of format, even if it's trivial.
- aleph_minus_one 3y agoBut you can separate the file format of the executable from the loading process, i.e. implement "doing what the OS loader does" on your own. This way, you can define your completely own executable format instead of being forced to use the one that your OS wants you to use, or even decide that it doesn't have to be a file format (e.g. stream the data from a network stream).
- DSMan195276 3y agoI think you're making a wrong assumption about how this OS works, its programs are still loaded from ELF executables, the parser is here: https://github.com/Ruddle/Fomos/blob/91cf732f173a01cdec3df438617c87b6dd8dcf8e/bootloader/kernel/src/app.rs#L70 https://github.com/Ruddle/Fomos/blob/91cf732f173a01cdec3df43... The "app is a function" distinction is simply about the `Context` struct passed it, otherwise it loads and runs executables as expected (load ELf memory segments in, jump to entrypoint) Edit: I guess I'd also add that on Linux or other OSs it's possible to construct and run process completely from memory with no on-disk executable file. JIT compilers do effectively this, the produce the executable code completely in memory and run it.
- aleph_minus_one 3y ago> I guess I'd also add that on Linux or other OSs it's possible to construct and run process completely from memory with no on-disk executable file. This is rather likely true. But since writing such code is much harder than, say, writing FizzBuzz, I assume that somewhere in the OS code, a "wrong" abstraction is used which makes this task far too complicated.
- DSMan195276 3y agoWhy do you assume it's complicated? It's not hard, it's actually very straight forward. The hard part is generating the executable code in the first place (if you're not reading it out of an executable file). I'm not really sure what you're looking for or expecting unless you want the OS to compile your code for you (which this OS doesn't do either).