Re: Kernel stack

From: Jan Hudec
Date: Tue Oct 12 2004 - 08:15:14 EST


On Tue, Oct 12, 2004 at 21:30:54 +0900, aq wrote:
> > > >From what you all discuss, I can say: kernel memory is devided into 2
> > > part, and the upper part are shared between processes. The below part
> > > (the kernel stack, or 8K traditionally) is specifict for each process.
> > >
> > > Is that right?
> >
> > No, it's not. There is just one kernel memory. In it each process has
> > it's own task_struct + kernel stack (by default 8K). There is no special
> > address mapping for these, nor are they allocated from a special area.
> >
> > When a context of some process is entered, esp is pointed to the top of
> > it's stack. That's exactly all it takes to exchange stacks.
>
> OK, lets say there are 20 processes running in the system. Then the
> kernel must allocate 20 * 8K = 160K just for the stacks of these
> processes. All of these 160K always occupy the kernel (kernel memory
> is never swapped out). When a process actives, ESP would switch to
> point to the corresponding stack (of that process).

This is correct.

> The remainding memory of kernel therefore is equally accessible to all
> the processes.

This is not. There is nothing like "remaining memory". **ALL* kernel
memory is equally accessible to all the processes.

There is noting special about the stacks and task-structs. They are
normal 8K structures somewhere in kernel memory.

> Is that correct ?

-------------------------------------------------------------------------------
Jan 'Bulb' Hudec <bulb@xxxxxx>

Attachment: signature.asc
Description: Digital signature