Symmetric Multiprocessing (SMP) development
 help / color / mirror / Atom feed
From: "J.A. Magallon" <jamagallon@able.es>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: "Robert M. Hyatt" <hyatt@cis.uab.edu>,
	Lista Linux-SMP <linux-smp@vger.kernel.org>
Subject: Re: per-thread global variables
Date: Sat, 13 Jul 2002 03:11:14 +0200	[thread overview]
Message-ID: <20020713011114.GC1675@werewolf.able.es> (raw)
In-Reply-To: <1026525032.9956.38.camel@irongate.swansea.linux.org.uk>; from alan@lxorguk.ukuu.org.uk on Sat, Jul 13, 2002 at 03:50:32 +0200


On 2002.07.13 Alan Cox wrote:
>On Sat, 2002-07-13 at 01:12, J.A. Magallon wrote:
>> On IRIX, you have a
>> 
>> // Fixed address space always private for each process/thread
>> #define PRDA        ((struct prda *)0x00200000L)
>> 
>> struct prda*	thrprda;
>> int*	self;
>> 
>
>Which goes to show they weren't planning for clone like performance. A
>single unshared page means two seperate mm structs, two sets of page
>tables and switches causing TLB flushes. All because
>
>	movl %esp, %eax
>	andl $ffff8000, %eax
>	
>and casting that is 'hard'
>

OK, I do not know a word on x86 assembler, but lets see if at least I understand
this.

stack = reserve 32K+sizeof(my_private_area) (say, 1Kb)
clone() lying about stack start: stack + 32K - 1
   (private on top and stack grows downwards)

   |---- stack ----||--- private -----|
   0                32K               33k
                   ^
                   stack passed to clone()

void* getpriv()
{
  // get my stack frame pointer, can be anywhere depending on my
  // 
  movl %esp, %eax
  |---- stack ----||--- private -----|
           ^
           %eax
  // Round it to 32k multiple, cause I know the thread stack is 32k aligned
  // So I have the thread stack end, ie, bottom
  andl $ffff8000, %eax
  |---- stack ----||--- private -----|
  ^
  %eax
  // Move after top of stack
  addl 32K,%eax
  |---- stack ----||--- private -----|
                   ^
                   %eax
  // and I have the begining of my private area, upwards
}

Could it even be correct ?

TIA

-- 
J.A. Magallon             \   Software is like sex: It's better when it's free
mailto:jamagallon@able.es  \                    -- Linus Torvalds, FSF T-shirt
Linux werewolf 2.4.19-rc1-jam3, Mandrake Linux 8.3 (Cooker) for i586
gcc (GCC) 3.1.1 (Mandrake Linux 8.3 3.1.1-0.7mdk)

  reply	other threads:[~2002-07-13  1:11 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-12 16:15 per-thread global variables J.A. Magallon
2002-07-12 16:43 ` Alan Cox
2002-07-12 16:34   ` J.A. Magallon
2002-07-12 17:41     ` Alan Cox
2002-07-12 19:17 ` Robert M. Hyatt
2002-07-13  0:12   ` J.A. Magallon
2002-07-13  1:50     ` Alan Cox
2002-07-13  1:11       ` J.A. Magallon [this message]
2002-07-13  2:05         ` J.A. Magallon
2002-07-13  3:20     ` Robert M. Hyatt
2002-07-13  9:43       ` J.A. Magallon
2002-07-13 14:07         ` Robert M. Hyatt

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=20020713011114.GC1675@werewolf.able.es \
    --to=jamagallon@able.es \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=hyatt@cis.uab.edu \
    --cc=linux-smp@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox