<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Sep 9, 2014 at 12:40 PM, Max Lapshin <span dir="ltr"><<a href="mailto:max.lapshin@gmail.com" target="_blank">max.lapshin@gmail.com</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"><div class="gmail_extra">I need to send binary to driver, do some  VERY cpu consumptive job with it (transcoding video) and return back.</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">I was trying to use dirty NIFs, but it seems to be very unstable: after several hours of work whole erlang machine becomes very, very slowly without any CPU usage.</div></div></blockquote><div><br></div><div>I'm very interested in seeing an example of this.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra">Now I try to migrate to erl drivers, but I've got new problem: I don't understand how to get zerocopy from erlang level to C level. <br></div></div></blockquote><div><br></div><div>Pass your data to the driver via port_command, as Lukas suggested. Implement the outputv callback and call driver_enqv to enqueue the incoming ErlIOVec argument into your driver queue. This won't copy. Also, since async threads are involved for doing the work, use the port data lock to protect the queue, as Lukas suggested.</div><div><br></div><div>--steve</div></div></div></div>