[erlang-questions] What API should be used in port-drivers to guarantee thread-safety of driver_send_term and driver_output_term?

Zhemzhitsky Sergey <>
Wed Sep 5 17:18:37 CEST 2012


Hi erlang gurus,

We’re developing erlang port driver that will send different terms to some processes from the separate threads using driver_send_term.
Each native thread started in the port driver (by means of erl_drv_thread_create) will be associated with only one erlang process and will send messages only to it.

As a rule the documentation for driver_send_term says that it’s not thread-safe when smp is disabled, so we have tested the driver with disabled smp support and found that from time to time it leads to segfaults.

So, the question is what is the proper way to make calls to driver_send_term (and driver_output_term) thread-safe?
Will driver_pdl_lock, driver_pdl_unlock help?
Will wrapping all the calls to driver_send_term (and driver_output_term) with erl_drv_mutex_lock and erl_drv_mutex_unlock help?


Best Regards,
Sergey


_______________________________________________________

The information contained in this message may be privileged and conf idential and protected from disclosure. If you are not the original intended recipient, you are hereby notified that any review, retransmission, dissemination, or other use of, or taking of any action in reliance upon, this information is prohibited. If you have received this communication in error, please notify the sender immediately by replying to this message and delete it from your computer. Thank you for your cooperation. Troika Dialog, Russia. 
If you need assistance please contact our Contact Center  (+7495) 258 0500 or go to www.troika.ru/eng/Contacts/system.wbp  

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120905/e7935141/attachment.html>


More information about the erlang-questions mailing list