On Thu, 2008-04-24 at 09:35 -0400, Robert P. J. Day wrote: > On Thu, 24 Apr 2008, sahlot arvind wrote: > > > Yes. I agree with Robert. There are two stacks per process. But why > > cannot we just use one stack as I said earlier? > > while there may be other reasons, there's one obvious one -- as i > mentioned in my earlier email, the kernel likes to store a small, > pre-process "thread_info" structure at the bottom of the kernel stack. the other prominent reason is the kernel needs somewhere to keep the state for when you get scheduled off while you're running kernel code on behalf of the userspace process.. this might be in the preemptible kernel, or maybe just when you "sleep" on something like a semaphore, page fault, wait_event*, or any of the other things you can't do in an atomic context ;) I've read speculation about just using one kernel stack per CPU for normal system call usage, another for irqs, and then tearing them up and down dynamically for these interrupted kernel code situations (and perhaps other situs?).. I guess that would work, but it certainly has some overhead. -Patrick -- www.ducksong.com -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ