erlang内置的port相关的驱动程序

erlang能够利用多核心的优势不仅体现在多线程的smp调度器,更在port上面上体现。通过执行外部程序,接管它的输入输出, 实现了安全性和充分利用cpu计算资源。

erlang的io设计体现了unix一切以文件为中心的思想。在port设计上也是.这3个驱动程序都是把相关的东西转化成文件句柄,登记到poll上面,利用强大的IO poll来实现上层语义的整合。

[color=red]
ErlDrvEntry spawn_driver_entry;[/color]

{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.

[color=red]ErlDrvEntry fd_driver_entry;[/color]

{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.

[color=red]ErlDrvEntry vanilla_driver_entry;[/color]

官方没有文档。它的作用是直接打开文件进行读写。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值