<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
__thread is only used in C code. The difference is in the gcc backend within the gcc C/C++ compiler. Not cm3cg.<br><br><br> I put in using __thread for Linux. There is some potential for using it elsewhere, but that's all I did. e.g. Solaris sometimes, AIX.<br> All other non-Windows targets use pthread_getspecific/setspecific. <br> It is hidden from any Modula-3 code. It is all in C. m3gdb might might might need to know about it. It could also be that m3gdb gets confused by any C code linked in. Or that m3gdb is old (it is) and is confused by __thread (but again, m3gdb might or might not have a builtin need to often look at these, or maybe just the human debugger wants to see them).<br><br><br>Currently no targets support stack walking. I couldn't get SOLgnu/SOLsun's stack walker to work with the gcc 4.5 backend. I really really tried. I tried not optimizing at all. And/or putting volatile everywhere.<br>Tru64 also didn't work despite a bit of an attempt. I probably also tried not optimizing there. I probably didn't try as much as for SOLgnu/SOLsun due to the machine being slower and the platform being in less use.<br><br><br> - Jay<br><br><hr id="stopSpelling">From: hosking@cs.purdue.edu<br>Date: Thu, 14 Apr 2011 20:28:12 -0400<br>To: jay.krell@cornell.edu<br>CC: m3devel@elegosoft.com<br>Subject: Re: [M3devel] Thread local storage?<br><br>
<meta http-equiv="Content-Type" content="text/html; charset=unicode">
<meta name="Generator" content="Microsoft SafeHTML">There is a difference between an API call for thread locals (pthread_getspecific/pthread_setspecific) and use of __thread in the gcc backend.<div>I think the API call should work fine.  But, as I understand it we are now using __thread for thread exception stacks on targets that don't support stack unwinding (only SOLgnu/SOLsun AFAIK).<br><div><br><div>
<span class="ecxApple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="ecxApple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div style="word-wrap: break-word;"><span class="ecxApple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="ecxApple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="ecxApple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="ecxApple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="ecxApple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="ecxApple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="ecxApple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="ecxApple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div><font class="ecxApple-style-span" color="#0000ff"><font class="ecxApple-style-span" face="Gill Sans"><span class="ecxApple-style-span" style="color: rgb(0, 0, 255); font-family: 'Gill Sans';"><span class="ecxApple-style-span" style="color: rgb(0, 0, 255); font-family: 'Gill Sans';">Antony Hosking</span></span></font></font><font class="ecxApple-style-span" face="Gill Sans"><span class="ecxApple-style-span" style="font-family: 'Gill Sans';"><span class="ecxApple-style-span" style="font-family: 'Gill Sans';"><span class="ecxApple-converted-space"> </span>|<span class="ecxApple-converted-space"> </span></span></span><span class="ecxApple-style-span" style="font-family: 'Gill Sans';"><span class="ecxApple-style-span" style="font-family: 'Gill Sans';">Associate Professor</span></span><span class="ecxApple-style-span" style="font-family: 'Gill Sans';"><span class="ecxApple-style-span" style="font-family: 'Gill Sans';"> | Computer Science | Purdue University</span></span></font></div><div><font class="ecxApple-style-span" face="GillSans-Light"><span class="ecxApple-style-span" style="font-family: GillSans-Light;">305 N. University Street | West Lafayette | IN 47907 | USA</span></font></div><div><font class="ecxApple-style-span" color="#0000ff" face="Gill Sans"><span class="ecxApple-style-span" style="color: rgb(0, 0, 255); font-family: 'Gill Sans';"><span class="ecxApple-style-span" style="color: rgb(0, 0, 255); font-family: 'Gill Sans';">Office</span></span></font><font class="ecxApple-style-span" face="GillSans-Light"><span class="ecxApple-style-span" style="font-family: GillSans-Light;"><span class="ecxApple-style-span" style="font-family: GillSans-Light;"> +1 765 494 6001 |<span class="ecxApple-converted-space"> </span></span></span></font><font class="ecxApple-style-span" color="#0000ff" face="Gill Sans"><span class="ecxApple-style-span" style="color: rgb(0, 0, 255); font-family: 'Gill Sans';"><span class="ecxApple-style-span" style="color: rgb(0, 0, 255); font-family: 'Gill Sans';">Mobile</span></span></font><font class="ecxApple-style-span" face="GillSans-Light"><span class="ecxApple-style-span" style="font-family: GillSans-Light;"><span class="ecxApple-style-span" style="font-family: GillSans-Light;"><span class="ecxApple-converted-space"> </span>+1 765 427 5484</span></span></font></div><div><font class="ecxApple-style-span" face="GillSans-Light"><br class="ecxkhtml-block-placeholder"></font></div></span></span></span></span></span></span></span><br class="ecxApple-interchange-newline"></span></div></span></span><br class="ecxApple-interchange-newline">
</div>
<br><div><div>On Apr 14, 2011, at 5:32 PM, Jay K wrote:</div><br class="ecxApple-interchange-newline"><blockquote><span class="ecxApple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium;"><div class="ecxhmmessage" style="font-size: 10pt; font-family: Tahoma;"> > We've always had thread locals<br><br>ps: user threads do this differently and it could be that m3gdb was never updated for pthreads?<br><br> - Jay<br><br><hr id="ecxstopSpelling">From:<span class="ecxApple-converted-space"> </span><a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a><br>To:<span class="ecxApple-converted-space"> </span><a href="mailto:hosking@cs.purdue.edu">hosking@cs.purdue.edu</a>;<span class="ecxApple-converted-space"> </span><a href="mailto:rodney_bates@lcwb.coop">rodney_bates@lcwb.coop</a><br>Date: Thu, 14 Apr 2011 21:27:10 +0000<br>CC:<span class="ecxApple-converted-space"> </span><a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>Subject: Re: [M3devel] Thread local storage?<br><br>[I wrote a long answer here but it seemed to have gotten lost.]<br><br>We've always had thread locals via TlsAlloc/TlsSetValue/TlsGetValue / pthread_key_create, pthread_setspecific, pthread_getspecific.<br>On Linux we now use __thread instead. It might be a little more efficient. But a much better more difficult change will be to eliminate them in favor of underlying stack walkers.<br>There is nothing in cm3cg about this.<br><br><a href="http://dcvs.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c" target="_blank">http://dcvs.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c</a><br>Revision<span class="ecxApple-converted-space"> </span><b>1.155</b>:<span class="ecxApple-converted-space"> </span><a href="http://dcvs.elegosoft.com/cgi-bin/cvsweb.cgi/%7Echeckout%7E/cm3/m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c?rev=1.155;content-type=text/x-c%2B%2Bsrc" class="ecxdownload-link" target="_blank">download</a><span class="ecxApple-converted-space"> </span>- view:<span class="ecxApple-converted-space"> </span><a href="http://dcvs.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c?rev=1.155;content-type=text/plain" class="ecxdisplay-link" target="_blank">text</a>,<span class="ecxApple-converted-space"> </span><a href="http://dcvs.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c?rev=1.155;content-type=text/x-cvsweb-markup" class="ecxdisplay-link" target="_blank">markup</a>,<span class="ecxApple-converted-space"> </span><a href="http://dcvs.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c?annotate=1.155" target="_blank">annotated</a><span class="ecxApple-converted-space"> </span>-<span class="ecxApple-converted-space"> </span><a href="http://dcvs.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c?r1=1.155#rev1.155" target="_blank">select for diffs</a><br><i>Wed Jan 5 18:32:00 2011 MET</i><span class="ecxApple-converted-space"> </span>(3 months, 1 week ago) by<span class="ecxApple-converted-space"> </span><i>jkrell</i><br>Branches:<span class="ecxApple-converted-space"> </span><a href="http://dcvs.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c?only_with_tag=MAIN" target="_blank">MAIN</a><br>Diff to: previous 1.154:<span class="ecxApple-converted-space"> </span><a href="http://dcvs.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c.diff?r1=1.154;r2=1.155" target="_blank">preferred</a>,<span class="ecxApple-converted-space"> </span><a href="http://dcvs.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c.diff?r1=1.154;r2=1.155;f=u" target="_blank">unified</a><br>Changes since revision 1.154: +2 -1 lines<br><pre class="ecxlog">Don't use __thread on Solaris.<br>It failed to link.<br>See:<br><a href="http://hudson.modula3.com:8080/job/cm3-current-build-SOLsun-opencsw-current9s/166/console" target="_blank">http://hudson.modula3.com:8080/job/cm3-current-build-SOLsun-opencsw-current9s/166/console</a><br></pre>Revision<span class="ecxApple-converted-space"> </span><b>1.151</b>:<span class="ecxApple-converted-space"> </span><a href="http://dcvs.elegosoft.com/cgi-bin/cvsweb.cgi/%7Echeckout%7E/cm3/m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c?rev=1.151;content-type=text/x-c%2B%2Bsrc" class="ecxdownload-link" target="_blank">download</a><span class="ecxApple-converted-space"> </span>- view:<span class="ecxApple-converted-space"> </span><a href="http://dcvs.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c?rev=1.151;content-type=text/plain" class="ecxdisplay-link" target="_blank">text</a>,<span class="ecxApple-converted-space"> </span><a href="http://dcvs.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c?rev=1.151;content-type=text/x-cvsweb-markup" class="ecxdisplay-link" target="_blank">markup</a>,<span class="ecxApple-converted-space"> </span><a href="http://dcvs.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c?annotate=1.151" target="_blank">annotated</a><span class="ecxApple-converted-space"> </span>-<span class="ecxApple-converted-space"> </span><a href="http://dcvs.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c?r1=1.151#rev1.151" target="_blank">select for diffs</a><br><i>Tue Dec 28 12:53:16 2010 MET</i><span class="ecxApple-converted-space"> </span>(3 months, 2 weeks ago) by<span class="ecxApple-converted-space"> </span><i>jkrell</i><br>Branches:<span class="ecxApple-converted-space"> </span><a href="http://dcvs.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c?only_with_tag=MAIN" target="_blank">MAIN</a><br>Diff to: previous 1.150:<span class="ecxApple-converted-space"> </span><a href="http://dcvs.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c.diff?r1=1.150;r2=1.151" target="_blank">preferred</a>,<span class="ecxApple-converted-space"> </span><a href="http://dcvs.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c.diff?r1=1.150;r2=1.151;f=u" target="_blank">unified</a><br>Changes since revision 1.150: +30 -0 lines<br><pre class="ecxlog">Use __thread on Linux and Solaris.<br>Doesn't compile on Apple.<br>Segfaults on OpenBSD and NetBSD.<br>Not tested on FreeBSD, AIX, Irix, HP-UX, etc., stick with pthread_get/setspecific.<br>In future hope to eliminate this code anyway, in favor of gcc/libgcc stack walker<br>  or C++ exceptions (C++ backend).<br></pre><br> - Jay<br><br><br>> From:<span class="ecxApple-converted-space"> </span><a href="mailto:hosking@cs.purdue.edu">hosking@cs.purdue.edu</a><br>> Date: Thu, 14 Apr 2011 17:05:27 -0400<br>> To:<span class="ecxApple-converted-space"> </span><a href="mailto:rodney_bates@lcwb.coop">rodney_bates@lcwb.coop</a><br>> CC:<span class="ecxApple-converted-space"> </span><a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>> Subject: Re: [M3devel] Thread local storage?<br>><span class="ecxApple-converted-space"> </span><br>> I think that these were introduced into the C libraries by Jay.<br>><span class="ecxApple-converted-space"> </span><br>> On Apr 14, 2011, at 11:45 AM, Rodney M. Bates wrote:<br>><span class="ecxApple-converted-space"> </span><br>> > I have never understood what "thread local storage" is all about, in particular,<br>> > what need it addresses.<br>> ><span class="ecxApple-converted-space"> </span><br>> > All local variables and parameters are already private to a thread, as consequence<br>> > of semantics going back as far as Algol-60. They are allocated space when and<br>> > only when a call is executed. That can't happen until there is a thread to<br>> > execute the call and it has to have its own private stack where the space is<br>> > allocated, or it wouldn't work as a thread, (OK leaving out languages like<br>> > very old Fortrans that don't support recursion either.)<br>> ><span class="ecxApple-converted-space"> </span><br>> > That leaves global variables. At least some of these have to be shared by all<br>> > the threads of a process, or the threads could have no shared memory interaction,<br>> > and thus no function that would not be served by just separate processes running<br>> > separate main programs.<br>> ><span class="ecxApple-converted-space"> </span><br>> > If you need variables that are private to a thread but in some sense global,<br>> > just put them in the Thread.Closure. They would hardly make sense as declared<br>> > lexically global variables anyway, since, except for the initial thread provided<br>> > by the OS/RTS, their lifetime does not cover the entire execution of the main<br>> > program.<br>> ><span class="ecxApple-converted-space"> </span><br>> > So what are they really, and what are they for? And do we even have or use them in<br>> > Modula-3?<br>> ><span class="ecxApple-converted-space"> </span><br>> > It is looking to me like some sort of accommodation for them in cm3cg may be what has<br>> > undermined m3gdb in the CVS head.<br>> ><span class="ecxApple-converted-space"> </span><br>> > Rodney Bates<br>><span class="ecxApple-converted-space"> </span><br></div></span></blockquote></div><br></div></div>                                       </body>
</html>