Subj : Re: a thread question To : comp.programming.threads From : David Butenhof Date : Tue May 17 2005 04:39 pm David Schwartz wrote: > "Chris Friesen" wrote in message > news:d635g0$91r$1@zcars129.ca.nortel.com... > >>Not necessarily. I think it would be legal to have a portion of the >>memory map dedicated to thread local storage, and thus you really wouldn't >>be able to see other thread's memory. The same virtual address would map >>to different physical pages for each thread. > > I think you are right. I really should have said, "actually, even > thread-local variables usually reside in shared memory". Thread-local variables aren't standard, but generally implementations aspire to treat "thread locality" as essentially a storage class attribute on the declaration. That makes them addressible entities such that a thread could execute, e.g., 'fscanf ("%ld", &tls_variable);'. POSIX rules clearly state that "Anything whose address may be determined by a thread [...] [is] accessible to all threads in the same process." (Full definition under "Thread", section 3.393 in XBD document.) Since thread-local storage isn't standardized, the standards police aren't likely to come looking for anyone who breaks the rule; but probably some user, sooner or later, will. ;-) -- Dave Butenhof, David.Butenhof@hp.com HP Utility Pricing software, POSIX thread consultant Manageability Solutions Lab (MSL), Hewlett-Packard Company 110 Spit Brook Road, ZK2/3-Q18, Nashua, NH 03062 .