Thread IP initialization

Adam Lackorzynski adam at os.inf.tu-dresden.de
Thu Jan 13 18:16:20 CET 2011


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-example.html



Adam
-- 
Adam                 adam at os.inf.tu-dresden.de
  Lackorzynski         http://os.inf.tu-dresden.de/~adam/




More information about the l4-hackers mailing list