原文:http://www.cnblogs.com/hanyan225/archive/2010/10/20/1857040.html
異步通知:一旦設備準備好,就主動通知應用程序,這種情況下應用程序就不需要查詢設備狀態。
阻塞I/O意味着一直等待設備可訪問再訪問,非阻塞I/O意味着使用poll()函數來查詢是否可訪問,而異步通知則意味着設備通知應用程序自身可訪問。
AIO:Asynchronous Input/Output異步輸入/輸出,基本思想是允許進程發起很多的I/O操作,而不用阻塞或等待任何操作的完成,稍後或在接收到I/O操作完成的通知時,進程就可以檢索I/O操作的結果。每個操作需要有一個唯一的上下文,這樣才能在它們完成時區分到底是哪個傳輸操作完成了。在AIO中,通過aiocb(AIO IO control block)結構體進行區分。
struct aiocb {
int aio_fildes; /* File descriptor */
off_t aio_offset; /* File offset */
volatile void * aio_buf; /* Location of buffer */
size_t aio_nbytes; /* Length of transfer */
int aio_reqprio; /* Request priority offset */
struct sigevent aio_sigevent; /* Signal number and value */
int aio_lio_opcode; /* Operation to be performed */
};
kiocb描述符用來跟蹤正在運行的同步和異步I/O操作的完成狀態。