[M3devel] FW: variations of waitpid..?

Randy Coleburn rcoleburn at scires.com
Fri Jan 2 22:18:40 CET 2009


Jay:
 
Your comment about stack size rang a bell with me.
 
I have had trouble in the past running out of stack space, most notably on HP-UX.  Same program built on Windows usually did not suffer the same fate.  I seem to recall the most stack space trouble was when a thread did anything with Trestle/FormsVBT etc.
 
So, I added a command line switch to my program that let's you specify a multiplier for the stack size.  During initialization, my programs read the command line switches and take appropriate action to increase the thread stack sizes before any threads are created.
 
If you don't specify a stack size multiplier on the command line, I think I wound up using seven (7) as the default.
 
Here is a code excerpt:
      IF stackMult > 1
      THEN
         WITH default = Thread.GetDefaultStackSize(),
              desired = default * stackMult,
              increase = desired - default
         DO
            PutText("Increasing default stack size by a factor of " &
               Fmt.Int(stackMult) & " (" & Fmt.Int(default) & " >>> " &
               Fmt.Int(desired) & ").\n");
            Thread.IncDefaultStackSize(increase);
         END; (* with *)
         WITH default = Thread.GetDefaultStackSize()
         DO
            PutText("Thread stacks are now " & Fmt.Int(default) & " bytes.\n");
         END; (* with *)
      END; (* if *)
Regards,
Randy

>>> Jay <jay.krell at cornell.edu> 12/31/2008 8:59 PM >>>
[truncated just slightly..and probably will be again given more rambling..]
 
ps: the internal use in m3core could be easily removed, just by compiling one branch of the if or the other.
I just wanted them in the same file to keep similar code closer together.
 
So it comes down that m3core does expose Uwaitpid.waitpid and Uexec.waitpid, and as long as they are...or as long as user threads exist..imho there is some obligation of m3core to expose perhaps surprising characteristics of its thread library. You might say the entire interface is already and has always been fully exposed in Thread.i3, but I don't believe it. User threads and kernel threads have too divergent too visible artifacts, that I don't think are previously exposed in the public interface.
 
I claim it is somewhat "surprising", or at least important to know the detail of, whether or not waitpid yields to other threads.
 
You know, I mean..let's say I am some really clever waitpid user and I really must use it. And I am using Modula-3 threads. And my child process is reading the output of Modula-3 threads. Aren't I kind of stuck? Isn't there /some/ obligation of m3core to help just a teeny tiny bit? Or, would you argue, I am obligated, if I am using Modula-3, to use the higher level interfaces, that already know about this? Well, ok, m3core did already know about, I fixed it only a few months ago, but then even the likes of sysutils is stuck?
 
Another example, that may or may not be well exposed, is willingness/ability to set thread stack size. Mika mentions creation thousands of threads. 32bit kernel threads are going to be more limited here. Whereas 32bit user threads might be willing to create much smaller stacks, and 64 bit anything has essentially infinite address space for infinite stacks (but still beware working set, physical memory is not infinite).
 
(Personally I have seen precious little code that cares about stack size, just seems to somehow get along, combined with the fact that the current Modula-3 pthread code very likely leaks on some platforms attempting to deal with stack size, makes me inclined to just rip out the code..but yeah..just fix the leak...)
 
 - Jay


From: jay.krell at cornell.edu 
To: hosking at cs.purdue.edu 
CC: mika at async.caltech.edu; m3devel at elegosoft.com 
Subject: RE: [M3devel] variations of waitpid..?
Date: Thu, 1 Jan 2009 01:49:28 +0000

 > If someone uses waitpid they get what they paid for. 
 
But someone is us -- m3core/libm3 (I think just m3core), sysutils, and then cm3 uses them.
 
I guess there is a point that this "grand new interface" SchedulerPosix.DoesWaitPidYield has precious few users.
 (It isn't grand. It takes no parameters and just returns a boolean, hardcoded, depending on thread library.)
 
m3core now (today) uses it internally -- no need for a public interface.
Sysutils can't use it until the baseline m3core is newer, so arguably, not a user.
  Instead (today) sysutils uses m3core's m3makefiles to decide the value.
 
Heck, waitpid is therefore only used internally by m3core, and sysutils.
If sysutils could be (partly) merged into m3core, then m3core's waitpid need not be public.
 
 - Jay

> CC: mika
> From: hosking
> To: jay
> Subject: Re: [M3devel] variations of waitpid..?
> Date: Thu, 1 Jan 2009 12:29:24 +1100
> 
> If someone uses waitpid they get what they paid for.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20090102/0ed8f8e4/attachment-0002.html>


More information about the M3devel mailing list