title: What is the Linux process kernel stack state at process creation?
body: <p>I can't find this information anywhere. Everywhere I look, I find things referring to how the stack looks once you hit "main" (whatever your entry point is), which would be the program arguments, and environment, but what I'm looking for is how the system sets up the stack to cooperate with the switch_to macro. The first time the task gets switched to, it would need to have EFLAGS, EBP, the registers that GCC saves, and the return address from the schedule() function on the stack pointed to by "tsk->thread->esp", but what I can't figure out is how the kernel sets up this stack, since it lets GCC save the general purpose registers (using the output parameters for inline assembly).</p>
  
  <p>I am referring to x86 PCs only. I am researching the Linux scheduler/process system for my own small kernel I am (attempting) to write, and I can't get my head around what I'm missing. I know I'm missing something since the fact that Slackware is running on my computer is a testament to the fact that the scheduler works :P </p>
  
  <p>EDIT: I seem to have worded this badly. I am looking for information on how the tasks <strong>kernel</strong> stack is setup not how the tasks <strong>user</strong> task is setup. More specifically, the stack which tsk->thread->esp points to, and that "switch_to" switches to.</p>