Erl Ports and Threads

Casper casper2000a@REDACTED
Thu Dec 16 10:37:34 CET 2004


Hi Klacke,

Thanks for the response.

Here I am not talking about simultaneous write() operations on a socket/pipe
from the multiple external program. I am talking about multiple threads in
one program.

Is single write() call, atomic or not?

If that's not thread safe, what's the best way to go for inter-operability?

Cheers,
Eranga




-----Original Message-----
From: klacke@REDACTED [mailto:klacke@REDACTED] 
Sent: Thursday, December 16, 2004 3:04 PM
To: Casper
Cc: erlang-questions@REDACTED
Subject: Re: Erl Ports and Threads

On Thu, Dec 16, 2004 at 09:54:52AM +0600, Casper wrote:
>    Hi all,
> 
> 
>    I am wondering, is Erlang Ports are thread safe?
> 
> 
>    I'm planning to use Erl Interface based Erlang Port. If communicates
>    with the Erlang node over Standard Input and Output. The communication
>    message has 2 bytes header indicating the length of the message
>    followed by the encoded message. If the C program has multiple threads
>    and if they write to the stdout at the same time, will there be any
>    communication problem?
> 

This will ofcourse wreak major havoc. You have to synchronize
the output from your threads.

It's just a pipe between erlang and the external C-program and
erlang will just sit there reading data.

write() operations on a socket/pipe from the external program
are not atomic in unix/linux. 


/klacke


-- 
Claes Wikstrom                        -- Caps lock is nowhere and
http://www.hyber.org                  -- everything is under control





More information about the erlang-questions mailing list