<html><head><base href="x-msg://3191/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">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="Apple-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; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; 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; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; 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; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; 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; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; 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; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; 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; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; 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; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; 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; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; 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; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; 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; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div><font class="Apple-style-span" color="#0000FF"><font class="Apple-style-span" face="Gill Sans"><span class="Apple-style-span" style="color: rgb(0, 0, 255); font-family: 'Gill Sans'; "><span class="Apple-style-span" style="color: rgb(0, 0, 255); font-family: 'Gill Sans'; ">Antony Hosking</span></span></font></font><font class="Apple-style-span" face="Gill Sans"><span class="Apple-style-span" style="font-family: 'Gill Sans'; "><span class="Apple-style-span" style="font-family: 'Gill Sans'; "><span class="Apple-converted-space"> </span>|<span class="Apple-converted-space"> </span></span></span><span class="Apple-style-span" style="font-family: 'Gill Sans'; "><span class="Apple-style-span" style="font-family: 'Gill Sans'; ">Associate Professor</span></span><span class="Apple-style-span" style="font-family: 'Gill Sans'; "><span class="Apple-style-span" style="font-family: 'Gill Sans'; "> | Computer Science | Purdue University</span></span></font></div><div><font class="Apple-style-span" face="GillSans-Light"><span class="Apple-style-span" style="font-family: GillSans-Light; ">305 N. University Street | West Lafayette | IN 47907 | USA</span></font></div><div><font class="Apple-style-span" color="#0000FF" face="Gill Sans"><span class="Apple-style-span" style="color: rgb(0, 0, 255); font-family: 'Gill Sans'; "><span class="Apple-style-span" style="color: rgb(0, 0, 255); font-family: 'Gill Sans'; ">Office</span></span></font><font class="Apple-style-span" face="GillSans-Light"><span class="Apple-style-span" style="font-family: GillSans-Light; "><span class="Apple-style-span" style="font-family: GillSans-Light; "> +1 765 494 6001 |<span class="Apple-converted-space"> </span></span></span></font><font class="Apple-style-span" color="#0000FF" face="Gill Sans"><span class="Apple-style-span" style="color: rgb(0, 0, 255); font-family: 'Gill Sans'; "><span class="Apple-style-span" style="color: rgb(0, 0, 255); font-family: 'Gill Sans'; ">Mobile</span></span></font><font class="Apple-style-span" face="GillSans-Light"><span class="Apple-style-span" style="font-family: GillSans-Light; "><span class="Apple-style-span" style="font-family: GillSans-Light; "><span class="Apple-converted-space"> </span>+1 765 427 5484</span></span></font></div><div><font class="Apple-style-span" face="GillSans-Light"><br class="khtml-block-placeholder"></font></div></span></span></span></span></span></span></span><br class="Apple-interchange-newline"></span></div></span></span><br class="Apple-interchange-newline">
</div>
<br><div><div>On Apr 14, 2011, at 5:32 PM, Jay K wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div class="hmmessage" 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="stopSpelling">From:<span class="Apple-converted-space"> </span><a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a><br>To:<span class="Apple-converted-space"> </span><a href="mailto:hosking@cs.purdue.edu">hosking@cs.purdue.edu</a>;<span class="Apple-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="Apple-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">http://dcvs.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/m3core/src/thread/PTHREAD/ThreadPThreadC.c</a><br>Revision<span class="Apple-converted-space"> </span><b>1.155</b>:<span class="Apple-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="Apple-converted-space"> </span>- view:<span class="Apple-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="Apple-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="Apple-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="Apple-converted-space"> </span>-<span class="Apple-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="Apple-converted-space"> </span>(3 months, 1 week ago) by<span class="Apple-converted-space"> </span><i>jkrell</i><br>Branches:<span class="Apple-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="Apple-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="Apple-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="Apple-converted-space"> </span><b>1.151</b>:<span class="Apple-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="Apple-converted-space"> </span>- view:<span class="Apple-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="Apple-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="Apple-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="Apple-converted-space"> </span>-<span class="Apple-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="Apple-converted-space"> </span>(3 months, 2 weeks ago) by<span class="Apple-converted-space"> </span><i>jkrell</i><br>Branches:<span class="Apple-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="Apple-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="Apple-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="Apple-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="Apple-converted-space"> </span><a href="mailto:rodney_bates@lcwb.coop">rodney_bates@lcwb.coop</a><br>> CC:<span class="Apple-converted-space"> </span><a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>> Subject: Re: [M3devel] Thread local storage?<br>><span class="Apple-converted-space"> </span><br>> I think that these were introduced into the C libraries by Jay.<br>><span class="Apple-converted-space"> </span><br>> On Apr 14, 2011, at 11:45 AM, Rodney M. Bates wrote:<br>><span class="Apple-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="Apple-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="Apple-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="Apple-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="Apple-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="Apple-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="Apple-converted-space"> </span><br>> > Rodney Bates<br>><span class="Apple-converted-space"> </span><br></div></span></blockquote></div><br></div></div></body></html>