How do initialize the IP or SP for thread or determine it location? In the "ThreadControl" system call (which used to create threads) it requires a IP and a SP, so where you get these values from? Are they implicitly determined by the kernel? I've briefly read pingpong source file but the calls made in the source do not seem to provide these values. And also how do I load program in order to execute it? I know this probably sounds like an easy question but I just started experimenting with l4 and I just getting to know things.
On Wed Jan 12, 2011 at 14:44:58 -0800, jason philip wrote:
How do initialize the IP or SP for thread or determine it location? In the "ThreadControl" system call (which used to create threads) it requires a IP and a SP, so where you get these values from? Are they implicitly determined by the kernel? I've briefly read pingpong source file but the calls made in the source do not seem to provide these values. And also how do I load program in order to execute it? I know this probably sounds like an easy question but I just started experimenting with l4 and I just getting to know things.
The IP is that what you give as the 3rd argument for pthread_create(), i.e. the location where a (C-)function is in memory. The stack pointer is the memory location where the stack should start, i.e. usually the top of the memory you or the OS want to use as stack memory for that thread. Loading a program boils down to the same thing, the loader needs to create an address space (task) and put a thread in there with the appropriate IP and SP, and make sure the expected memory contents are there when needed. The following example uses L4 primitives to start a thread so it should give a good overview: http://os.inf.tu-dresden.de/L4Re/doc/examples_2sys_2utcb-ipc_2main_8c-exampl...
Adam
I understand that much but what if I want to load program? Assume I already have access to the file (disk and filesystem driver present) how can I load bare instructions in "instruction segment" from say a Mach-o file. basically what want to know is how you go about creating an task given the bare instructions as in a file.
Hey,
I understand that much but what if I want to load program? Assume I already have access to the file (disk and filesystem driver present) how can I load bare instructions in "instruction segment" from say a Mach-o file. basically what want to know is how you go about creating an task given the bare instructions as in a file.
In such a case you do whatever you'd need to do on any other OS as well. You use a binary loader that interprets the binary format, finds out which sections of the binary should be placed where, sets up the memory layout, and determines the entry point of the application. There is an ELF binary loader already coming with L4Re, you might want to go through it and the Mach-O binary spec if you wanted to have a Mach-O binary loader.
Bjoern
l4-hackers@os.inf.tu-dresden.de