From mboxrd@z Thu Jan 1 00:00:00 1970 From: "J.A. Magallon" Subject: Re: per-thread global variables Date: Sat, 13 Jul 2002 11:43:00 +0200 Sender: linux-smp-owner@vger.kernel.org Message-ID: <20020713094300.GC1836@werewolf.able.es> References: Mime-Version: 1.0 Content-Transfer-Encoding: 7BIT Return-path: Content-Disposition: inline In-Reply-To: ; from hyatt@cis.uab.edu on Sat, Jul 13, 2002 at 05:20:38 +0200 List-Id: Content-Type: text/plain; charset="us-ascii" To: "Robert M. Hyatt" Cc: Lista Linux-SMP 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)