Am 04.01.2006 um 20:40 schrieb Stephen Deasey:

On 1/4/06, Vlad Seryakov <[EMAIL PROTECTED]> wrote:
I believe poll can be used on any file descriptor, not only sockets.


It doesn't work if the file descriptor is backed by a file on disk.
If it did, we wouldn't have to talk about aio_read()    :-)



Hmmm...

SYNOPSIS
     #include <poll.h>

     int
     poll(struct pollfd *fds, nfds_t nfds, int timeout);

DESCRIPTION
Poll() examines a set of file descriptors to see if some of them are ready for I/O or if certain events have occurred on them. The fds argu- ment is a pointer to an array of pollfd structures as defined in <poll.h> (shown below). The nfds argument determines the size of the fds array.

I believe that poll should work with files as well. That is I can't
find no reason why it shoudn't by reading the man and inspecting
the "poll" emulation we have in nsd/unix.c. Tcl also uses the similar
machinery to implement non-blocking read/write to files (see below).

The AIO comes into place where you basically have one more layer
of processing in the kernel which handles your dispatched events
and let you asynchronously inspect them, cancel them etc.

So: poll + tcl_event_loop *= AIO. Unfortunately this works only
for single-threaded apps as tcl_event_loop only handles events
from the current thread. Roughly. As AIO is normally done by the
kernel it is/shouldbe much more faster.
One can always simulate the aio by a specialized thread and non-blocking
read/writing. But having this all done for you in the kernel (as
in some "proper" implementation) things should be simpler to implement
and faster in deployment.

Cheers
Zoran

Reply via email to