Communicating with Java node

Twan van der Schoot <>
Thu May 23 01:25:46 CEST 2002


Hi Vlad,

As far as I understand it from reading the maillist (from Raimo Niskanen 
[] 200020515 12:19 with subject line "Re: File 
locking & device drivers"), quoted:

...
Is this not more of a general flow control problem. Asynchronous message
passing is THE way to synchronize processes in Erlang. If you have a
server that passes messages to somewhere (a file while guarding all
writes with 'flock') and many clients just feeding the server (no
request/reply message passing), the server message queue might grow in
this case affecting the server's ability to serve requests since these
client messages gets in the way of more important messages.

There is a mechanism in the Erlang emulator (virtual machine) that
compensates for this problem. A process that sends a message to another
process with a large message queue gets punished with getting sheduled
out sooner. This mechanism diminsishes this producer/consumer problem.
...

The last paragraph, I believe, is the answer to your question.


kr

Twan


On Tuesday, May 21, 2002 8:57 AM, Vlad Dumitrescu  wrote:
> Hi all,
>
> I have a problem that I can't find the cause, and hope someone might know 
> the answer.
>
> I have an Erlang and a Java node communicating with each other. I noticed 
> that if an Erlang process sends many messages to a Java process, then it 
is
> sometimes being slowed down, as if it was waiting for some response 
(which
> is not the case). The delay occurs when the Java process, upon receiving 
the
> message, writes something to the console... The difference for 1000 
messages
> is ~500 ms when Java only reads the msg, and ~2200 ms when the receive is 
> followed by an System.out.println. The delay seems to be independent of 
how
> much text is written.
>
> Is it something that I do wrong, or is it normal behaviour, or is there a 
> bug? Thanks in advance,
>
> Vlad
>
> Erlang code:
> -module(tt).
> -compile(export_all).
> go(0)-> ok;
> go(N) -> {main, } ! {self(), hello}, go(N-1).
>
> shell> timer:tc(tt, go, [999]).
>
> Java code:
> import com.ericsson.otp.erlang.*;
> class App {
> 	public static main(String[] args)
> 	{
> 	try {
> 		OtpErlangNode node = new OtpErlangNode("java");
> 		OtpErlangMbox mbox = node.createMbox("main");
> 		while(true)
> 		{
> 			OtpErlangObject msg = mbox.receive();
> 			// System.out.println("got: "+msg.toString());
> 		}
> 	} catch (Exception ex) {}
> 	}
> }
>
>
>
> _________________________________________________________________
> Chatta med kompisar online, prova MSN Messenger: http://messenger.msn.com
> 



More information about the erlang-questions mailing list