Asynchronous File I/O on Linux
Richard Pieri
richard.pieri-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Sun May 16 17:35:45 EDT 2010
On May 16, 2010, at 2:30 PM, Mark Woodward wrote:
>
> While I can see your point, it would be impossible to do multiple simultaneous requests without some sort of asynchronous I/O capability. The "random access" aspect of it comes out of using multiple file handles to a single file.
Not true. read() and friends usually block until the read completes or an error occurs. If you open() a file with O_NONBLOCK then the read() call returns an error if there is nothing ready to be read. This gets you nowhere near parallel reads, but it does get you a polling loop that chews up CPU while effectively blocking your program anyway.
> Besides, you probably mean O_RDWR or O_RDONLY, O_WRONLY won't work in your example.
Probably. :)
--Rich P.
More information about the Discuss
mailing list