<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 23 Jan 2009, at 02:09, 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; ">I noticed in some of the code..I think for SegV, Quit,<br>etc., not for thread suspension, that if the signal<br>is already set to other than SIG_DFL, Modula-3 refrains<br>from changing it.<br> <br>So, I was thinking, would it be reasonable to iterate through, say<br>SIGUSR1, SIGUSR2, and SIGRTMIN through SIGRTMAX, and<br>use the "first" one that isn't set to SIG_DFL?<br>By "first", I don't mean to imply what order to check in,<br>probably my statement has the order backwards.<br>The point is to check them and not just hijack them.</div></span></blockquote><div><br></div><div>Maybe.  I would argue the opposite: that M3 apps that use signals should avoid using the one dedicated to thread suspension.</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; ">OR, is there another way to do this?<br><br>Doesn't or can't the Modula-3 code "check a flag"<br>"every so often" and then voluntarily yield?<br>Of course, the allocator would check the flag.</div></span></blockquote><div><br></div><div>This is a reasonable approach for Modula-3-compiled code: the polling points are called GC-safe-points.  You just need to insert poll-points on backward branches and calls.  The real problem is stopping threads that are off in native code and system calls.   We could wrap every native call with a code to save GC-relevant state before going native, and then check the flag on return from native in case a GC is in progress.  Many Java implementations use that approach.</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; ">Perhaps I just really need to get "that paper" into my head?<br>Understand the issue around "other threads running in<br>tight computation loops for a long time", and therefore not checking<br>on yielding?<br><br>Is the signal mechanism actually preemptive anyway?</div></span></blockquote><div><br></div><div>Preemptive in what sense?  Depending on the OS, signals tend to get delivered at system calls or thread context-switches.</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><br><br><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>> Date: Wed, 21 Jan 2009 09:42:38 -0500<br>> CC:<span class="Apple-converted-space"> </span><a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>> Subject: Re: [M3devel] chosing SIG_SUSPEND?<br>><span class="Apple-converted-space"> </span><br>> Yes, we want a signal no-one else is using to stop the threads.<br>><span class="Apple-converted-space"> </span><br>> On 21 Jan 2009, at 08:37, Jay wrote:<br>><span class="Apple-converted-space"> </span><br>> ><br>> > Solaris at least currently has SIGRTMAX.<br>> > I want to switch RTSignalC.c to "something" here.<br>> > I can preserve compat, like<br>> ><br>> > #ifdef __sun<br>> > SIGUSR2<br>> > #else..<br>> ><br>> > or..?<br>> ><br>> > I could do<br>> > #ifdef SIGUSR2<br>> > #define SIG_SUSPEND SIGUSR2<br>> > #elif defined(SIGRTMAX)<br>> > #define SIG_SUSPEND SIGRTMAX<br>> > #else<br>> > #error<br>> > #endif<br>> ><br>> > I'll go with a compatible version for now and you can change it if<span class="Apple-converted-space"> </span><br>> > you want.<br>> > I'll test on Linux/x86, FreeBSD (AMD64, but hopefully there is gcc -<span class="Apple-converted-space"> </span><br>> > m32),<br>> > Linux/PPC, Solaris, Cygwin, Darwin/PPC (uh, actually, no, Darwin isn't<br>> > really relevant, but I'll make sure the result does what is intended.)<br>> ><br>> > It looks like SIGRTMAX is a function call on Solaris.<br>> ><br>> > This stuff is like broken, right?<br>> > I mean, there's a small number of signals and there's no arbitration.<br>> > People just take them over and hope nobody else cares.<br>> ><br>> ><br>> > There's no way to just queue a function call to a thread, in<span class="Apple-converted-space"> </span><br>> > portable/general?<br>> > Windows has QueueUserAPC or SuspendThread (SuspendThread is dangerous,<br>> > thread could be doing anything), QueueUserAPC only interrupts at<span class="Apple-converted-space"> </span><br>> > certain times.<br>> ><br>> ><br>> > - Jay<br>> ><br>> ><br>> > ----------------------------------------<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>> >> Date: Wed, 21 Jan 2009 03:42:01 +1100<br>> >> CC:<span class="Apple-converted-space"> </span><a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>> >> Subject: Re: [M3devel] chosing SIG_SUSPEND?<br>> >><br>> >> Choose SIGRTMAX first if defined, then SIGUSR2. I don't thing NSIG-1<br>> >> is reliable, but just works on some systems.<br>> >><br>> >> On 21 Jan 2009, at 01:12, Jay wrote:<br>> >><br>> >>><br>> >>> What is the algorithm for chosing SIG_SUSPEND?<br>> >>><br>> >>> Something like:<br>> >>><br>> >>> #include<br>> >>><br>> >>> #ifdef __APPLE__<br>> >>> /* nothing -- SIG_SUSPEND not used */<br>> >>> #elif defined(NSIG)<br>> >>> #define SIG_SUSPEND (NSIG - 1)<br>> >>> #elif defined(_NSIG)<br>> >>> #define SIG_SUSPEND (_NSIG - 1)<br>> >>> #elif defined(SIGRTMAX)<br>> >>> #define SIG_SUSPEND SIGRTMAX<br>> >>> #else<br>> >>> #define SIG_SUSPEND SIGUSR2<br>> >>> #endif<br>> >>><br>> >>> ?<br>> >>><br>> >>> Whatever it is, I think it should be in RTSignalC.c.<br>> >>><br>> >>> - Jay<br>> >><br>><span class="Apple-converted-space"> </span><br><br></div></span></blockquote></div><br></body></html>