如果有的话,Erlang 进程如何映射到内核线程? [英] How, if at all, do Erlang Processes map to Kernel Threads?

查看:23
本文介绍了如果有的话,Erlang 进程如何映射到内核线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Erlang 以能够支持许多轻量级进程而闻名;它可以这样做,因为这些不是传统意义上的进程,甚至不是 P 线程中的线程,而是完全在用户空间中的线程.

Erlang is known for being able to support MANY lightweight processes; it can do this because these are not processes in the traditional sense, or even threads like in P-threads, but threads entirely in user space.

这很好(实际上很棒).但是 Erlang 线程如何在多核/多处理器环境中并行执行呢?当然,它们必须以某种方式映射到内核线程才能在单独的内核上执行吗?

This is well and good (fantastic actually). But how then are Erlang threads executed in parallel in a multicore/multiprocessor environment? Surely they have to somehow be mapped to kernel threads in order to be executed on separate cores?

假设是这样,这是如何完成的?许多轻量级进程是否映射到单个内核线程?

Assuming that that's the case, how is this done? Are many lightweight processes mapped to a single kernel thread?

或者有其他方法可以解决这个问题吗?

Or is there another way around this problem?

推荐答案

答案取决于所使用的 VM:

Answer depends on the VM which is used:

1) non-SMP:有一个调度程序(操作系统线程),它执行所有 Erlang 进程,取自可运行进程池strong>(即那些没有被例如 receive 阻止的)

1) non-SMP: There is one scheduler (OS thread), which executes all Erlang processes, taken from the pool of runnable processes (i.e. those who are not blocked by e.g. receive)

2) SMP:有K个调度器(OS线程,K通常是CPU核数),从共享进程执行Erlang进程队列.它是一个简单的 FIFO 队列(带有锁以允许多个 OS 线程同时访问).

2) SMP: There are K schedulers (OS threads, K is usually a number of CPU cores), which executes Erlang processes from the shared process queue. It is a simple FIFO queue (with locks to allow simultaneous access from multiple OS threads).

3) R13B 和更新版本中的 SMP:将有 K 个调度程序(和以前一样)从多个进程队列中执行 Erlang 进程.每个调度程序都有自己的队列,因此将添加从一个调度程序到另一个调度程序的进程迁移逻辑.此解决方案将通过避免共享进程队列中的过度锁定来提高性能.

3) SMP in R13B and newer: There will be K schedulers (as before) which executes Erlang processes from multiple process queues. Each scheduler has it's own queue, so process migration logic from one scheduler to another will be added. This solution will improve performance by avoiding excessive locking in shared process queue.

有关详细信息,请参阅由爱立信 AB 的 Kenneth Lundin 编写的本文档,Erlang 用户大会,斯德哥尔摩,2008 年 11 月 13 日.

For more information see this document prepared by Kenneth Lundin, Ericsson AB, for Erlang User Conference, Stockholm, November 13, 2008.

这篇关于如果有的话,Erlang 进程如何映射到内核线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆