<br><br><div class="gmail_quote">On Tue, Jan 11, 2011 at 1:08 PM, Igor Stasenko <span dir="ltr"><<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>></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 <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>> wrote:<br>
><br>
><br>
><br>
> 2011/1/11 Levente Uzonyi <<a href="mailto:leves@elte.hu">leves@elte.hu</a>><br>
>><br>
>><br>
>> On Tue, 11 Jan 2011, Eliot Miranda wrote:<br>
>><br>
>> (Pine can't quote your mail, sorry.)<br>
>><br>
>> "The problem with linux is that the pthreads implementation doesn't allow a normal user-level process to create high-priroity threads so that as<br>
>> 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>
>> expires it'll never get interrupted because it is blocking the very thread that would signal the delay. So until linux's pthreads implementation<br>
>> supports multiple priorities we're stuck with hacks like the interval timer based itimer in the linux Cog VMs."<br>
>><br>
>> What about keeping the priority of the heartbeat thread at user-level and decreasing the other VM threads' priority slighly?<br>
><br>
> Linux doesn't allow more than /one/ thread priority for threads in a user-level process. So one /can'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 & 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'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's use of sigaction. I can give you some tests to run to ensure the VM'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 <= 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't allow the heartbeat thread to run if the heartbeat thread'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>
> best<br>
> Eliot<br>
>><br>
>> Levente<br>
><br>
><br>
><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>