gpt4 book ai didi

multithreading - Erlang的抽象机BEAM中使用了哪些OS线程?

转载 作者:行者123 更新时间:2023-12-04 06:11:57 24 4
gpt4 key购买 nike

我已经开始研究Erlang,并发现BEAM运行时环境令人着迷。通常会说,在Erlang中,进程属于语言而不是操作系统(意味着运行时,在这种情况下意味着BEAM)。这些是Erlang闻名的轻量级“绿色过程”。进一步指出(在this paper的第5页上),BEAM使用每个CPU内核一个(1)OS线程进行调度,并使用另一个OS线程进行i/o。所以我想知道:实际执行Erlang代码所需的CPU周期是从哪个线程来的?

此外,如果我在双核计算机上运行,​​基于目前为止我所读的内容,我希望看到三(3)个线程在BEAM进程下运行:两个调度程序(每个内核一个)一个I/O线程。但是我看到的是10。有时是11。有时,它从13开始,并且像高品质放大器一样,达到11。

我很困惑。任何见识将不胜感激。

最佳答案

遵循@ user425720的建议,我在erlang问题LISTSERV上提出了我的问题。也可以作为Google Group使用。 Trifork的Kresten Krab Thorup几乎立刻回答了我。非常感谢您前往克雷斯顿(Kreston)。这是他的答案。 (美学和重点是我的。)

Here is AFAIK, the basic scenario:

Erlang code will be run in as many "green threads" as there are processes; the process limit is controlled by the +P (command line) flag.

The green threads are mapped on to S threads, where S is the number of cores/CPUs. The fact that these threads are also called schedulers can seem somewhat confusing, but from the VMs point of view they are. From the developer's point of view, they are the threads that run your erlang code. The number S can be controlled with the +S option to the erl command line.

In addition hereto, there are a number of so-called "Async Threads". That's a thread pool which is used by I/O processes called linked in drivers, to react to select / poll etc. The number of asynch threads is dynamic, but limited by the +A flag.

So, the 11 threads you see on a dual-core may be 2 schedulers, and 9 async threads. For instance.

Read more about the flags here.

关于multithreading - Erlang的抽象机BEAM中使用了哪些OS线程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3663823/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com