<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'><div dir='ltr'>
>From what I understand the new NIF features are intended to supercede the use of linked in drivers.<br><br>NIFS are fast to call C code, much faster than linked in drivers, but as you know they can block the scheduler if your C code does something nasty like read from a driver or sit in a loop.<br><br>I can, of course, use a NIF as an accessor to a C API that can dispatch a message to a thread in a thread pool (as you would using a linked in driver, in fact I believe the NIF threading functions are wrappers around the exisiting linked in driver functions).<br><br>What the new NIFS provide is the ability to "convert" an Erlang process into native code. Effectively you will invoke native code that will enter into its own event loop on one of the threads in the thread pool and other Erlang processes can send/receive messages to it. Basically providing an "OTP" like interface to your C code.  <br><br>Please see:<br>http://www.erlang-factory.com/upload/presentations/377/RickardGreen-NativeInterface.pdf<br><br>Matt<br><br><div><hr id="stopSpelling">Date: Sat, 15 Oct 2011 13:10:26 +0100<br>From: watson.timothy@gmail.com<br>To: joelr1@gmail.com<br>CC: erlang-questions@erlang.org<br>Subject: Re: [erlang-questions] New NIF behavior in R15???<br><br>Sure I get that it's possible but as I said, I've not used NIFs yet and from reading the documentation you'd expect that the *expected* thing to do with a NIFs is keep it bound to the calling process and use it for fast synchronous calls, whereas linked-in drivers provide an explicit API for executing tasks asynchronously. <br>
<br><div class="ecxgmail_quote">On 15 October 2011 12:59, Joel Reymont <span dir="ltr"><<a href="mailto:joelr1@gmail.com">joelr1@gmail.com</a>></span> wrote:<br><blockquote class="ecxgmail_quote" style="border-left:1px #ccc solid;padding-left:1ex">
<div class="ecxim"><br>
On Oct 15, 2011, at 12:27 PM, Tim Watson wrote:<br>
<br>
> I was under the impression that linked-in drivers are the way to go if you want to avoid blocking the emulator whilst potentially long running tasks execute.<br>
<br>
</div>What is preventing you from using a queue to talk to your NIF?<br>
<br>
You can then spawn as many threads as you like in your C code to avoid blocking the emulator.<br>
<br>
--------------------------------------------------------------------------<br>
- for hire: mac osx device driver ninja, kernel extensions and usb drivers<br>
---------------------+------------+---------------------------------------<br>
<a href="http://wagerlabs.com" target="_blank">http://wagerlabs.com</a> | @wagerlabs | <a href="http://www.linkedin.com/in/joelreymont" target="_blank">http://www.linkedin.com/in/joelreymont</a><br>
---------------------+------------+---------------------------------------<br>
<br>
</blockquote></div><br>
<br>_______________________________________________
erlang-questions mailing list
erlang-questions@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions</div>                                           </div></body>
</html>