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

RE: Any2OneCallChannel deadlocking? - NO Any2OneChannel deadlocking



Title: RE: Any2OneCallChannel deadlocking?

Sachin (and everyone else),

 

Just a quick update.  I haven’t found out exactly what is going wrong so far, but I’ll give you a rundown of what is happening internally.

 

Basically, a call channel works in two parts, as you probably spotted.  The server (or the callee) calls the accept method, and the client (or caller) calls the relevant method on the call channel.  Internally, a two part synchronization upon two channels – c and d - occurs.  c is a Any2OneChannel and d is a One2OneChannel.  When the client calls a method, it writes to c, thus blocking.  The server, on calling accept, reads from c, and then immediately reads from d, thus blocking.  The client can now call the method, and when finished writes to d ending the synchronization.  As c is Any2One, it should in principle be safe for multiple clients to use the call channel.

 

My first though was that somehow two client processes were attempting to read from d at once.  As d is One2One, this can lead to either both processes being released, or both being blocked.  However, I tried that and the same problem occurred, so no luck there.  Then I wrote a quick test program checking the Any2OneChannel itself (same idea, 200 writers to 1 reader, 100 writes per writer) and the same deadlock appeared, so there appears to be a problem with the Any2OneChannel.  I’ll try and piece together what is going on and fix it.

 

For just now, to get your program to work you will have to change the Any2OneFooChannel.  After each fork() and each join() call Thread.yield().  This appears to work for me.

 

Kevin Chalmers

Research Student

School of Computing

Napier University

Edinburgh


From: Mailing_List_Robot [mailto:sympa@xxxxxxxxxx] On Behalf Of Chalmers, Kevin
Sent: 20 May 2008 08:20
To: Sachin Desai; java-threads@xxxxxxxxxx
Subject: RE: Any2OneCallChannel deadlocking?

 

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

 

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