anchor.diff:              erlang:demonitor(MRef, [flush]),
               monitor_order_1(N - 1)
       end.
  +
  +%% Signal order: Message vs DOWN from local process monitored by name.
  +monitor_named_order_local(_Config) ->
  +    process_flag(message_queue_data, off_heap),
  +    erts_debug:set_internal_state(available_internal_state, true),
  +    true = erts_debug:set_internal_state(proc_sig_buffers, true),
  +
  +    LNode = node(),
  +    repeat(fun (N) -> monitor_named_order(LNode, N) end, 100),
  +    ok.
  +
  +%% Signal order: Message vs DOWN from remote process monitored by name.
  +monitor_named_order_remote(_Config) ->
  +    process_flag(message_queue_data, off_heap),
  +    erts_debug:set_internal_state(available_internal_state, true),
  +    true = erts_debug:set_internal_state(proc_sig_buffers, true),
  +
  +    {ok, Peer, RNode} = ?CT_PEER(),
  +    repeat(fun (N) -> monitor_named_order(RNode, N) end, 10),
  +    peer:stop(Peer),
  +    ok.
  +
  +monitor_named_order(Node, N) ->
  +    %% Send messages using pid, name and alias.
  +    Pid = self(),
  +    register(tester, Pid),
  +    Name = {tester, node()},
  +    AliasA = alias(),
  +    NumMsg = 1000 + N,
  +    Sender = spawn_link(Node,
  +                     fun() ->
  +                             register(monitor_named_order, self()),
  +                             Pid ! {self(), ready},
  +                             {go, AliasM} = receive_any(),
  +                             send_msg_seq(Pid, Name, AliasA, AliasM, NumMsg),
  +                             exit(normal)
  +                     end),
  +    {Sender, ready} = receive_any(),
  +    AliasM = monitor(process, {monitor_named_order,Node},
  +                     [{alias,explicit_unalias}]),
  +    Sender ! {go, AliasM},
  +    recv_msg_seq(NumMsg),
  +    {'DOWN', AliasM, process, {monitor_named_order,Node}, normal}
  +        = receive_any(),
  +    unregister(tester),
  +    unalias(AliasA),
  +    unalias(AliasM),
  +    ok.
  +
  +send_msg_seq(_, _, _, _, 0) -> ok;
  +send_msg_seq(To1, To2, To3, To4, N) ->
  +    To1 ! N,
  +    send_msg_seq(To2, To3, To4, To1, N-1).
  +
  +recv_msg_seq(0) -> ok;
  +recv_msg_seq(N) ->
  +    N = receive M -> M end,
  +    recv_msg_seq(N-1).
  +
  +receive_any() ->
  +    receive M -> M end.
  +
   
   %%
   %% -- Internal utils --------------------------------------------------------
  
positive.code:          busy_dist_down_signal/1,
           busy_dist_spawn_reply_signal/1,
           busy_dist_unlink_ack_signal/1,
           monitor_order/1]).
  
  init_per_testcase(Func, Config) when is_atom(Func), is_list(Config) ->
      [{testcase, Func}|Config].
  
negative.code:      busy_dist_down_signal,
       busy_dist_spawn_reply_signal,
       busy_dist_unlink_ack_signal,
       monitor_order,
       monitor_named_order_local,
       monitor_named_order_remote].
  
  %% Test that exit signals and messages are received in correct order
  xm_sig_order(Config) when is_list(Config) ->
      LNode = node(),
      repeat(fun (_) -> xm_sig_order_test(LNode) end, 1000),
      {ok, Peer, RNode} = ?CT_PEER(),
      repeat(fun (_) -> xm_sig_order_test(RNode) end, 1000),
      peer:stop(Peer),
      ok.
      
  