continued init (RE: OTP or not to OTP)

Matthias Lang <>
Mon Mar 3 15:29:14 CET 2003


Sean Hinde writes:

 > I do believe that we are
 > slightly kidding ourselves when we say that Erlang makes concurrent
 > programming easy* - it is easy (ish) to make simple 'object' type processes
 > but it is possible to get into an enormous mess of deadlocks and so on if
 > you try to get too tricky. This to me is another reason why gen_servers and
 > so on are a good thing - they stop people trying to get too complex and then
 > find that after a couple of months some weird network conition occurs which
 > deadlocks the whole thing.

Even with gen_servers, the only thing preventing deadlock in most of
the systems I write is the diagram on my whiteboard of which
gen_servers are allowed to call which other gen_servers. Otherwise
it's too easy to get into this situation:

   a.erl:

    lookup_something_else() -> gen_server:call(?MODULE, lookup_something_else).

    handle_call(_,_,_) ->
         b:lookup_something(),
         ...

   b.erl:

    lookup_something() -> gen_server:call(?MODULE, lookup_something).

    handle_call(_,_,_) ->
         a:lookup_something_else(),
         ...

The positive thing about Erlang is that these types of mistakes almost
always result in a deadlock followed by a timeout (as compared to
corruption, crash or a permanently hung thread).

Matthias



More information about the erlang-questions mailing list