On Thu, Oct 8, 2015 at 6:27 PM, Craig Latta <craig@netjam.org> wrote:


> Well, I threw a (ProcessorScheduler
> relinquishProcessorForMicroseconds: 100) into one of the successful
> vm-thread callbacks, and now the foreign-thread callback hangs waiting
> for the ioWaitOnOSSemaphore() in ownVM(). So I'm not too confident
> that fixing the bug in cedeToHigherPriorityThreads and/or
> threadSwitchIfNecessary:from: will get me moving again. But I'll bang
> on it anyway, I guess.

     I also notice that, at the point where things just start spinning,
I've got four threads, three of which (interpreter loop, thread
scheduling loop, foreign callback thread) are waiting on VM thread
semaphores. How is the other thread, the heartbeat thread, supposed to
get things moving?

The only rôle the heartbeat thread has in multithreading is spotting when the VM is unowned and starting off a thread to take ownership.  e.g. some long-running callout occurs, which first disowns the VM.  It is the heartbeat which spots that the VM is unowned and it might be sensible to start another thread to try and run the VM, hence not slowing down the callout by having it start a thread on each callout.

What's supposed to stop the threads spinning is proper interaction between them.  that this isn't happening is a bug.  As I said, this is a prototype work in progress.




-C

--
Craig Latta
netjam.org
+31 6 2757 7177 (SMS ok)
+ 1 415 287 3547 (no SMS)




--
_,,,^..^,,,_
best, Eliot