On Sat, 2010-11-13 at 12:49 +0300, Dmitry Olshansky wrote: [ . . . ] > Well at least the Thread starts )
Indeed :-) > I'd search for the clues by replacing all complicated logic with > writeln("Func x executed"); where x identifies functions. > If it prints all successfully, then it's bug in your code. > My best guess - you are not aware of "Thread-local by default", i.e. any > thread you spawn won't have access to parent's thread global data. > Anyway, I'd suggest posting it on D.learn with full source code, guys > there are quite helpful. Using gdb I get: (gdb) bt #0 0x0804ee1a in _d_monitorenter () #1 0x080498c2 in pi_d2_threads.partialSum (delta=9.9999999999999999998051260704522807e-10, end=4294967296, start=1000000001) at pi_d2_threads.d:25 #2 0x08049ae5 in pi_d2_threads.execute.__dgliteral1 (this=0xf7d24ce0) at pi_d2_threads.d:35 #3 0x0804f942 in core.thread.Thread.run() () #4 0x08055e3e in thread_entryPoint () #5 0xf7fa7cb2 in start_thread (arg=0xf7d1fb70) at pthread_create.c:304 #6 0xf7ef107e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130 (gdb) OK, so now I know I am trying to do things the wrong way, explicit threads, shared global data, and synchronized statements, but that is the whole point of my examples. Segementation fault is not though the error message I think this should result in. Anyway I have global objects: shared real sum ; shared Object sumMutex ; then in the function partialSum that is being executed by each of the threads: synchronized ( sumMutex ) { sum += localSum ; } It compiles, it executes, it seg faults. -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.win...@ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: rus...@russel.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
signature.asc
Description: This is a digitally signed message part