[PATCH] Initialize IO_STATUS_BLOCK for pread, pwrite

Mark Geisert mark@maxrnd.com
Sat Dec 2 22:32:00 GMT 2017


On Sat, 2 Dec 2017, Corinna Vinschen wrote:
> On Dec  1 13:46, Mark Geisert wrote:
>> I'm open to using overlapped I/O for the usual read & write cases of aio but
>> there are some extensions I have in mind that don't allow for overlapped so
>> I think I need to have threads handle them.  I might combine the two.
>
> I'm just a bit concerned in terms of calling lots of aio_read/write at
> the same time or lio_listio with lots of entries.  One thread for each
> entry?

No, first use of aio_* or lio_* causes a pool of AIO_MAX worker threads to 
be created.  The actual request(s) is/are placed on a FIFO queue.  Each 
enqueue bumps a semaphore to wake up a worker thread to dequeue and 
process a request.  More requests than threads?  It's OK, requests are
queued until there's a worker thread available to field it.

>> Using
>> overlapped for the common case would, I think, allow me to reduce the number
>> of worker threads hanging around.  Thanks for the input!
>
> I wonder if APCs are the way to go for this use case.  As you might
> know, Nt{Read,Write}File provide a way to specify an APC routine and a
> APC context pointer (struct aiocb *?), so instead of waiting actively
> for the event, you could just lean back and wait for the APC routine to
> be called.
>
> As a sidenote, I think we could use APCs in other scenarios, too, but
> somehow we never got around to it.

Good points.  Requires a little architecting.  Have to wait in an 
interruptible wait.  Hmm.  I could consider this direction too.

..mark



More information about the Cygwin-patches mailing list