<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><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; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 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; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 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; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-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; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 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; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-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; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 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; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-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; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 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; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-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; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 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; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-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; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 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; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-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; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 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; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-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; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 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; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div><span class="Apple-style-span" style="font-size: medium;"><font class="Apple-style-span" color="#0000FF" face="'Gill Sans'">Main thread should call Yield if you want that behavior, not sleep.</font></span></div></span></span></span></span></span></span></span></span></div></span></span>
</div>
<br><div><div>On 14 Dec 2009, at 14:57, Jay Krell wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>CVSROOT:<span class="Apple-tab-span" style="white-space:pre">  </span>/usr/cvs<br>Changes by:<span class="Apple-tab-span" style="white-space:pre">       </span>jkrell@birch.<span class="Apple-tab-span" style="white-space:pre">       </span>09/12/14 14:57:30<br><br>Added files:<br><span class="Apple-tab-span" style="white-space:pre"> </span>cm3/m3-libs/m3core/src/unix/Common/context/sigaltstack/: <br><span class="Apple-tab-span" style="white-space:pre"> </span>                                                         Makefile <br><span class="Apple-tab-span" style="white-space:pre">        </span>                                                         config.c <br><span class="Apple-tab-span" style="white-space:pre">        </span>                                                         context.c <br><span class="Apple-tab-span" style="white-space:pre">       </span>                                                         context.h <br><span class="Apple-tab-span" style="white-space:pre">       </span>                                                         m3makefile <br><span class="Apple-tab-span" style="white-space:pre">      </span>                                                         tcontext.c <br><br>Log message:<br><span class="Apple-tab-span" style="white-space:pre">      </span>working version of <a href="http://www.engelschall.com/pw/usenix/2000/pmt-html/">http://www.engelschall.com/pw/usenix/2000/pmt-html/</a><br><span class="Apple-tab-span" style="white-space:pre">    </span>- This should be moved to m3core/src/thread/POSIX<br><span class="Apple-tab-span" style="white-space:pre"> </span>- Notice how I switched from virtual timer to real timer,<br><span class="Apple-tab-span" style="white-space:pre"> </span>in the test case that mimics m3core/src/thread/POSIX.<br><span class="Apple-tab-span" style="white-space:pre">     </span>"This seems to work much better."<br><span class="Apple-tab-span" style="white-space:pre">       </span>In particular, if the main thread does while (1) sleep(0)<br><span class="Apple-tab-span" style="white-space:pre"> </span>to let things run, nothing runs. The virtual time doesn't<br><span class="Apple-tab-span" style="white-space:pre"> </span>run down at all. If I make it a busy wait "while (1) ;" then<br><span class="Apple-tab-span" style="white-space:pre">    </span>it does work.<br><span class="Apple-tab-span" style="white-space:pre">     </span><br><span class="Apple-tab-span" style="white-space:pre">  </span>Note that Apple seems very down on supplying get/make/set/swapcontext (read the mailing lists).<br><span class="Apple-tab-span" style="white-space:pre">   </span>This solution might be preferred? Though it is slower to create a thread here, due to<br><span class="Apple-tab-span" style="white-space:pre">     </span>extra gymnastics to establish the initial context.<br><span class="Apple-tab-span" style="white-space:pre">        </span><br><span class="Apple-tab-span" style="white-space:pre">  </span>Also still some experiments to try.<br><span class="Apple-tab-span" style="white-space:pre">       </span>_setjmp vs. setjmp vs. sigsetjmp.<br><span class="Apple-tab-span" style="white-space:pre"> </span>Best is probably sigsetjmp(1).<br><span class="Apple-tab-span" style="white-space:pre">    </span>using the same signal in both parts<br></div></blockquote></div><br></body></html>