Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion non-FIFO behavior in process mailboxes?

Received: by 10.204.131.75 with SMTP id w11mr1375619bks.0.1335115659412;
        Sun, 22 Apr 2012 10:27:39 -0700 (PDT)
X-BeenThere: erlang-programming@googlegroups.com
Received: by 10.204.130.2 with SMTP id q2ls4870181bks.9.gmail; Sun, 22 Apr
 2012 10:27:39 -0700 (PDT)
Received: by 10.205.123.6 with SMTP id gi6mr1374955bkc.5.1335115658978;
        Sun, 22 Apr 2012 10:27:38 -0700 (PDT)
Received: by 10.205.123.6 with SMTP id gi6mr1374954bkc.5.1335115658962;
        Sun, 22 Apr 2012 10:27:38 -0700 (PDT)
Return-Path: <erlang-questions-boun...@erlang.org>
Received: from hades.cslab.ericsson.net (hades.cslab.ericsson.net. [192.121.151.104])
        by gmr-mx.google.com with ESMTP id k15si14439510bks.0.2012.04.22.10.27.38;
        Sun, 22 Apr 2012 10:27:38 -0700 (PDT)
Received-SPF: pass (google.com: domain of erlang-questions-boun...@erlang.org designates 192.121.151.104 as permitted sender) client-ip=192.121.151.104;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of erlang-questions-boun...@erlang.org designates 192.121.151.104 as permitted sender) smtp.mail=erlang-questions-boun...@erlang.org
Received: from hades.cslab.ericsson.net (hades [192.121.151.104])
	by hades.cslab.ericsson.net (Postfix) with ESMTP id 81C3D5C098;
	Sun, 22 Apr 2012 19:27:33 +0200 (CEST)
X-Original-To: erlang-questi...@erlang.org
Delivered-To: erlang-questi...@erlang.org
Received: from m1plsmtpa01-07.prod.mesa1.secureserver.net
 (m1plsmtpa01-07.prod.mesa1.secureserver.net [64.202.165.186])
 by hades.cslab.ericsson.net (Postfix) with ESMTP id D4EF55C000
 for <erlang-questi...@erlang.org>; Sun, 22 Apr 2012 19:27:30 +0200 (CEST)
Received: from [192.168.1.74] ([81.231.171.228])
 by m1plsmtpa01-07.prod.mesa1.secureserver.net with 
 id 15TT1j00C4w1SRM015TVAd; Sun, 22 Apr 2012 10:27:30 -0700
References: <CANHeBiipSpLo7fgK+bt18qKVEQ+D4DfvcqCQKYqHyK60MK5-ng@mail.gmail.com>
 <C1C677A0-E625-4BCC-8D70-8AB492309503@feuerlabs.com>
In-Reply-To: <C1C677A0-E625-4BCC-8D70-8AB492309503@feuerlabs.com>
Mime-Version: 1.0 (1.0)
Message-Id: <765DC2EC-CA0F-47A3-B58C-511C1BF71...@feuerlabs.com>
X-Mailer: iPhone Mail (9B179)
From: Ulf Wiger <u...@feuerlabs.com>
Date: Sun, 22 Apr 2012 19:27:26 +0200
To: Ulf Wiger <u...@feuerlabs.com>
Cc: "erlang-questi...@erlang.org" <erlang-questi...@erlang.org>
Subject: Re: [erlang-questions] non-FIFO behavior in process mailboxes?
X-BeenThere: erlang-questi...@erlang.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: General Erlang/OTP discussions <erlang-questions.erlang.org>
List-Unsubscribe: <http://erlang.org/mailman/options/erlang-questions>,
 <mailto:erlang-questions-requ...@erlang.org?subject=unsubscribe>
List-Archive: <http://erlang.org/pipermail/erlang-questions>
List-Post: <mailto:erlang-questi...@erlang.org>
List-Help: <mailto:erlang-questions-requ...@erlang.org?subject=help>
List-Subscribe: <http://erlang.org/mailman/listinfo/erlang-questions>,
 <mailto:erlang-questions-requ...@erlang.org?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: erlang-questions-boun...@erlang.org
Sender: erlang-questions-boun...@erlang.org

Oh, and the io:format/2 call _does_ force a yield, since it involves a synchronous call to the group_leader.

BR,
Ulf W

Ulf Wiger, Feuerlabs, Inc.
http://www.feuerlabs.com

22 apr 2012 kl. 19:23 skrev Ulf Wiger <u...@feuerlabs.com>:

> You seem to have a race between the messages sent from the client and the ones the server sends to itself.
> 
> Bear in mind that the client doesn't yield after send, add SMP to the mix and you cannot know whether that server consumes the first message before the client sends its 
> 
> BR,
> Ulf W
> 
> Ulf Wiger, Feuerlabs, Inc.
> http://www.feuerlabs.com
> 
> 22 apr 2012 kl. 18:25 skrev Michael Turner <michael.eugene.tur...@gmail.com>:
> 
>> When the code listed below executes with the first io:format call
>> commented out, it breaks, reporting:
>> 
>> ** exception error: no match of right hand side value []
>>    in function  wg:init/0
>> 
>> When I don't have it commented out, it works (sort of), writing
>> 
>> val_for (P)=[]
>> val_for (P)=2
>> ok
>> 
>> Here's the code:
>> -----
>> 
>> -module(wg).
>> -export ([init/0, be/2]).
>> 
>> val_for (P) ->
>>   P ! {tell, self(), val},
>>   receive
>>       {Val, for, P} -> Val
>>   end.
>> 
>> be (Arg, Val) ->
>>   receive
>>       [H|T] ->
>>           self() ! T,
>>           self() ! H,
>>           be (Arg, Val);
>>       [] ->
>>           be (Arg, Val);
>>       {tell, X, val} ->
>>           X ! {Val, for, self()},
>>           be (Arg, Val);
>>       {set_arg_to, A} ->
>>           be (A, Val);
>>       {set_val_to, V} ->
>>           be (Arg, V)
>>   end.
>> 
>> init() ->
>>   P = spawn (wg, be, [[],[]]),
>>   P ! [{set_arg_to, 1}, {set_val_to, 2}],
>> %   io:format ("val_for (P)=~p~n", [val_for (P)]),
>>   2 = val_for (P),
>>   io:format ("val_for (P)=~p~n", [val_for (P)]),
>>   ok.
>> -----
>> 
>> This is R14B on Windows XP. Haven't tried it elsewhere yet.
>> 
>> Seeing this really messes with my mental model of process mailboxes.
>> With the first io:format call commented out, I think process P should
>> be seeing messages queued up in the following order:
>> 
>> [{set_arg_to, 1}, {set_val_to, 2}]
>> [{set_val_to, 2}]
>> {set_arg_to, 1}
>> []
>> {set_val_to, 2}
>> {tell, X, val}
>> 
>> And shouldn't this mean that Val = 2 in process P when the {tell, X,
>> val} message reaches P? As I interpret Armstrong pp.145-6, since
>> matches are guaranteed in this case, there's no save queue activity;
>> since there's no "after" close, the timer is irrelevant; so you should
>> get pure FIFO behavior, right?
>> 
>> -michael turner
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questi...@erlang.org
>> http://erlang.org/mailman/listinfo/erlang-questions
> _______________________________________________
> erlang-questions mailing list
> erlang-questi...@erlang.org
> http://erlang.org/mailman/listinfo/erlang-questions
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions