<br><br><div class="gmail_quote">On Tue, Jan 11, 2011 at 1:08 PM, Igor Stasenko <span dir="ltr">&lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5"><br>
On 11 January 2011 20:23, Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; 2011/1/11 Levente Uzonyi &lt;<a href="mailto:leves@elte.hu">leves@elte.hu</a>&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Tue, 11 Jan 2011, Eliot Miranda wrote:<br>
&gt;&gt;<br>
&gt;&gt; (Pine can&#39;t quote your mail, sorry.)<br>
&gt;&gt;<br>
&gt;&gt; &quot;The problem with linux is that the pthreads implementation doesn&#39;t allow a normal user-level process to create high-priroity threads so that as<br>
&gt;&gt; soon as the Vm starts to spin doing some computation the heartbeat thread is shut-out and if the spinning computation only interrupted when a delay<br>
&gt;&gt; expires it&#39;ll never get interrupted because it is blocking the very thread that would signal the delay.  So until linux&#39;s pthreads implementation<br>
&gt;&gt; supports multiple priorities we&#39;re stuck with hacks like the interval timer based itimer in the linux Cog VMs.&quot;<br>
&gt;&gt;<br>
&gt;&gt; What about keeping the priority of the heartbeat thread at user-level and decreasing the other VM threads&#39; priority slighly?<br>
&gt;<br>
&gt; Linux doesn&#39;t allow more than /one/ thread priority for threads in a user-level process.   So one /can&#39;t/ have multiple priorities.  All threads run at the same priority.  This is a horrible bug in the linux pthreads implementation but there it is.<br>

<br>
<br>
</div></div>So, why not use signals &amp; POSIX timer [1] for same purpose?<br>
Or do signals having other issues which even worse than using heartbeat process?<br></blockquote><div><br></div><div>What would the benefit of using timer_create (which looks to be linux-specific) instead of setitimer?  Both would deliver their pulse via signals, no?  You&#39;re very welcome to try this and see whether e.g. the use <font class="Apple-style-span" face="arial, helvetica, sans-serif">of </font><span class="Apple-style-span" style="white-space: pre; "><font class="Apple-style-span" face="arial, helvetica, sans-serif">SIGEV_THREAD_ID or </font></span><span class="Apple-style-span" style="white-space: pre; "><font class="Apple-style-span" face="arial, helvetica, sans-serif">SIGEV_THREAD works better than the heartbeat&#39;s use of sigaction.  I can give you some tests to run to ensure the VM&#39;s heartbeat is working correctly.  It is essentially</font></span></div>
<div><span class="Apple-style-span" style="white-space: pre; "><font class="Apple-style-span" face="arial, helvetica, sans-serif"><br></font></span></div><div><span class="Apple-style-span" style="white-space: pre; "><font class="Apple-style-span" face="arial, helvetica, sans-serif">    | start stop |</font></span></div>
<div><span class="Apple-style-span" style="white-space: pre; "><font class="Apple-style-span" face="arial, helvetica, sans-serif">    start := Time millisecondClockValue.</font></span></div><div><span class="Apple-style-span" style="white-space: pre; "><font class="Apple-style-span" face="arial, helvetica, sans-serif">    stop := start + 1000.</font></span></div>
<div><span class="Apple-style-span" style="white-space: pre; "><font class="Apple-style-span" face="arial, helvetica, sans-serif">    [Time millisecondClockValue &lt;= stop] whileTrue</font></span></div><div><span class="Apple-style-span" style="white-space: pre; "><font class="Apple-style-span" face="arial, helvetica, sans-serif"><br>
</font></span></div><div><span class="Apple-style-span" style="white-space: pre; "><font class="Apple-style-span" face="arial, helvetica, sans-serif">This will lock-up a threaded heartbeat on linux since the hard loop doesn&#39;t allow the heartbeat thread to run if the heartbeat thread&#39;s priority is the same as the VMs.  So this may break </font></span><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif; white-space: pre; ">SIGEV_THREAD if the implementation is really based on threads.</span></div>
<div><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif; white-space: pre; "><br></span></div><div><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif; white-space: pre; ">best</span></div>
<div><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif; white-space: pre; ">Eliot</span></div><div><span class="Apple-style-span" style="white-space: pre; "><font class="Apple-style-span" face="arial, helvetica, sans-serif"><br>
</font></span></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
[1] <a href="http://www.kernel.org/doc/man-pages/online/pages/man2/timer_create.2.html" target="_blank">http://www.kernel.org/doc/man-pages/online/pages/man2/timer_create.2.html</a><br>
<br>
&gt; best<br>
&gt; Eliot<br>
&gt;&gt;<br>
&gt;&gt; Levente<br>
&gt;<br>
&gt;<br>
&gt;<br>
<font color="#888888"><br>
<br>
<br>
--<br>
</font><div><div></div><div class="h5">Best regards,<br>
Igor Stasenko AKA sig.<br>
</div></div></blockquote></div><br>