Page 1 of 1

How do I run a program?

Posted: Mon Jan 23, 2012 2:36 pm
by atomizer
Hi, it's my first post/thread :)

I've made simple os based on Brandon's F. Kernel Dev. Tut. And I have a question. Hoc can I make and run a program for this OS? I've written simple command recognition, to make it easier to do. Does my OS need to be able to read/write files?

The point to run progs. on it to for. ex. make while() func not "freeze" whole system when using for. ex. while(x = 1);

So if you can help me, I want to make code look like this:

Code: Select all

when user sumbits a command {
run_program(command);
}
Sorry for english mistakes(if any :P)

Re: How do I run a program?

Posted: Mon Jan 23, 2012 2:49 pm
by piranha
If you want to load executable files and run them, of course it needs to be able to read and write files. It can't magically know what the code for a program is.

Code: Select all

while(x=1);
Will always loop...= != ==

http://wiki.osdev.org/Executable_Formats
Is a good place to start looking. Keep in mind that you're going to want to have a memory manager set up for this to be effective. (paging, a way to malloc() from the OS will make this a lot easier. And then, yes, you'll need to be able to read a file, parse the header and section headers, load the appropriate data into the correct address and then jump to the starting point.

-JL

Re: How do I run a program?

Posted: Mon Jan 23, 2012 2:58 pm
by atomizer
Thanks you. I'll now try to implement file IO. I've actually added malloc(), grow(), free() and realloc(). I'll read more about paging too :)
piranha wrote:

Code: Select all

while(x=1);
Will always loop...= != ==
Yes, but if it is running as a kernel part, you won't be able to write for. ex. But if it will be running in a program, all system processes will be still working.

Re: How do I run a program?

Posted: Mon Jan 23, 2012 3:13 pm
by Solar
atomizer wrote:The point to run progs. on it to for. ex. make while() func not "freeze" whole system when using for. ex. while(x = 1);
That's called "preemption", and you should know stuff like this before doing OS dev.

Re: How do I run a program?

Posted: Mon Jan 23, 2012 3:45 pm
by atomizer
Solar wrote:
atomizer wrote:The point to run progs. on it to for. ex. make while() func not "freeze" whole system when using for. ex. while(x = 1);
That's called "preemption", and you should know stuff like this before doing OS dev.
:( I can't find anything about this/how to do this :/

Re: How do I run a program?

Posted: Mon Jan 23, 2012 6:49 pm
by VolTeK
atomizer wrote:Hi, it's my first post/thread

I've made simple os based on Brandon's F. Kernel Dev. Tut. And I have a question. Hoc can I make and run a program for this OS? I've written simple command recognition, to make it easier to do. Does my OS need to be able to read/write files?

The point to run progs. on it to for. ex. make while() func not "freeze" whole system when using for. ex. while(x = 1);

So if you can help me, I want to make code look like this:
Code:
when user sumbits a command {
run_program(command);
}


Sorry for english mistakes(if any )
Its quite possible that i may be mis reading your goal.. but what your looking for relies in multitasking. I could be wrong but.. load a program, run that program while other program is still in loop... sounds alot like you want multitasking. Have a look online, i could be wrong, but its my guess.

Re: How do I run a program?

Posted: Tue Jan 24, 2012 2:46 am
by Solar
atomizer wrote: :( I can't find anything about this/how to do this :/
Fail. Find a different hobby.

Seriously.

You just said the equivalent to "I don't really know how a power slide is done or what a 4-wheel-drive is, but I want to become a rallye driver. Can you teach me?".

To which, obviously, the short answer is "no", and the long answer is "I lack the time to teach, and you lack the required knowledge to understand what I could be telling you".

(Hint: Find the thread where we recommend dozens of good books on the subject...)

Re: How do I run a program?

Posted: Tue Jan 24, 2012 9:19 am
by atomizer
@GhostXoPCorp Yes, I meant multitasking, I know how to do this. I now understand everything :)

@Solar
Find a different hobby.
Ok, but you change the forum first.

@berkus Thanks, you helped me a lot.

Re: How do I run a program?

Posted: Tue Jan 24, 2012 9:39 am
by Solar
atomizer wrote:@Solar
Find a different hobby.
Ok, but you change the forum first.
I meant that to be a serious and well-meaning suggestion. You exhibited a serious shortcoming in rather basic knowledge, independent research in the face of rather obvious FAQ / "Search this first" / Forum Rules resources, and - as a latest addition - humor.

Thus, I fear that your current hobby won't make you happy, and seriously suggest you pick something else as a pastime.