<br><br><div class="gmail_quote">On Mon, Sep 21, 2009 at 2:55 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;">
<br>
2009/9/21 John M McIntosh &lt;<a href="mailto:johnmci@smalltalkconsulting.com">johnmci@smalltalkconsulting.com</a>&gt;:<br>
<div class="im">&gt;<br>
&gt; Er, did we reach a consensus about what to do?<br>
&gt;<br>
&gt; My problem is determining what is best based on some the code concepts given<br>
&gt; (which people pointed out flaws in, or confusion about).<br>
&gt; and the premise they work all the same on different hardware platforms<br>
&gt; intel, powerpc, arm, which I&#39;m not sure about.<br>
&gt;<br>
&gt; Perhaps a more heavy weight, platform dependent solution using the generic<br>
&gt; acceptable locking logic is required.<br>
&gt;<br>
</div>+1. As i mentioned before, it would be nice to extend the platform<br>
API, which VM could use<br>
to deal with multithreading.<br>
And platforms which have no threading support could simply do nothing<br>
in these functions.<br>
<div class="im"><br>
&gt; Er like<br>
&gt; acquireTheHostPlatformIndexedSemaphoreLock()<br>
&gt; {Do what ever is required to remember the semaphore index so that<br>
&gt; checkForInterrupts can find it, a queue perhaps?<br>
&gt; releaseTheHostPlatformIndexSemaphoreLock()<br>
&gt;<br>
&gt; I&#39;d keep in mind<br>
&gt;<br>
&gt; (a) How many times do we execute the signalExternalSemaphore logic per<br>
&gt; seconds, and<br>
&gt; (b) if someone want to do  this a million times a second I think they can do<br>
&gt; their own &quot;exotic&quot; solution via overriding<br>
&gt; acquireTheHostPlatformIndexedSemaphoreLock &amp;<br>
&gt; releaseTheHostPlatformIndexSemaphoreLock<br>
&gt; (c) keep it simple so I don&#39;t have to worry how it works on powerpc, intel,<br>
&gt; and arm.<br>
&gt;<br>
&gt; acquireTheHostPlatformIndexedSemaphoreLock/releaseTheHostPlatformIndexSemaphoreLock<br>
&gt; Obviously I&#39;d just throw myself on the evil pthread solution.<br>
&gt;<br>
&gt;<br>
&gt; Would we do a linked list, or queue for the semaphores, versus that fixed<br>
&gt; size list? A size I picked based on exploring network interrupt value rates<br>
&gt; on a mind numbling 200Mhz powerpc machine?<br>
&gt;<br>
<br>
</div>My own experience is following:<br>
- i implemented a shared queue to use in Hydra based on atomic xchg<br>
available on Intel<br>
platforms. It worked well, until i had chance to run Hydra on a<br>
multicore PC, where it failed<br>
just after a few seconds of running the VM, causing VM to freeze infinitely.<br>
Obviously, because implementation was wrong :)<br>
The moral of it that, its not a question, how often we need the<br>
synchronization between threads,<br>
but how correct it is :)<br></blockquote><div><br></div><div>The correct use of mfence &amp; sfence around the XCHGs are essential for it to work on multi-core.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im"><br>
<br>
&gt;<br>
&gt; On 2009-09-20, at 7:00 PM, Igor Stasenko wrote:<br>
&gt;&gt;<br>
&gt;<br>
&gt; --<br>
&gt; ===========================================================================<br>
&gt; John M. McIntosh &lt;<a href="mailto:johnmci@smalltalkconsulting.com">johnmci@smalltalkconsulting.com</a>&gt;   Twitter:  squeaker68882<br>
&gt; Corporate Smalltalk Consulting Ltd.  <a href="http://www.smalltalkconsulting.com" target="_blank">http://www.smalltalkconsulting.com</a><br>
&gt; ===========================================================================<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
<br>
<br>
<br>
</div>--<br>
<div><div></div><div class="h5">Best regards,<br>
Igor Stasenko AKA sig.<br>
</div></div></blockquote></div><br>