[erlang-questions] driver asyncronous notifications

Oscar Hellström oscar@REDACTED
Fri Jun 1 13:08:41 CEST 2007


Serge Aleynikov wrote:
> Oscar Hellström wrote:
>>>   
>> Could you use a pipe here to notify the emulator of the event?
> 
> Indeed I described that solution in the previous email as well:
> 
> <quote>
>  >> One possibility is to create a pipe and
>  >> register a read-end of the pipe with Erlang's select loop by calling
>  >> driver_select() function, and use write() call on the other end of
>  >> the pine from another thread to communicate some activity, so that if
>  >> would trigger the ready_input() driver's callback in the context of
>  >> emulator's thread.  However this is a very expensive solution which I
>  >> wouldn't want to use.
> </quote>

I should really learn to think before I speak as well as read before I 
reply...

> The problem here is that pipe is a very expensive way of doing 
> inter-thread communications.  I implemented this approach and wasn't 
> happy with performance (that involved two context switches and an 
> expensive select() call for messages communicated to the emulator's 
> thread).  I wish that there was something much more light-weight to 
> notify emulator's thread of an external non I/O related event.

Have you compared the performance loss to that of a port driver? A port 
driver would also have to communicate through a pipe, but the 
synchronisation issues should be gone. Also, the emulator should be able 
to use kernel polling the fd:s I guess.

<snip>

Best Regards
-- 
Oscar Hellström, oscar@REDACTED
Erlang Training and Consulting
http://www.erlang-consulting.com/



More information about the erlang-questions mailing list