<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>Ah, I removed it in 2010. Head is much better than 5.8.6 here.</p>
<p><br>
</p>
<p><a class="OWAAutoLink" id="LPlnk496021" href="https://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/libm3/src/os/POSIX/ProcessPosixCommon.m3" previewremoved="true">https://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/libm3/src/os/POSIX/ProcessPosixCommon.m3</a><br>
</p>
<p><br>
</p>
<div id="Signature">
<div>Revision <b>1.13</b>: <a class="download-link" href="https://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/~checkout~/cm3/m3-libs/libm3/src/os/POSIX/ProcessPosixCommon.m3?rev=1.13;content-type=text%2Fplain">
download</a> - view: <a class="display-link" href="https://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/libm3/src/os/POSIX/ProcessPosixCommon.m3?rev=1.13;content-type=text%2Fplain">
text</a>, <a class="display-link" href="https://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/libm3/src/os/POSIX/ProcessPosixCommon.m3?rev=1.13;content-type=text%2Fx-cvsweb-markup">
markup</a>, <a href="https://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/libm3/src/os/POSIX/ProcessPosixCommon.m3?annotate=1.13">
annotated</a> - <a href="https://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/libm3/src/os/POSIX/ProcessPosixCommon.m3?r1=1.13#rev1.13">
select for diffs</a><br>
<i>Sun Apr 11 13:01:43 2010 </i>(7 years, 4 months ago) by <i>jkrell</i><br>
Branches: <a href="https://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/libm3/src/os/POSIX/ProcessPosixCommon.m3?only_with_tag=MAIN">
MAIN</a><br>
Diff to: previous 1.12: <a href="https://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/libm3/src/os/POSIX/ProcessPosixCommon.m3.diff?r1=1.12;r2=1.13">
preferred</a>, <a href="https://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/libm3/src/os/POSIX/ProcessPosixCommon.m3.diff?r1=1.12;r2=1.13;f=u">
unified</a><br>
Changes since revision 1.12: +1 -15 lines<br>
<pre class="log">There is no need to disable the interval timer around fork.
It doesn't get inherited by the child.
</pre>
</div>
<br>
</div>
<div>Revision <b>1.14</b>: <a class="download-link" href="https://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/~checkout~/cm3/m3-libs/libm3/src/os/POSIX/ProcessPosixCommon.m3?rev=1.14;content-type=text%2Fplain">
download</a> - view: <a class="display-link" href="https://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/libm3/src/os/POSIX/ProcessPosixCommon.m3?rev=1.14;content-type=text%2Fplain">
text</a>, <a class="display-link" href="https://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/libm3/src/os/POSIX/ProcessPosixCommon.m3?rev=1.14;content-type=text%2Fx-cvsweb-markup">
markup</a>, <a href="https://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/libm3/src/os/POSIX/ProcessPosixCommon.m3?annotate=1.14">
annotated</a> - <a href="https://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/libm3/src/os/POSIX/ProcessPosixCommon.m3?r1=1.14#rev1.14">
select for diffs</a><br>
<i>Sun Apr 11 13:04:38 2010 </i>(7 years, 4 months ago) by <i>jkrell</i><br>
Branches: <a href="https://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/libm3/src/os/POSIX/ProcessPosixCommon.m3?only_with_tag=MAIN">
MAIN</a><br>
Diff to: previous 1.13: <a href="https://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/libm3/src/os/POSIX/ProcessPosixCommon.m3.diff?r1=1.13;r2=1.14">
preferred</a>, <a href="https://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/libm3/src/os/POSIX/ProcessPosixCommon.m3.diff?r1=1.13;r2=1.14;f=u">
unified</a><br>
Changes since revision 1.13: +1 -7 lines<br>
<pre class="log">There's also no need to disable/enable scheduling, ThreadPosix.m3 registers fork handlers to do that.</pre>
</div>
<div><br>
</div>
<div><span>Do you have code that LTO will really help?</span></div>
<div><span>i.e. cross module inlining?</span></div>
<div><span><br>
</span></div>
<div><span>The gcc backend imho was just too large, so I cut out stuff that didn't seem worthwhile -- gmp, mpfr, mpc, lto...</span></div>
<div><span><br>
</span></div>
<div><span>I asked a while ago, I'll ask again -- port latest gcc?</span></div>
<div><span>Or what is the state of llvm? Would it be horrible if I started from scratch there?</span></div>
<div><span>I think I'd output the textual IR files.</span></div>
<div><span><br>
</span></div>
<div><span>I'm also somewhat keen on writing a Modula-3 IR JIT or interpreter, however I fear one or two of the files (in C++ and Cpreprocessor) I'd like to start from GPL2 and stuck there.</span></div>
<div><span>One wonders how good or bad our IR is for a JIT input -- it is backend input, sort of (gcc backend transforms it into gcc IR)</span></div>
<div><span><br>
</span></div>
<div><span> - Jay</span></div>
<div><br>
<br>
</div>
<div style="color: rgb(0, 0, 0);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font color="#000000" face="Calibri, sans-serif" style="font-size:11pt"><b>From:</b> M3devel <m3devel-bounces@elegosoft.com> on behalf of Jay K <jayk123@hotmail.com><br>
<b>Sent:</b> Tuesday, August 15, 2017 1:28 AM<br>
<b>To:</b> Peter McKinna<br>
<b>Cc:</b> m3devel<br>
<b>Subject:</b> Re: [M3devel] modula3 fork and virtual timer</font>
<div> </div>
</div>
<div>
<div id="compose-container" style="direction:ltr" itemtype="https://schema.org/EmailMessage" itemscope="">
<span itemtype="https://schema.org/Organization" itemscope="" itemprop="creator"><span itemprop="name"></span></span>
<div>
<div>
<div style="direction:ltr">Huh I'll check head later.</div>
<div style="direction:ltr">No I probably removed LTO sorry, but C backend...</div>
<div style="direction:ltr">Or maybe llvm?</div>
<div style="direction:ltr">Or report latest gcc?</div>
<div style="direction:ltr">LTO doesn't scale in compile time but Llvm has ThinLTO now..</div>
<div style="direction:ltr">LTO requires linker support. A matching linker? I'm not sure.</div>
</div>
<div><br>
</div>
<div class="acompli_signature">- Jay</div>
</div>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font color="#000000" face="Calibri, sans-serif" style="font-size:11pt"><b>From:</b> Peter McKinna <peter.mckinna@gmail.com><br>
<b>Sent:</b> Monday, August 14, 2017 6:21:15 PM<br>
<b>To:</b> Jay K<br>
<b>Cc:</b> m3devel<br>
<b>Subject:</b> Re: [M3devel] modula3 fork and virtual timer</font>
<div> </div>
</div>
<div>
<div dir="ltr">Hi Jay,
<div><br>
</div>
<div> I can't see that code anywhere in that file on git. What version are you using?</div>
<div><br>
</div>
<div>By the way, you wouldnt happen to know if we can get LTO support in the backend would you? </div>
<div><br>
</div>
<div>Regards Peter</div>
<div><br>
</div>
<div><br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Tue, Aug 15, 2017 at 8:20 AM, Jay K <span dir="ltr"><<a href="mailto:jayk123@hotmail.com" target="_blank">jayk123@hotmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr">
<div id="m_-2807824095065338855divtagdefaultwrapper" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<p><br>
/mnt/d/dev2/cm3-5.8.6/m3-libs/<wbr>libm3/src/os/POSIX/<wbr>ProcessPosixCommon.m3</p>
<p><br>
</p>
<p>PROCEDURE Create_ForkExec:</p>
<p>.<br>
.<br>
.<br>
(* Turn off the interval timer (so it won't be running in child). *)</p>
<p> nit := Utime.struct_itimerval { <br>
it_interval := Utime.struct_timeval {0, 0}, <br>
it_value := Utime.struct_timeval {0, 0}}; <br>
IF Utime.setitimer(Utime.ITIMER_<wbr>VIRTUAL, nit, oit) < 0 THEN <br>
<* ASSERT FALSE *> <br>
END; <br>
. <br>
. </p>
<p> .</p>
<p> fork() </p>
<p> . <br>
. </p>
<p><br>
(* Enable scheduler. *) <br>
Scheduler.EnableSwitching (); </p>
<p> (* Restore previous virtual timer. *) <br>
IF Utime.setitimer(Utime.ITIMER_<wbr>VIRTUAL, oit, nit) < 0 THEN <br>
<* ASSERT FALSE *> <br>
END; </p>
<p> <br>
This code has a number of problems. </p>
<p> - It looks thread-unsafe -- another thread could be changing the timer. </p>
<p> </p>
<p> - The comments are wrong in multiple ways.<br>
The timer doesn't have to be turned off to not run in the child.<br>
Timers except alarm() are not inherited by child.<br>
It goes ahead and enables in the child anyway. Granted, after EnableSwitching,<br>
which also enables it! </p>
<p><br>
</p>
<p> - Doesn't work on Microsoft's Windows Subsystem for Linux (WSL).</p>
<p> You get back -1/EINVAL.</p>
<p><br>
</p>
<p> - Is probably specific to user threads?</p>
<p> </p>
<p>- Fails to put a useful message in the assert other than "FALSE"</p>
<p> </p>
<p>Proposals:</p>
<p> 1. Remove it.<br>
2. Make it check for and ignore EINVAL, and possibly WSL, and not then enable in child.<br>
3. Change it to get in parent and set in child if enabled. </p>
<p> 4. Move it to Thread.AtFork in user threads. Though again, not clearly needed there.</p>
<p><br>
</p>
<p> 5. Consider that fork+exec should work from C/C++ code in a process that is using Modula3.</p>
<p><br>
</p>
<p> 6. Research posix_spawn and use it more. </p>
<p> We can probably just use it and forget about any system that lacks it.</p>
<p><br>
Thoughts?</p>
<p> WSL can be detected by searching for "Microsoft" in /proc/sys/kernel/osrelease or /proc/version.</p>
<p><br>
</p>
<p> Or we can just accept -1/EINVAL here for any OS.</p>
<span class="HOEnZb"><font color="#888888">
<p><br>
</p>
<p><br>
</p>
<p> - Jay</p>
<p><br>
</p>
</font></span></div>
</div>
<br>
______________________________<wbr>_________________<br>
M3devel mailing list<br>
<a href="mailto:M3devel@elegosoft.com">M3devel@elegosoft.com</a><br>
<a href="https://m3lists.elegosoft.com/mailman/listinfo/m3devel" target="_blank" rel="noreferrer">https://m3lists.elegosoft.com/<wbr>mailman/listinfo/m3devel</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</div>
</body>
</html>