<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
</style>
</head>
<body class='hmmessage'>
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.<BR>
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.)<BR>
<BR>
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.<BR>
<BR>
The only minor detail then is, how to express the request, and the precise meaning.<BR>
It is a request or a mandate?<BR>
<BR>
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?<BR>
<BR>
I think the "important" part here is easy to implement.<BR>
But again..<BR>
<BR>
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.<BR>
However if that was not ok, the choice could be made at link time and only be supported for standalone programs.<BR>
<BR>
- Jay<BR><BR><BR><BR>
<HR id=stopSpelling>
<BR>
CC: wagner@elegosoft.com; m3devel@elegosoft.com<BR>From: hosking@cs.purdue.edu<BR>To: jay.krell@cornell.edu<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: 12px 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></body>
</html>