[erlang-questions] Opening "Special" Files

Ciprian Dorin, Craciun ciprian.craciun@REDACTED
Wed Aug 26 17:23:40 CEST 2009


On Wed, Aug 26, 2009 at 4:30 AM, Jayson Vantuyl<kagato@REDACTED> wrote:
> Isn't this prevented by the asynchronous I/O threading stuff (erl +A NNN)?
>  I'm unsure why a block device would be that different than a file in that
> case.  Both create a potentially random seek and both mitigate this with
> cache.
>
> On Aug 25, 2009, at 6:22 PM, Mark Wagner wrote:
>>
>> My understanding based on discussions on the mailing list is that this
>> is an effort to avoid blocking I/O: a OS-level block on read or write
>> would result in all Erlang-level threads managed by the current
>> process being suspended until the I/O completes or times out.
>
> --
> Jayson Vantuyl
> kagato@REDACTED

    Indeed earlier (this year or last one) there was a similar
discussion on the mailing list... And the result was as Mark pointed,
that for a regular file there is no risk of having the read or write
operation stall...

    Unfortunately I must say that this protection is not
bullet-proof... For example I've played a lot with FUSE (File System
in User Space), and it is very easy to create virtual regular files,
for which read or write could stall...

    As a conclusion, I would propose to allow the user to specify a
flag that would force OTP (at the risk of the user) to open any file.
(Of course I don't think such a thing would be implemented...)

    So if you really want to be able to open any kind of file from
Erlang (I mean here block devices, character devices, fifo's, unix
domain sockets, etc.) You could just implement a simple FUSE
application in C to wrap the file system (this would be reusable for
other projects with similar problems)... (Or as you've said write a
port-like process or driver...)

    Ciprian Craciun.


More information about the erlang-questions mailing list