What kind of virtual machine is BEAM (the Erlang VM)?

三世轮回 提交于 2019-11-27 10:03:01
rvirding

The Erlang VM runs as one OS process. By default it runs one OS thread per core to achieve maximum utilisation of the machine. The number of threads and on which cores they run can be set when the VM is started.

Erlang processes are implemented entirely by the Erlang VM and have no connection to either OS processes or OS threads. So even if you are running an Erlang system of over one million processes it is still only one OS process and one thread per core. So in this sense the Erlang VM is a "process virtual machine" while the Erlang system itself very much behaves like an OS and Erlang processes have very similar properties to OS processes, for example isolation. There is actually an Erlang VM, based on the BEAM, which runs on bare metal and is in fact an OS in its own right, see Erlang on Xen.

By the way, it is perfectly possible to have systems running millions of Erlang processes and it is actually done in some products, for example WhatsApp.

We were definitely thinking very much about OSes when we designed the basic Erlang environment.

Virtual machine is a computing system. The ultimate goal of a computing system is to execute programmed logic. From this perspective, virtual machines can be categorized into 4 types according to the level of abstraction and scope of emulation:

Type 1: Full Instruction Set Architecture (ISA) virtual machine provides a full computer system's ISA emulation or virtualization. Guest operating systems and applications can run on the top of the virtual machine as an actual computer (e.g.,VirtualBox,QEMU,XEN).

Type 2: Application Binary Interface (ABI) virtual machine provides a guest process ABI emulation. Applications against that ABI can run in the process side by side with other processes of native ABI applications (e.g.,Intel's IA-32 Execution Layer on Itanium, Transmeta's Code Morphing for X86 emulation, Apple's Rosetta translation layer for PowerPC emulation).

Type 3: Virtual ISA virtual machine provides a runtime engine so that applications coded in the virtual ISA can execute on it. Virtual ISA usually defines a high level and limited scope of ISA semantics, so it does not require the virtual machine to emulate a full computer system (e.g.,Sun Microsystem's JVM, Microsoft's Common Language Runtime, Parrot Foundation's Parrot virtual machine).

Type 4: Language Virtual Machine provides a runtime engine that executes programs expressed in a guest language. The programs are usually presented to the virtual machine in source form of the guest language, without being fully compiled into machine code beforehand. The runtime engine needs to interpret or translate the program and also fulfill certain functionalities that are abstracted by the language such as memory management (e.g., the runtime engines for Basic, Lisp, Tcl, Ruby).

The boundaries between virtual machine types are not clear-cut. For example, a language virtual machine can also employ the technique of a virtual ISA virtual machine by compiling the program into a kind of virtual ISA and then executing the code on a virtual machine of that virtual ISA.

Many VM designs, such as BEAM, crossing the boundaries. They could be fit into both 3rd and 4th categories.

source:

  1. Wikipedia
  2. Advanced Design and Implementation of Virtual Machines; Xlao-Feng LI

I assume that you've been reading http://en.wikipedia.org/wiki/Virtual_machine - under that terminology, BEAM is a "process virtual machine", just like the JVM.

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