<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div apple-content-edited="true"><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>On 8 Jan 2009, at 14:10, Jay wrote:</div></span></span></span></span></span></span></span></span></div></span></div><div><br class="Apple-interchange-newline"><blockquote type="cite"><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; "><div class="hmmessage" style="font-size: 10pt; font-family: Verdana; ">Olaf understood the point (I think). :)<br> <br>Some programs, people say, and I believe, run "better" (faster, without running out of address space) with user threads instead of kernel threads.</div></span></blockquote><div><br></div><div>Is this still true for modern kernel thread systems?</div><br><blockquote type="cite"><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; "><div class="hmmessage" style="font-size: 10pt; font-family: Verdana; ">On systems that have both.<br>A good example might be a program that needs lots of threads and therefore small stacks, and the kernel threads, due to code below the Modula-3 runtime, might force fairly large stacks. (Such a program might have to adjust thread size differently for different threads, and only call into the underlying system on threads with larger stacks.)</div></span></blockquote><div><br></div><div>In a systems programming language like Modula-3 shouldn't threads have a relationship to the system?</div><br><blockquote type="cite"><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; "><div class="hmmessage" style="font-size: 10pt; font-family: Verdana; ">It might be nice for such programs to be able to mandate or request (two slightly different things) that the user thread library be used by them, even if the platform's default is to use kernel threads.</div></span></blockquote><div><br></div><div>This will need to be a link-time distinction.  I would hate to have both kernel and user thread code live in the same compiled run-time system.</div><br><blockquote type="cite"><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; "><div class="hmmessage" style="font-size: 10pt; font-family: Verdana; ">The only minor detail then is, how to express the request, and the precise meaning.<br>It is a request or a mandate?</div></span></blockquote><div><br></div><div>I see no problem with factoring out the threads subsystem as a separate library and linking accordingly.</div><br><blockquote type="cite"><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; "><div class="hmmessage" style="font-size: 10pt; font-family: Verdana; ">As well, if the issue is address space, sholud there a "built in" way to only make the request on 32bit platforms, or should uses manually say if equal (WORD_SIZE, "32BITS")?<br> <br>Is it a boolean or an enum?<br>Cygwin might conceivably get pthreads support (Cygwin has it, but Modula-3/Cygwin does not).<br>Therefore, is the choice among "posix" threads, "pthreads" and "NT" threads?<br>Or just user vs. kernel?</div></span></blockquote><div><br></div><div>I would argue for user vs. kernel.</div><br><blockquote type="cite"><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; "><div class="hmmessage" style="font-size: 10pt; font-family: Verdana; ">I think the "important" part here is easy to implement.<br>But again..</div></span></blockquote><div><br></div><div>And managing the state-space explosion that multiple choices might entail.  I would like to avoid that.</div><br><blockquote type="cite"><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; "><div class="hmmessage" style="font-size: 10pt; font-family: Verdana; ">The easier straightforward implementation always links both pieces of code in and makes a choice early in startup as to which to use, either setting a boolean, or an enum, or a pointer to a record of function pointers. This means that people that don't care to ever use user threads pay a small price, in code bloat and probably in a few extra instructions per certain functions. This is probably ok.</div></span></blockquote><div><br></div><div>I am not so sure, since it would entail some fairly low-level and expensive decisions that would best instead be done at link-time.</div><div><br></div><blockquote type="cite"><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; "><div class="hmmessage" style="font-size: 10pt; font-family: Verdana; ">However if that was not ok, the choice could be made at link time and only be supported for standalone programs.</div></span></blockquote><div><br></div><div>Actually, for non-standalone (dynamically-linked) code we could make the choice at dynamic load time using the OS's support for dynamic library choice.</div><div><br></div><div>I note that Solaris (but not Solaris Modula-3) currently lets dynamically linked C programs choose among 3 different threads implementations dynamically.</div><br><blockquote type="cite"><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; "><div class="hmmessage" style="font-size: 10pt; font-family: Verdana; "><br> <br> - Jay<br><br><br><br><hr id="stopSpelling"><br>CC:<span class="Apple-converted-space"> </span><a href="mailto:wagner@elegosoft.com">wagner@elegosoft.com</a>;<span class="Apple-converted-space"> </span><a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>From:<span class="Apple-converted-space"> </span><a href="mailto:hosking@cs.purdue.edu">hosking@cs.purdue.edu</a><br>To:<span class="Apple-converted-space"> </span><a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a><br>Subject: Re: [M3devel] dynamic chose between user/kernel threads?<br>Date: Thu, 8 Jan 2009 13:51:15 +1100<br><br><br><div>Jay, perhaps you can provide some context and motivation for your proposals.  I am unable to evaluate your proposals in the form of a simple laundry-list.</div><br><div><div>On 8 Jan 2009, at 01:34, Jay wrote:</div><br class="EC_Apple-interchange-newline"><blockquote><span class="EC_Apple-style-span" style="word-spacing: 0px; font: normal normal normal 12px/normal Helvetica; text-transform: none; color: rgb(0, 0, 0); text-indent: 0px; white-space: normal; letter-spacing: normal; border-collapse: separate; "><div class="EC_hmmessage" style="font-size: 10pt; font-family: Verdana; ">I looked into this a bit..and I think it's actually pretty easy.<br>It hardly churns the code even.<br> <br><br>I have other things I want to do first.<br> <br><br>In the meantime, specify the directive?<br>There are actually a large number of subtle options.<br> <br> <br>Can I ask for any of n libraries -- NT, pthreads, user threads?<br> setjmp vs. context? Or is it just a boolean, user vs. kernel?<br> <br> <br>Is the option to "favor" or "require" a certain library?<br> <br> <br>Can I set it on libraries or only programs?<br> What if the requests clash?<br> <br> <br>Is it "Favor" or "Require"?<br>Is it a function call or setting a global variable?<br>I favor function call, but TARGET, WORD_SIZE, BUILD_DIR establish the other precedent,<br>and either can work.<br> <br>Is it flags in the moduleinfo like incgc, gengc, or separate data that<br>there is just one of in RTLinker? Probably separate data, unless it is allowed in libraries.<br> <br> <br>What are the names of the libraries?<br> "posix" and "pthreads"  ?<br>  "user" and "kernel" ?<br>  "true" and "false" (or vice versa) ?<br> <br> <br>Should NT implement user threads, using fibers?<br> <br> <br>Presumably it works with both standalone and shared/dynamic programs.<br>Presumably it is ok to always bloat up m3core.dll with both libraries.<br>Presumably it is ok to have everyone pay a teeny tiny perf.<br>  That is, there is a microscopic dispatching layer, that everyone<br>  ends up going through, not chosing to link in one library or the other.<br> <br> <br>And as part of this, whenever it happens, can we bump up the minimum<br>bootstrap to a version that includes SchedulerPosix.DoesWaitPidYield()?<br>Or does it become VAR Scheduler.UsingKerneThreads?<br>(no, it should be a function; but naming matter remains).<br> <br> <br>(ie. as I said, the decision currently is baked into m3core.dll, but<br>now it is also baked into sysutils.dll, but these should change together;<br>m3core.dll should manage the knowledge).<br> <br><br> - Jay<br><br><br>> Date: Sat, 3 Jan 2009 01:12:27 +0100<br>> From:<span class="EC_Apple-converted-space"> </span><a href="mailto:wagner@elegosoft.com">wagner@elegosoft.com</a><br>> To:<span class="EC_Apple-converted-space"> </span><a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>> Subject: Re: [M3devel] dynamic chose between user/kernel threads?<br>><span class="EC_Apple-converted-space"> </span><br>> An option to cm3 or a quake directive to use in the m3makefiles<br>> would suffice in my opinion (and be a great improvement).<br>><span class="EC_Apple-converted-space"> </span><br>> Olaf<br>><span class="EC_Apple-converted-space"> </span><br>> Quoting Jay <<a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a>>:<br>><span class="EC_Apple-converted-space"> </span><br>> ><br>> > Should the user/kernel thread chose be available:<br>> ><br>> ><br>> > On the command line to a Modula-3 executable (or even an executable<span class="EC_Apple-converted-space"> </span><br>> > where main is in another language, but which static or dynamic<span class="EC_Apple-converted-space"> </span><br>> > Modula-3 libs are used)?<br>> ><br>> ><br>> > Via a quake directive when building programs?<br>> ><br>> ><br>> > You know, imagine you have a bunch of Modula-3 programs and some but<span class="EC_Apple-converted-space"> </span><br>> > not all use a very large number of threads and benefit from<span class="EC_Apple-converted-space"> </span><br>> > userthreads.<br>> ><br>> ><br>> > Currently the chose is locked into m3core when it is built.<br>> ><br>> ><br>> > - Jay<br>><span class="EC_Apple-converted-space"> </span><br>><span class="EC_Apple-converted-space"> </span><br>> --<span class="EC_Apple-converted-space"> </span><br>> Olaf<br></div></span></blockquote></div><br></div></span><br class="Apple-interchange-newline"></blockquote></div><br></body></html>