[erlang-questions] Nif and driver callbacks

Mikael Karlsson karlsson.rm@REDACTED
Thu May 23 15:54:22 CEST 2019


Hi,
I just started to write some nif code to interface towards a Linux driver
API.
I can install a callback function in my nif module that gets called from
the driver  whenever it is ready to receive new data. Currently it gets
called every 5 ms. The callback function sends a message to an erlang
process that in turn delivers new data to the driver. (Using another nif
function).

This works, although I am a bit puzzled how, since the callback function
that is called from the linux driver appearantly is running outside the
Erlang VM and still is able to send a message to the erlang process. Could
anyone explain how this works?

Also when loaded with a lot of data I am not capable of delivering in time
(5 ms) unless I set the process_flag(priority, high). I noticed there is a
enif_select function that I can use instead but this also sends a message
to an erlang process so I am not sure if there is any timing difference
between using enif_select or sending an erlang message directly from a
driver callback?

Thanks,
Mikael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190523/6e81c516/attachment.htm>


More information about the erlang-questions mailing list