What is trampoline.S for?
esk at ira.uka.de
Wed Mar 8 20:03:47 CET 2006
> Whenever i try to start executing first thread in a new address
> space, its pager is receiving pagefault (at 0x0000002b), eventhough
> none of the mapped code touches that place. Why is it?
> I found out that CHACMOS is mapping trampoline.S at that address. I
> What is this trampoline.S is for? I tried to understand
> trampoline.S code, but i couldn't. I didnt find any FAQ entry
> regarding this. Can anyone please help me here?
> NOTE: I am using pistachio-0.4
Don't know the chacmos code and can't tell what it does. I can tell
you what trampoline.S in Pistachio is used for, though.
In some cases that kernel creates some form of "asynchronous event"
for another thread. This is implemented by creating a new stack frame
on the kernel stack of that thread. The next time this thread is
activated, the context described by this new stack frame is started.
The new context is actually a function invokation (see the invoke()
methods in include/glue/v4-ia32/tcb.h). If we have to pass some
parameters to this function, the parameters have to be popped off the
stack before the old context is resumed. This is what the
notify_trampoline in trampoline.S does. It simply pops two parameters
off the stack and resumes the old context by jumping ("returning") to
its instruction pointer.
More information about the l4-hackers