All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Hudec <bulb@ucw.cz>
To: suthambhara nagaraj <suthambhara@gmail.com>
Cc: "Dhiman, Gaurav" <gaurav.dhiman@ca.com>,
	main kernel <linux-kernel@vger.kernel.org>,
	kernel <kernelnewbies@nl.linux.org>
Subject: Re: Kernel stack
Date: Tue, 12 Oct 2004 11:41:04 +0200	[thread overview]
Message-ID: <20041012094104.GM703@vagabond> (raw)
In-Reply-To: <46561a790410112351942e735@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1776 bytes --]

On Tue, Oct 12, 2004 at 12:21:37 +0530, suthambhara nagaraj wrote:
> Hi,
> The problem is each process does not have a TSS of its own.Only one
> TSSper processor is present and the process dependant features (Like
> esp) are stored
> in another structure( struct thread_struct ).A kernel stack of size 8k
> (By default)
> is actully shared by processes running on a processor. There is a func named
> load_tss (or something similiar) which loads the TSS from the
> thread_struct structure during task switch .

Yes. Thus each process has it's own TSS. It is just stored differently
when the process is not scheduled.

It comes out of that, that the stack is NOT shared among different
processes, because it is replaced whenever a different process is
scheduled on a CPU.

> A Process does not have an SS entry in its thread_struct but only an
> esp (and esp0) entry. This made me believe that the stack base is the
> same.

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.

The base of the stack does not have to be stored either, because it is
AT FIXED OFFSET from the task_struct! If you don't believe me, look at
definition of the current macro. It says just (%esp & ~8195) (it says it
in assembly, because you can't directly access registers from C, and it
uses some macros that mean "two pages" instead of 8195).

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.

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@ucw.cz>

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2004-10-12  9:42 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <577528CFDFEFA643B3324B88812B57FE3055B9@inhyms21.ca.com>
2004-10-12  6:51 ` Kernel stack suthambhara nagaraj
2004-10-12  9:41   ` Jan Hudec [this message]
2004-10-12 10:05     ` aq
2004-10-12 10:27       ` Jan Hudec
2004-10-12 12:30         ` aq
2004-10-12 13:11           ` Jan Hudec
2004-10-12 14:30     ` Jon Masters
2004-10-12 14:31       ` Jan Hudec
2004-10-13  5:03 Thekkedath, Gopakumar
  -- strict thread matches above, loose matches on Subject: below --
2004-10-13  4:35 Dhiman, Gaurav
2004-10-14 19:31 ` Denis Vlasenko
2004-10-12  7:51 Thekkedath, Gopakumar
2004-10-12  6:15 kernel stack suthambhara nagaraj
2004-10-12 11:09 ` Neil Horman
2004-10-13  3:29   ` suthambhara nagaraj
2004-10-14  3:15     ` suthambhara nagaraj
2001-09-11 15:53 Kernel stack Richard J Moore
2001-09-10 21:47 Raghava Raju
2001-09-10 21:57 ` Erik Mouw
2001-09-11 10:31   ` Emmanuel Varagnat
2001-09-11 12:15 ` Richard B. Johnson
2001-08-27 22:24 Raghava Raju

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041012094104.GM703@vagabond \
    --to=bulb@ucw.cz \
    --cc=gaurav.dhiman@ca.com \
    --cc=kernelnewbies@nl.linux.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=suthambhara@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.