<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Ok, so I tried sched_yield in my C testbed (m3core/src/unix/Common/context/sigaltstack).<br>It still seemed to hang.<br>(I realize you might not have meant that.)<br><br><br>So what happens if none of our user threads have any work? Is that possible?<br>Sure, I can make it so.<br> Just create a bunch of threads that call the Modula-3 equivalent of sleep(big number).<br>Will they actually wake up after that time?<br>And we won't spin the CPU in the meantime?<br>I guess I should test it out..<br><br><br>I can see that "virtual" does seem maybe better than "real", if the virtual one is guaranteed to progress.<br>But I wonder also..you have OpenBSD/x86 or sparc64?<br>cd to that test bed, make, ./tcontext.<br>It always seemed kind of jerky.<br>I bet it'll seem "faster" with "real" timer.<br><br> - Jay<br><br><br><hr id="stopSpelling">From: hosking@cs.purdue.edu<br>Date: Mon, 14 Dec 2009 10:39:31 -0500<br>To: jkrell@elego.de<br>CC: m3commit@elegosoft.com<br>Subject: Re: [M3commit] CVS Update: cm3<br><br>
<div><span class="ecxApple-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; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="ecxApple-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; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div style="word-wrap: break-word;"><span class="ecxApple-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; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="ecxApple-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; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="ecxApple-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; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="ecxApple-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; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="ecxApple-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; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="ecxApple-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; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="ecxApple-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; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="ecxApple-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; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div><span class="ecxApple-style-span" style="font-size: medium;"><font class="ecxApple-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="ecxApple-interchange-newline"><blockquote><div>CVSROOT:<span class="ecxApple-tab-span" style="white-space: pre;"> </span>/usr/cvs<br>Changes by:<span class="ecxApple-tab-span" style="white-space: pre;"> </span>jkrell@birch.<span class="ecxApple-tab-span" style="white-space: pre;"> </span>09/12/14 14:57:30<br><br>Added files:<br><span class="ecxApple-tab-span" style="white-space: pre;"> </span>cm3/m3-libs/m3core/src/unix/Common/context/sigaltstack/: <br><span class="ecxApple-tab-span" style="white-space: pre;"> </span> Makefile <br><span class="ecxApple-tab-span" style="white-space: pre;"> </span> config.c <br><span class="ecxApple-tab-span" style="white-space: pre;"> </span> context.c <br><span class="ecxApple-tab-span" style="white-space: pre;"> </span> context.h <br><span class="ecxApple-tab-span" style="white-space: pre;"> </span> m3makefile <br><span class="ecxApple-tab-span" style="white-space: pre;"> </span> tcontext.c <br><br>Log message:<br><span class="ecxApple-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="ecxApple-tab-span" style="white-space: pre;"> </span>- This should be moved to m3core/src/thread/POSIX<br><span class="ecxApple-tab-span" style="white-space: pre;"> </span>- Notice how I switched from virtual timer to real timer,<br><span class="ecxApple-tab-span" style="white-space: pre;"> </span>in the test case that mimics m3core/src/thread/POSIX.<br><span class="ecxApple-tab-span" style="white-space: pre;"> </span>"This seems to work much better."<br><span class="ecxApple-tab-span" style="white-space: pre;"> </span>In particular, if the main thread does while (1) sleep(0)<br><span class="ecxApple-tab-span" style="white-space: pre;"> </span>to let things run, nothing runs. The virtual time doesn't<br><span class="ecxApple-tab-span" style="white-space: pre;"> </span>run down at all. If I make it a busy wait "while (1) ;" then<br><span class="ecxApple-tab-span" style="white-space: pre;"> </span>it does work.<br><span class="ecxApple-tab-span" style="white-space: pre;"> </span><br><span class="ecxApple-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="ecxApple-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="ecxApple-tab-span" style="white-space: pre;"> </span>extra gymnastics to establish the initial context.<br><span class="ecxApple-tab-span" style="white-space: pre;"> </span><br><span class="ecxApple-tab-span" style="white-space: pre;"> </span>Also still some experiments to try.<br><span class="ecxApple-tab-span" style="white-space: pre;"> </span>_setjmp vs. setjmp vs. sigsetjmp.<br><span class="ecxApple-tab-span" style="white-space: pre;"> </span>Best is probably sigsetjmp(1).<br><span class="ecxApple-tab-span" style="white-space: pre;"> </span>using the same signal in both parts<br></div></blockquote></div><br> </body>
</html>