aio_read
Section: C Library Functions (3)
Updated: 2026-02-08
Index
JM Home Page
roff page
名前
aio_read - 非同期で読み込む
ライブラリ
リアルタイムライブラリ (librt,~-lrt)
書式
#include <aio.h>
int aio_read(struct aiocb *aiocbp);
説明
aio_read() 関数は、aiocbp が指すバッファーに記載された I/O リクエストを
キューに入れる。この関数は read(2) の非同期版である。
呼び出し
read(fd, buf, count)
の各引数は aiocb が指す構造体の aio_fildes, aio_buf, aio_nbytes
に (この順序で) 対応する (aiocb 構造体の説明は aio(7) を参照)。
データの読み込みは、ファイルオフセットに関係なく、絶対位置 aiocbp->aio_offset
を開始点として行われる。呼び出しの後のファイルオフセットは規定されていない。
The "asynchronous" means that this call returns as soon as the request has
been enqueued; the read may or may not have completed when the call
returns. One tests for completion using aio_error(3). The return status
of a completed I/O operation can be obtained by aio_return(3).
Asynchronous notification of I/O completion can be obtained by setting
aiocbp->aio_sigevent appropriately; see sigevent(3type) for
details.
_POSIX_PRIORITIZED_IO が定義されていて、 かつファイルがこれをサポートしている場合、
非同期操作は呼び出したプロセスの優先度から aiocbp->aio_reqprio を引いた優先度で登録 (submit) される。
フィールド aiocbp->aio_lio_opcode は無視される。
最大オフセットを超えた通常のファイルからは、何もデータが読み込まれない。
返り値
On success, 0 is returned. On error, the request is not enqueued, -1 is
returned, and errno is set to indicate the error. If an error is
detected only later, it will be reported via aio_return(3) (returns
status -1) and aio_error(3) (error status---whatever one would have
gotten in errno, such as EBADF).
エラー
- EAGAIN
-
リソースが足りない。
- EBADF
-
aio_fildes は読み込みのためにオープンされた有効なファイルディスクリプターでない。
- EINVAL
-
aio_offset, aio_reqprio, aio_nbytes のうち 1 つ以上が無効である。
- ENOSYS
-
aio_read() は実装されていない。
- EOVERFLOW
-
ファイルが通常のファイルであり、 ファイルの終端の前から読み込みを開始して、 少なくとも 1 バイトを読み込もうとした。
しかし開始位置がこのファイルの最大オフセットを超えていた。
属性
この節で使用されている用語の説明については、 attributes(7) を参照。
| インターフェース | 属性 | 値
|
|
aio_read()
| Thread safety | MT-Safe
|
標準規格
POSIX.1-2008.
歴史
glibc 2.1. POSIX.1-2001.
注意
使用する前に制御ブロックを 0 にしておくのは、よい考えである。 この制御ブロックは、読み込み操作が進行している間は変更すべきでない。
読み込まれるバッファー領域は 操作の最中にアクセスすべきではない。 さもないと起こる結果が不定になる。
これに含まれるメモリー領域は、有効なままにしなければならない。
同じ aiocb 構造体を指定して同時に複数の I/O 操作を行った場合、
どのような結果になるかは不定である。
例
aio(7) を参照。
関連項目
aio_cancel(3), aio_error(3), aio_fsync(3), aio_return(3),
aio_suspend(3), aio_write(3), lio_listio(3), aio(7)
Index
- 名前
-
- ライブラリ
-
- 書式
-
- 説明
-
- 返り値
-
- エラー
-
- 属性
-
- 標準規格
-
- 歴史
-
- 注意
-
- 例
-
- 関連項目
-
This document was created by
man2html,
using the manual pages.