"A. Supreeth Reddy" wrote: > > Hi, > > So, the task union contains the statically allocated stack, > > union task_union { > struct task_struct task; > unsigned long stack[INIT_TASK_SIZE/sizeof(long)]; > }; > > ----------------- > > #ifndef INIT_TASK_SIZE > # define INIT_TASK_SIZE 2048*sizeof(long) > #endif > > The INIT_TASK_SIZE macro takes care of putting the stack a page below. The > INIT_TSS macro in processor.h calls init_stack to get a pointer to this > stack. OK, I understand all that. What I don't understand is how, for a new task t, t->thread->esp gets the proper stack pointer value. The value for the new task's ESP is somehow passed into the sys_fork() call in the pt_regs struct. I don't understand how that makes sense; it seems self-evident that the kernel must set the new task's ESP to the top of the allocated kernel stack, not to some apparently arbitrary value passed in by the caller of sys_fork() (which of course is, ultimately, a user task in most cases). Thanks, -- Joe > rgds, > > -Sup > > % -----Original Message----- > % From: kernelnewbies-bounce@nl.linux.org > % [mailto:kernelnewbies-bounce@nl.linux.org]On Behalf Of Joseph A Knapka > % Sent: Wednesday, December 05, 2001 5:35 AM > % To: Anumula Venkat; kernelnewbies > % Subject: Re: runtimeimage of kernel module > % > % > % Anumula Venkat wrote: > % > > % > Can u please tell me where does the kernel stack lie. > % > And how to get access to it. > % > > % > Regards > % > Venkat > % > % I believe the kernel stack for a task is located on either > % the page above or the page below the task struct. Well, I > % used to believe that. After looking at do_fork() and > % sys_clone(), it appears the location of the new stack is > % actually being passed into sys_clone() in the pt_regs > % argument?!?!? That's very weird; the kernel has to allocate > % space for a new task's stack somewhere. > % > % In fact I notice all the sys_*() functions get a pt_regs > % argument; where does that come from, what does it mean? > % I'm not sufficiently clueful about gas assembler syntax > % to have any idea what the code in entry.S (system_call) > % is doing. > % > % Can anyone clarify how this works? > % > % Cheers, > % > % -- Joe > % -- > % Kernelnewbies: Help each other learn about the Linux kernel. > % Archive: http://mail.nl.linux.org/kernelnewbies/ > % IRC Channel: irc.openprojects.net / #kernelnewbies > % Web Page: http://www.kernelnewbies.org/ > % > > ------------------------------------------------------------------------ > Name: InterScan_Disclaimer.txt > InterScan_Disclaimer.txt Type: Plain Text (text/plain) > Encoding: 7bit -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ IRC Channel: irc.openprojects.net / #kernelnewbies Web Page: http://www.kernelnewbies.org/