How to run process from kernel

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
tomsk
Posts: 18
Joined: Sat Sep 22, 2018 2:38 pm
Libera.chat IRC: tomsk

Re: How to run process from kernel

Post by tomsk »

So what should I do?
dseller
Member
Member
Posts: 84
Joined: Thu Jul 03, 2014 5:18 am
Location: The Netherlands
Contact:

Re: How to run process from kernel

Post by dseller »

Combuster wrote:
dseller wrote:The code for your executable resides at the end of your kernel. Because that’s where you placed it.
Not even that.

The code for that executable is appended after a proper ELF file. qemu has a built-in bootloader that knows how to read ELF files, so it will look at the ELF headers and load what those headers state. It will not see the second ELF file, as there is no entry for that - its just garbage at the end.

There is also no way to tell a linker you are going to append blobs later - after all, that requires a file offset outside of the initial file which is illegal.
Yeah, that's what I meant to say. I guess "after" would have been a better word choice. :)
tomsk wrote: So what should I do?
This is pretty basic stuff. My honest advice for you is to go and learn the fundamentals of system programming.
tomsk
Posts: 18
Joined: Sat Sep 22, 2018 2:38 pm
Libera.chat IRC: tomsk

Re: How to run process from kernel

Post by tomsk »

So if it is so easy you could show me solution of it :)
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: How to run process from kernel

Post by iansjack »

If you are going to combine the "process" with your kernel, just do it at the source code stage. Define it as another function that you call from main().
tomsk
Posts: 18
Joined: Sat Sep 22, 2018 2:38 pm
Libera.chat IRC: tomsk

Re: How to run process from kernel

Post by tomsk »

But function is not a process, process is application.
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: How to run process from kernel

Post by iansjack »

Not the way that you are trying to do it. You are trying to build it as part of the kernel and then call it. What makes that any different from a simple function?

OK. You need to implement a file system and an elf loader. Then you can load the application from storage at the appropriate address and then run it.
tomsk
Posts: 18
Joined: Sat Sep 22, 2018 2:38 pm
Libera.chat IRC: tomsk

Re: How to run process from kernel

Post by tomsk »

So without file system it is not possible? That it would load into memory at specific address?
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: How to run process from kernel

Post by iansjack »

I'm not convinced that you really know what you want to do.

What makes a process, or application, any different from a function in your kernel?
glauxosdever
Member
Member
Posts: 501
Joined: Wed Jun 17, 2015 9:40 am
Libera.chat IRC: glauxosdever
Location: Athens, Greece

Re: How to run process from kernel

Post by glauxosdever »

Hi,


In order to be able to run a process, you need to get some code and data in a separate user-space address space. How you will get this code and data is another matter.

But I'm getting the impression you are putting the cart before the horse. Start with the kernel core, i.e. interrupt handling, memory management and in-kernel thread management and scheduling. Then try to do user-space processes.


Regards,
glauxosdever
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: How to run process from kernel

Post by Combuster »

So if it is so easy you could show me solution of it
Was I supposed to repeat my second post here?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply