<div dir="ltr"><div>Hello,<br><br></div><div>Thanks a lot for your response.<br><br></div><div>Silviu<br></div><div><br></div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 7, 2016 at 10:57 AM, Lukas Larsson <span dir="ltr"><<a href="mailto:lukas@erlang.org" target="_blank">lukas@erlang.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello,<br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Tue, Dec 6, 2016 at 9:56 PM, Caragea Silviu <span dir="ltr"><<a href="mailto:silviu.cpp@gmail.com" target="_blank">silviu.cpp@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div><div><div><br></div></div>From what I know the NIF is the fastest way to call c/c++ code from erlang. The disadvantage is that you need to return in under 1 ms in order to make sure the schedulers are not affected.<br><br></div>using erl_driver and  port_control is not the same ? because based on the documentation this is a sync call that blocks scheduler until the native method returns. <br></div></div></div></blockquote><div><br></div></span><div>The same ~1 ms limit exists for port callbacks as nif function calls.</div><div><br></div><div>For some reason there is a rumor circling around that you somehow circumvent the limit if you convert your nif code to a linked-in driver. This is not the case. The only thing you do by converting the code from a nif to linked-in driver is gain access to more tools to partitions the work (mostly driver_select[1], but also some other things like the async thread pool), and you possibly make some of the problems that long running native code can cause less likely.</div><div><br></div><div>Lukas</div><div><br></div><div>1: Soon this limit will be removed by the inclusion of enif_select, <a href="https://github.com/erlang/otp/pull/1264" target="_blank">https://github.<wbr>com/erlang/otp/pull/1264</a></div></div></div></div>
</blockquote></div><br></div>