Re: Q for the standards gurus...

Richard Henderson (
Mon, 12 May 1997 08:55:32 -0500 (CDT)

> iodone(char *buf, int len, int retval)
> {
> if (retval == -1) {
> fprintf(stderr, "I/O on buffer %x for %d failed: %d\n",
> buf, len, retval);
> } else if (retval < len) {
> fprintf(stderr, "I/O on buffer %x wanted %d got %d\n",
> buf, len, retval);
> } /* else success */
> free(buf);
> }
> char *buf = valloc(SIZE);
> reada(fd, buf, SIZE, iodone);
> /* do some other useful work */
> Is that what you meant?

I'm fairly sure that's what he meant -- at least that's what I
read out of it too. (Though I would also pass along a void* for
the callback routine so that it can avoid searching for some struct,
and retval would be -ERROR as usual.)

The thing that has always bothered me about the threaded userland
approach is that the new thread requires a stack. With this
approach, we consume minimal resources as well as already being in
the right place to issue the signal for the i/o completion.

Anyway, it got me thinking enough to actually start on posix.4
signals (yeah, my book is a bit behind ;-), so that those would
be ready for whichever method is used for aio.