erlang message passing architecture

。_饼干妹妹 提交于 2019-11-29 15:17:07

Message receiving is an atomic operation.

If you are interested how it is done, read the source code of VM. If I simplify it, the sending process is doing those steps:

  1. Allocate a target memory space in the sending process (it's called environment).
  2. Copy the message to that memory space
  3. Take the external lock on the target process
  4. Link message into the mailbox linked list
  5. Release the external lock on the target process

As you can see, copying is done outside (before) critical section and the critical section is pretty fast. It is just juggling with few pointers.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!