[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Any2OneCallChannel deadlocking?


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)

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++) {

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.