原创作者: mryufeng
阅读:1102次
评论:0条
更新时间:2011-06-01
erlang能够利用多核心的优势不仅体现在多线程的smp调度器,更在port上面上体现。通过执行外部程序,接管它的输入输出, 实现了安全性和充分利用cpu计算资源。
erlang的io设计体现了unix一切以文件为中心的思想。在port设计上也是.这3个驱动程序都是把相关的东西转化成文件句柄,登记到poll上面,利用强大的IO poll来实现上层语义的整合。
ErlDrvEntry spawn_driver_entry;
{spawn, Command}
Starts an external program. Command is the name of the external program which will be run. Command runs outside the Erlang work space unless an Erlang driver with the name Command is found. If found, that driver will be started. A driver runs in the Erlang workspace, which means that it is linked with the Erlang runtime system.
When starting external programs on Solaris, the system call vfork is used in preference to fork for performance reasons, although it has a history of being less robust. If there are problems with using vfork, setting the environment variable ERL_NO_VFORK to any value will cause fork to be used instead.
ErlDrvEntry fd_driver_entry;
{fd, In, Out}
Allows an Erlang process to access any currently opened file descriptors used by Erlang. The file descriptor In can be used for standard input, and the file descriptor Out for standard output. It is only used for various servers in the Erlang operating system (shell and user). Hence, its use is very limited.
ErlDrvEntry vanilla_driver_entry;
官方没有文档。它的作用是直接打开文件进行读写。
erlang的io设计体现了unix一切以文件为中心的思想。在port设计上也是.这3个驱动程序都是把相关的东西转化成文件句柄,登记到poll上面,利用强大的IO poll来实现上层语义的整合。
ErlDrvEntry spawn_driver_entry;
{spawn, Command}
Starts an external program. Command is the name of the external program which will be run. Command runs outside the Erlang work space unless an Erlang driver with the name Command is found. If found, that driver will be started. A driver runs in the Erlang workspace, which means that it is linked with the Erlang runtime system.
When starting external programs on Solaris, the system call vfork is used in preference to fork for performance reasons, although it has a history of being less robust. If there are problems with using vfork, setting the environment variable ERL_NO_VFORK to any value will cause fork to be used instead.
ErlDrvEntry fd_driver_entry;
{fd, In, Out}
Allows an Erlang process to access any currently opened file descriptors used by Erlang. The file descriptor In can be used for standard input, and the file descriptor Out for standard output. It is only used for various servers in the Erlang operating system (shell and user). Hence, its use is very limited.
ErlDrvEntry vanilla_driver_entry;
官方没有文档。它的作用是直接打开文件进行读写。
评论 共 0 条 请登录后发表评论