[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
POSIX Async IO (GSoC)
- Date: Thu, 3 Apr 2008 18:19:02 +0800
- From: cquark at gmail.com (Wei Shen)
- Subject: POSIX Async IO (GSoC)
Just to correct some errors of the previous mail, and extended it with a few
> On 4/3/08, Wei Shen <cquark at gmail.com> wrote:
I studied the implementation of Glibc. Below I list some elementary
implementation thoughts. Comments are solicited.
Seems that AIO is not so simple a task as I have thought, especially in
(1) should support priority (defined by aiocb.aio_reqprio) based AIO request
This can be realized by: a) using one task queue for each priority level or
linking the tasks having the same priority; b) inserting a new task to the
right position in the queue according to its priority (O(lgN) time
(2) aio_cancel should support cancel all the AIO tasks on a FD.
This implies a task queue for each FD or another linklist to link the
tasks on the same FD, otherwise this call would be time-consuming.
(3) Do we need to consider optimization at task selection from a task queue.
For example if there is a task on one FD still in processing, then we
consider first tasks of other FDs. Glibc seems to use one worker thread for
We also need to support two kinds of notification - signal (SIGEV_SIGNAL)
and callback (SIGEV_THREAD), immediate stutus query (aio_error), and
blocking on an AIO task (aio_suspend).
It would be useful to abstract a general task pool that supports various
async tasks besides AIO. Such a task pool should include:
(1) a number of task queues, and an interface for users to create and
locates a task queue - based on a specific attribute or link tasks according
to their attributes (e.g. FD attribute of AIO tasks).
(2) user defined task processing handlers (one hander per pool, per task
queue, or per task?), and completion notification per task (maybe better to
leave this to the handler)?
For the case of AIO, sharing one handler in the whole pool is enough.
(3) priority based task scheduling.
(4) task enqueuing, canceling (matching by specific attributes), status
query, blocked waiting.
In summary, an efficient algorithm and data-structures to support task
enqueue/dequeue, scheduling, search and sort, assignment and concurrent
(5) resource management/configuration/accounting
a) max number of worker threads, thread stack size, thread priority;
b) max number of active task queues in the pool;
c) max number of tasks in the pool or in each queue;
d) dynamic adjustment of worker threads.
So, quite a little work to build a good solution ...
-------------- next part --------------
An HTML attachment was scrubbed...