Symmetric Multiprocessing (SMP) development
 help / color / mirror / Atom feed
From: "J.A. Magallon" <jamagallon@able.es>
To: "Robert M. Hyatt" <hyatt@cis.uab.edu>
Cc: Lista Linux-SMP <linux-smp@vger.kernel.org>
Subject: Re: per-thread global variables
Date: Sat, 13 Jul 2002 11:43:00 +0200	[thread overview]
Message-ID: <20020713094300.GC1836@werewolf.able.es> (raw)
In-Reply-To: <Pine.LNX.4.33.0207122218200.16319-100000@crafty>; from hyatt@cis.uab.edu on Sat, Jul 13, 2002 at 05:20:38 +0200


On 2002.07.13 Robert M. Hyatt wrote:
>
>In the "master thread" I define an array of structures, one per
>thread.  When I start a thread, I pass it the address of its private
>structure.

So:

struct tinfo* data[n];

for (nthreads)
  data[i] = new private struct
  clone(f,data[i])

f(struct tinfo* mydata)
{
  me = mydata->mysefl; // OK till here
  g();
}

g()  // Note I do not pass any tinfo here
{
  // Who am I ?????????
}

You can't call any function from you thread-main function that
needs to self-identify ??

>Note that this has nothing to do with the stack.  Each
>thread _must_ have a stack (mine is 1mb per thread) and you have to
>(on intel) pass the _end_ address since stacks go backward on
>X86 machines.
>
>Another idea is to set up an array of pointers to the private
>(global) structures.  Then have each thread do something
>like pointer[thread_id]->stuff to get to stuff in its private
>structure.
>

We are in the same problem, if thread_id is pid, you need a big array.
If it is not, you need a multi-personality thread_id.

-- 
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  9:43 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
2002-07-13  2:05         ` J.A. Magallon
2002-07-13  3:20     ` Robert M. Hyatt
2002-07-13  9:43       ` J.A. Magallon [this message]
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=20020713094300.GC1836@werewolf.able.es \
    --to=jamagallon@able.es \
    --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