From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: To: 9fans@cse.psu.edu Subject: Re: [9fans] Re: Threads: Sewing badges of honor onto a Kernel From: Charles Forsyth In-Reply-To: <20040227115257.F22848@cackle.proxima.alt.za> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Date: Fri, 27 Feb 2004 10:00:32 +0000 Topicbox-Message-UUID: ff0504cc-eacc-11e9-9e20-41e7f4b1d025 >>Just out of curiosity, how do I get to the private space without >>a lock? It's been a long time since I studied these things and lots >>of water has flown under bridges, so I could be missing something. static __inline Proc *getup(void) { Proc *p; __asm__( "movl %%esp, %%eax\n\t" : "=a" (p) ); return *(Proc **)((unsigned long)p & ~(KSTACK - 1)); }; where the process that makes the new process's stack puts a pointer to the private space (a Proc* in this case) at the base of that stack, and where KSTACK is a power-of-2. i don't think it can be accessed portably in Linux, but you don't need a lock.