<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>I don't mind if low-level C calls abort rather than raising an exception.  Especially, OutOfMemory, which it is unlikely one can recover from with an untraced allocation, unless perhaps a GC can be called to free up space.  However, right now, the GC does not return pages to the OS, so the whole question is moot for now.</div><br><div> <span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 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; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 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; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-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; border-spacing: 0px 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; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-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; border-spacing: 0px 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; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-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; border-spacing: 0px 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; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-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; border-spacing: 0px 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; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-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; border-spacing: 0px 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; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-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; border-spacing: 0px 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; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-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; border-spacing: 0px 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; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-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></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></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; "> +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> </div><br><div><div>On 5 Feb 2009, at 09:01, Jay wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><br><a href="http://www.opengroup.org/onlinepubs/007908799/xsh/pthread_attr_init.html">http://www.opengroup.org/onlinepubs/007908799/xsh/pthread_attr_init.html</a><br><br><br>can fail for lack of memory.<br><br><br>The use should probably be modified somewhat therefore.<br><br><br>e.g. at least:<br><br><br>C code:<br><br><br>r = pthread_attr_init(...)<br>if (r == ENOMEM)<br>  return r;<br>assert(r == 0);<br><br><br>Modula-3 code:<br>r = ...<br>IF r = Cerrno.ENOMEM <br>  raise out of memory<br><br><br>or more generally probably:<br><br><br>C:<br><br><br>r = pthread_attr_init(...)<br>if (r != 0)<br>  return r;<br><br><br>Modula-3:<br>r = ...<br>IF r # 0<br>  raise it as is done for errno, whatever<br><br><br>or even C:<br><br><br>void thread_create(...)<br>{<br>r = pthread_attr_init(...)<br>if (r != 0)<br>  raise it as errno, whatever <br><br><br>just that I'm a little leary of "certain Modula-3 constructs in C".<br><br><br>I'll maybe review more code along these lines.<br>I gather the general gist of things in Modula-3 though<br>is that out of memory is fatal anyway. Raising an exception<br>vs. failing an assertion probably not significantly different<br>if the exception is not meant to be caught and isn't ever caught.<br>(Strange though then the gymnastics I pointed out elsewhere<br>converting one form of out of memory to another form..)<br><br><br>The docs also point out that pthread_attr can be reused.<br>It might be reasonable to try to do that somewhat, though<br>of course there are the usual caveats:<br><br><br>  - how many reusable objects to keep around<br>    I suggest 1, for the common case of either using the default<br>    or repeatedly using the same non-default.<br>  - how to lookup, insert, delete in the cache, in an efficient<br>    and thread-safe manner<br>    cache size = 1 helps, but doesn't address all questions.<br><br><br> I'll leave it alone, unless someone "vehemently agrees". <br><br><br>Expect the original change fairly soon..<br><br><br> - Jay<br><br><br><br><br><br><br><br><br><br><br>----------------------------------------<br><blockquote type="cite">From: <a href="mailto:hosking@cs.purdue.edu">hosking@cs.purdue.edu</a><br></blockquote><blockquote type="cite">To: <a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a><br></blockquote><blockquote type="cite">Date: Wed, 4 Feb 2009 21:24:19 +1100<br></blockquote><blockquote type="cite">CC: <a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br></blockquote><blockquote type="cite">Subject: Re: [M3devel] elminating pthread_attr_t from cloned headers<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">ok<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">On 4 Feb 2009, at 21:14, Jay wrote:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">The following eliminates the only use of pthread_attr_t from the<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">cloned headers, slightly reducing the work to port to new platforms.<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">It introduces a "small" "portable" C wrapper to encompass the files<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">lines of Modula-3 that use pthread_attr_t. ok?<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Index: ThreadPThread.m3<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">===================================================================<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">RCS file: /usr/cvs/cm3/m3-libs/m3core/src/thread/PTHREAD/<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">ThreadPThread.m3,v<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">retrieving revision 1.89<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">diff -u -r1.89 ThreadPThread.m3<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">--- ThreadPThread.m3 21 Jan 2009 15:25:03 -0000 1.89<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+++ ThreadPThread.m3 4 Feb 2009 10:07:59 -0000<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">@@ -11,11 +11,10 @@<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Unix, Utime, Word, Upthread, Usched,<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Uerror, ThreadPThreadC, Uexec;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">FROM Upthread<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">-IMPORT pthread_t, pthread_cond_t, pthread_key_t, pthread_attr_t,<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_mutex_t,<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+IMPORT pthread_t, pthread_cond_t, pthread_key_t, pthread_mutex_t,<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">FROM Compiler IMPORT ThisFile, ThisLine;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">FROM Ctypes IMPORT int;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">-FROM Utypes IMPORT size_t;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">FROM ThreadPThreadC IMPORT SIG_SUSPEND;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">(*----------------------------------------------------- types and<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">globals ---*)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">@@ -561,9 +560,7 @@<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">VAR<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">act := NEW(Activation);<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">t := CreateT(act);<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">- attr: pthread_attr_t;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">size := defaultStackSize;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">- bytes: size_t;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">BEGIN<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">(* determine the initial size of the stack for this thread *)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">TYPECASE closure OF<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">@@ -576,17 +573,12 @@<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">t.id := nextId; INC(nextId);<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">IF perfOn THEN PerfChanged(t.id, State.alive) END;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">- WITH r = Upthread.attr_init(attr) DO END;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">- WITH r = Upthread.attr_getstacksize(attr, bytes) DO END;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">- bytes := MAX(bytes, size * ADRSIZE(Word.T));<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">- EVAL Upthread.attr_setstacksize(attr, bytes);<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">act.next := allThreads;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">act.prev := allThreads.prev;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">act.size := size;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">allThreads.prev.next := act;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">allThreads.prev := act;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">- WITH r = Upthread.create(act.handle, attr, ThreadBase, act) DO<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">- EVAL Upthread.attr_destroy(attr);<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+ WITH r = ThreadPThreadC.thread_create(act.handle, size *<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">ADRSIZE(Word.T), ThreadBase, act) DO<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">IF r # 0 THEN<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">RTError.MsgI(ThisFile(), ThisLine(),<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">"Thread client error: Fork failed with error:<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">", r);<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Index: ThreadPThreadC.c<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">===================================================================<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">RCS file: /usr/cvs/cm3/m3-libs/m3core/src/thread/PTHREAD/<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">ThreadPThreadC.c,v<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">retrieving revision 1.8<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">diff -u -r1.8 ThreadPThreadC.c<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">--- ThreadPThreadC.c 21 Jan 2009 15:25:03 -0000 1.8<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+++ ThreadPThreadC.c 4 Feb 2009 10:07:59 -0000<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">@@ -14,6 +14,7 @@<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">#include<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">#include<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">#endif<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+#include<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">#ifdef __cplusplus<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">extern "C" {<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">@@ -145,6 +146,32 @@<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">#endif<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">}<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+#define VAR(t) t*<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+#define MAX(x, y) (((x)> (y)) ? (x) : (y))<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+typedef void* (*start_routine_t)(void*);<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+int ThreadPThreadC_thread_create(VAR(pthread_t) pthread, size_t<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">stackSize, start_routine_t start_routine, void* arg)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+{<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+ int r;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+ size_t bytes;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+ pthread_attr_t attr;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+ r = pthread_attr_init(&attr);<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+ assert(r == 0);<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+ r = pthread_attr_getstacksize(&attr, &bytes);<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+ assert(r == 0);<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+ bytes = MAX(bytes, stackSize);<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+ pthread_attr_setstacksize(&attr, bytes);<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+ r = pthread_create(pthread, &attr, start_routine, arg);<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+ pthread_attr_destroy(&attr);<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+ return r;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+}<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">#ifdef __cplusplus<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">} /* extern "C" */<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">#endif<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Index: ThreadPThreadC.i3<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">===================================================================<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">RCS file: /usr/cvs/cm3/m3-libs/m3core/src/thread/PTHREAD/<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">ThreadPThreadC.i3,v<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">retrieving revision 1.5<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">diff -u -r1.5 ThreadPThreadC.i3<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">--- ThreadPThreadC.i3 21 Jan 2009 15:25:03 -0000 1.5<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+++ ThreadPThreadC.i3 4 Feb 2009 10:07:59 -0000<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">@@ -7,6 +7,8 @@<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">UNSAFE INTERFACE ThreadPThreadC;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">FROM Ctypes IMPORT int;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+FROM Cstddef IMPORT size_t;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+FROM Upthread IMPORT pthread_t, start_routine_t;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">(*---------------------------------------------------------------------------*)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">@@ -38,4 +40,11 @@<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">(*---------------------------------------------------------------------------*)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+(* pthread_create but replace attr with stackSize so that attr need<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">not be known to Modula-3 *)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+PROCEDURE thread_create(VAR pthread: pthread_t; stackSize: size_t;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">start_routine: start_routine_t; arg: ADDRESS): int;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">(*---------------------------------------------------------------------------*)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">END ThreadPThreadC.<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">The corrolary then, ignoring the "cloned headers" that I leave<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">alone, is:<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Index: Common/Upthread.i3<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">===================================================================<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">RCS file: /usr/cvs/cm3/m3-libs/m3core/src/unix/Common/Upthread.i3,v<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">retrieving revision 1.3<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">diff -u -r1.3 Upthread.i3<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">--- Common/Upthread.i3 19 Jan 2009 15:57:20 -0000 1.3<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+++ Common/Upthread.i3 4 Feb 2009 10:12:18 -0000<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">@@ -10,7 +10,6 @@<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">TYPE<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_t = Usysdep.pthread_t;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">- pthread_attr_t = Usysdep.pthread_attr_t;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_mutex_t = Usysdep.pthread_mutex_t;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_cond_t = Usysdep.pthread_cond_t;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_key_t = Usysdep.pthread_key_t;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">@@ -21,14 +20,9 @@<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">VAR PTHREAD_MUTEX_INITIALIZER : pthread_mutex_t;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">VAR PTHREAD_COND_INITIALIZER : pthread_cond_t;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">- PROCEDURE create (VAR pthread: pthread_t; READONLY attr:<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_attr_t; start_routine: start_routine_t; arg: ADDRESS): int;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">PROCEDURE detach (thread: pthread_t): int;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">PROCEDURE self (): pthread_t;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">PROCEDURE equal (t1, t2: pthread_t): int;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">- PROCEDURE attr_init (VAR attr: pthread_attr_t): int;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">- PROCEDURE attr_destroy (VAR attr: pthread_attr_t): int;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">- PROCEDURE attr_getstacksize (READONLY attr: pthread_attr_t; VAR<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">stacksize: size_t): int;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">- PROCEDURE attr_setstacksize (VAR attr: pthread_attr_t; stacksize:<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">size_t): int;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">PROCEDURE yield (): int;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">PROCEDURE mutex_init (VAR mutex: pthread_mutex_t; attr: ADDRESS :=<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">NIL): int;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">PROCEDURE mutex_destroy (VAR mutex: pthread_mutex_t): int;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Index: cygwin/Usysdep.i3<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">===================================================================<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">RCS file: /usr/cvs/cm3/m3-libs/m3core/src/unix/cygwin/Usysdep.i3,v<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">retrieving revision 1.12<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">diff -u -r1.12 Usysdep.i3<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">--- cygwin/Usysdep.i3 21 Jan 2009 15:25:09 -0000 1.12<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+++ cygwin/Usysdep.i3 4 Feb 2009 10:12:18 -0000<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">@@ -28,7 +28,6 @@<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">(* INTERFACE Upthread; *)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_t = ADDRESS; (* opaque *)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">- pthread_attr_t = ADDRESS; (* opaque *)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_mutex_t = ADDRESS; (* opaque *)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_cond_t = ADDRESS; (* opaque *)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_key_t = ADDRESS; (* opaque *)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Index: darwin-common/Usysdep.i3<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">===================================================================<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">RCS file: /usr/cvs/cm3/m3-libs/m3core/src/unix/darwin-common/<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Usysdep.i3,v<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">retrieving revision 1.2<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">diff -u -r1.2 Usysdep.i3<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">--- darwin-common/Usysdep.i3 29 Jan 2009 07:43:23 -0000 1.2<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+++ darwin-common/Usysdep.i3 4 Feb 2009 10:12:18 -0000<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">@@ -20,7 +20,6 @@<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">(* INTERFACE Upthread; *)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_t = INTEGER; (* opaque *)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">- pthread_attr_t = RECORD opaque: ARRAY [1..10] OF INTEGER; END;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_mutex_t = RECORD opaque: ARRAY [1..11] OF INTEGER; END;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_cond_t = RECORD opaque: ARRAY [1..7] OF INTEGER; END;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_key_t = INTEGER; (* opaque *)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Index: freebsd-common/Usysdep.i3<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">===================================================================<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">RCS file: /usr/cvs/cm3/m3-libs/m3core/src/unix/freebsd-common/<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Usysdep.i3,v<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">retrieving revision 1.5<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">diff -u -r1.5 Usysdep.i3<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">--- freebsd-common/Usysdep.i3 21 Jan 2009 15:25:09 -0000 1.5<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+++ freebsd-common/Usysdep.i3 4 Feb 2009 10:12:18 -0000<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">@@ -22,7 +22,6 @@<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">(* INTERFACE Upthread; *)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_t = ADDRESS;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">- pthread_attr_t = ADDRESS;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_mutex_t = ADDRESS;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_cond_t = ADDRESS;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_key_t = int;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Index: hpux-common/Usysdep.i3<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">===================================================================<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">RCS file: /usr/cvs/cm3/m3-libs/m3core/src/unix/hpux-common/<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Usysdep.i3,v<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">retrieving revision 1.4<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">diff -u -r1.4 Usysdep.i3<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">--- hpux-common/Usysdep.i3 21 Jan 2009 15:25:11 -0000 1.4<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+++ hpux-common/Usysdep.i3 4 Feb 2009 10:12:18 -0000<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">@@ -25,7 +25,6 @@<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">(* INTERFACE Upthread; *)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_t = int32_t; (* opaque *)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">- pthread_attr_t = int32_t; (* opaque *)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_mutex_t = RECORD opaque: ARRAY [1..11 * X64 + 22 * X32]<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">OF INTEGER; END; (* 88 opaque bytes with size_t alignment *)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_cond_t = RECORD opaque: ARRAY [1..7 * X64 + 14 * X32] OF<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">INTEGER; END; (* 56 opaque bytes with size_t alignment *)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_key_t = int32_t; (* opaque *)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Index: linux-common/Usysdep.i3<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">===================================================================<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">RCS file: /usr/cvs/cm3/m3-libs/m3core/src/unix/linux-common/<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Usysdep.i3,v<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">retrieving revision 1.10<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">diff -u -r1.10 Usysdep.i3<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">--- linux-common/Usysdep.i3 21 Jan 2009 15:25:12 -0000 1.10<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+++ linux-common/Usysdep.i3 4 Feb 2009 10:12:18 -0000<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">@@ -21,7 +21,6 @@<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">(* INTERFACE Upthread; *)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_t = ADDRESS;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">- pthread_attr_t = Upthreadtypes.pthread_attr_t;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_mutex_t = Upthreadtypes.pthread_mutex_t;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_cond_t = RECORD data: ARRAY[1..6] OF LONGINT; END;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_key_t = uint32_t;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Index: solaris-common/Usysdep.i3<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">===================================================================<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">RCS file: /usr/cvs/cm3/m3-libs/m3core/src/unix/solaris-common/<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Usysdep.i3,v<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">retrieving revision 1.3<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">diff -u -r1.3 Usysdep.i3<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">--- solaris-common/Usysdep.i3 21 Jan 2009 15:25:13 -0000 1.3<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">+++ solaris-common/Usysdep.i3 4 Feb 2009 10:12:18 -0000<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">@@ -24,7 +24,6 @@<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">(* INTERFACE Upthread; *)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_t = int32_t; (* opaque *)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">- pthread_attr_t = int32_t; (* opaque *)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_mutex_t = RECORD opaque: ARRAY [1..4] OF LONGINT; END;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">(* 32 bytes with 64 bit alignment *)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_cond_t = RECORD opaque: ARRAY [1..2] OF LONGINT; END; (*<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">16 bytes with 64 bit alignment *)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">pthread_key_t = int32_t; (* opaque *)<br></blockquote></blockquote><blockquote type="cite"><br></blockquote></div></blockquote></div><br></body></html>