On Tue, Oct 12, 2004 at 19:05:52 +0900, aq wrote: > > There is no SS entry, because SS does not specify the stack. It is siply > > a segment in which the stack lives. Any segment, that covers all address > > space will do! IIRC in kernel SS == DS. > yes, if I am right, in Linux SS, DS and CS all point to the same base > address ( = 0 ?). To be exact, SS !=DS, since the segment registers in > protected mode point to segment selectors (in GDT ?), and we should > compare the value stored GDT entries, not the value of SS and DS in > this case. Of course. Though since DS and SS need the same parameters, they might actualy point to the same GDT entry. I don't know if they actualy do, though. By the way, C compilers usualy set SS and DS with same base. They would have to do conversion when taking pointers to local variables otherwise. > > The kernel stack is allocated together with the task_struct. Two pages > > are allocated and task_struct is placed at the start while the stack is > > placed at the end and grows down towards the task_struct. > 2 pages of kernel stack or not is optional. Recently version of kernel > allow you to choose to use 4K or 8K size for kernel stack. Yes, it does. Few people touch the "Kernel Hacking" though... > >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. ------------------------------------------------------------------------------- Jan 'Bulb' Hudec <bulb@xxxxxx>
Attachment:
signature.asc
Description: Digital signature