Can you email me your complete code? I've tried to put together your example by modifying the existing demo application, and although I'm not getting the error message (I'm maybe not waiting long enough), I am definetely not getting the correct number of responses printed to the screen, and the program doesn't terminate. Not sure if it's deadlock, but I'll take a closer look.
-----Original Message-----
From: Mailing_List_Robot on behalf of Sachin Desai
Sent: Tue 20/05/2008 01:31
To: java-threads@xxxxxxxxxx
Subject: Any2OneCallChannel deadlocking?
Hello,
I've modified the Any2OneCallChannel example that's part of
jcsp-1.1rc3 where I've added multiple callers for the call channel;
the example had one and I'm testing with 200. I've commented out all
System.out.* statements and each one of my 200 callers executes 100
calls in a tight loop.
My Any2OneMain main program looks like:
A[] a = new A[200];
for (int i = 0; i < 200; i++) {
a[i] = new A(c, 100);
}
new Parallel(
new CSProcess[] {
new Parallel(a),
new B2(c, 200 * 100)
}
).run();
where 200 is the number of processes and 100 is the number of calls
each process makes. The run() method in class B1 looks like:
for (int i = 0; i < count; i++) {
in.accept(this);
}
where count = 200 * 100. I wanted the program to terminate at
execution end and not wait to process.
When I run the program it seems to deadlock or at least seems to hang
for a long period of time. There are times when it completes but for
the most part it hangs. Forcing the JVM to dump the stack trace, I see
many instances of the following, I presume one for each running thread
"org.jcsp.lang.Parallel@31f26605" daemon prio=5 tid=0x000000010185b000
nid=0x110651000 waiting for monitor entry
[0x0000000110650000..0x0000000110650ad0]
java.lang.Thread.State: BLOCKED (on object monitor)
at org.jcsp.lang.Any2OneImpl.write(Unknown Source)
- waiting to lock <0x00000001050d3f60> (a java.lang.Object)
at org.jcsp.lang.Any2OneCallChannel.join(Unknown Source)
at
org.jcsp.demos.call.Any2OneFooChannel.calculate(Any2OneFooChannel.java:
39)
at org.jcsp.demos.call.A.run(A.java:49)
at org.jcsp.lang.Parallel.run(Unknown Source)
at org.jcsp.lang.ParThread.run(Unknown Source)
My question is, is this a deadlock I'm seeing? Am I using the
Any2OneCallChannel correctly? If not, what's the right way. What I'm
trying to accomplish is having multiple callers call on a single
resource.
I'm running this on a MacBook Pro 2.6GHz 4GB of memory.
Any help or pointers would be appreciated.
-- Sachin.
This message is intended for the addressee(s) only and
should not be read, copied or disclosed to anyone else outwith the University
without the permission of the sender.
It is your responsibility to ensure
that this message and any attachments are scanned for viruses or other defects.
Napier University does not accept liability for any loss
or damage which may
result from this email or any attachment, or for errors or omissions arising
after it was sent. Email is not a secure medium. Email entering the
University's system is subject to routine monitoring and filtering by the
University.
Napier University is a registered Scottish charity. Registration number SC018373