Page 1 of 1

loading and executing programs

Posted: Mon Sep 08, 2008 7:01 am
by System123
I am at the stage where I want my OS to load and execute a program, however I am not sure how to implement this. I know what has to be done but I don't know where to start.

Re: loading and executing programs

Posted: Mon Sep 08, 2008 7:49 am
by JamesM
Without sounding patronising, firstly you need to load the program, then you need to execute it.

To load a program you will need a filesystem layer and a driver or two to interact with the physical media.

To execute a program you will need a parser for the file format of your choice (ELF, PE, COFF, binary, etc), a virtual memory manager and (possibly) a system call layer.

If you need more specific information you're really going to have to be more specific in your question!

Re: loading and executing programs

Posted: Mon Sep 08, 2008 8:44 am
by System123
Ok I know that the app must be loaded into memory. It then needs to have the header files read which will then start execution. I am creating my Floppy Device driver to search and load the file into memory. The problem is I don't know if I can load the file anywhere in memory? The other thing is that once it is loaded how do I read the header file, like can I get an example of what it looks like for a PE file.

Re: loading and executing programs

Posted: Mon Sep 08, 2008 9:01 am
by AJ
Hi,

First Google Hit for PE Specification
First Google Hit for ELF Specification

Your OS can either specify that an executable must be linked at a certain address (or address range) or can use position independent code / relocation. The memory layout of your OS is something that you surely design fairly early on, though?

Later, you may want to look at lazy loading for your executables.

Cheers,
Adam