[Vm-dev] Re: [Pharo-project] Waste of CPU Power by polling events?

Eliot Miranda eliot.miranda at gmail.com
Tue Jan 11 21:38:33 UTC 2011


On Tue, Jan 11, 2011 at 1:08 PM, Igor Stasenko <siguctua at gmail.com> wrote:

>
> On 11 January 2011 20:23, Eliot Miranda <eliot.miranda at gmail.com> wrote:
> >
> >
> >
> > 2011/1/11 Levente Uzonyi <leves at elte.hu>
> >>
> >>
> >> On Tue, 11 Jan 2011, Eliot Miranda wrote:
> >>
> >> (Pine can't quote your mail, sorry.)
> >>
> >> "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
> >> 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
> >> expires it'll never get interrupted because it is blocking the very
> thread that would signal the delay.  So until linux's pthreads
> implementation
> >> supports multiple priorities we're stuck with hacks like the interval
> timer based itimer in the linux Cog VMs."
> >>
> >> What about keeping the priority of the heartbeat thread at user-level
> and decreasing the other VM threads' priority slighly?
> >
> > 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.
>
>
> So, why not use signals & POSIX timer [1] for same purpose?
> Or do signals having other issues which even worse than using heartbeat
> process?
>

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
of SIGEV_THREAD_ID or 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

| start stop |
start := Time millisecondClockValue.
stop := start + 1000.
[Time millisecondClockValue <= stop] whileTrue

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 SIGEV_THREAD if the implementation is
really based on threads.

best
Eliot



> [1]
> http://www.kernel.org/doc/man-pages/online/pages/man2/timer_create.2.html
>
> > best
> > Eliot
> >>
> >> Levente
> >
> >
> >
>
>
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20110111/7f236fc8/attachment.htm


More information about the Vm-dev mailing list