Hi,
i'm having problems with neko threading. The following program:
""
import neko.vm.Thread;
import neko.vm.Lock;
class Test {
static var foo:Int;
static var bar:Int;
static var lock:Lock;
static function threadFunc() {
bar = foo;
neko.Sys.sleep(.001);
lock.release();
}
public static function main() {
foo=0;
lock = new Lock();
while( true ) {
Thread.create( threadFunc );
lock.wait();
trace( ""+foo+": "+(foo==bar) );
foo++;
bar=null;
neko.Sys.sleep(.01);
}
}
}
""
counts to 380 or 381 on my 32bit machine, then:
Test.hx:23: 381: true
Called from <null> line 1
Called from Test.hx line 21
Called from neko/vm/Thread.hx line 57
Uncaught exception - s...@thread_create
on my 64bit, it's even worse, counting to an unpredictable number and
crashing with:
An exception occured in a neko Thread :
C Stack overflow
(additionally, i cant get me to trust Lock and Mutex on the 64bit, but
no formal tests there (yet))
in vm/threads.c, neko_thread_create, the "tparams p" is allocated on the
stack-- might that be the source of these problems?
help! please.
-dan
--
Neko : One VM to run them all
(http://nekovm.org)