![]() |
|
||||
POSIX 1.b Migration Guide |
Asynchronous I/O
Changes in asynchronous I/O features center primarily around reordered data structure entries and function parameters. In addition, POSIX.1b introduces a new idea of asynchronous I/O priority. The priority of an asynchronous I/O operation can be lowered, but not raised, with respect to the process scheduling priority.
Refer to "Changes from Draft 9 to POSIX.1b" for a comparison of data structures and flags specific to asynchronous I/O.
Data Structure Changes
The aiocb data structure changed has significantly. Because of these changes, the liocb data structure has been eliminated. The following is a comparison of the aiocb data structures for Draft 9 and POSIX.1b.
aiocb Structure No Equivalent (always SEEK_SET) No Equivalent No Equivalent No Equivalent No Equivalent No Equivalent No Equivalent No EquivalentPOSIX.1b structure includes the file descriptor, buffer, and listio opcode fields. The new aio_nbytes field has the same semantics as defined by the read() and write() synopses.
As a result, the synopses for the asynchronous I/O functions have changed
as follows:
- File descriptor, buffer, and number of bytes are not passed as separate arguments to aio_read() and aio_write().
- The listio opcode is not passed as a separate argument to lio_listio().
- The aio_whence field has been eliminated. The aio_offset argument is treated as offset from the beginning of the file. The effect is as if aio_whence is always SEEK_SET.
- The aio_errno field has been eliminated. Instead, a new function, aio_error(), with the aiocb argument does the same job.
- The aio_flag field has been eliminated. It is superseded by the aio_sigevent field.
- The afsync() function has been renamed to aio_fsync().
- The aio_nobytes field has been eliminated. The new aio_return() function retrieves the return status from an aiocb structure. aio_return() can be called exactly once per structure; this structure may not be passed to aio_error() or aio_return() again.
There is no relation between the new aio_nbytes field and the old aio_nobytes field. The aio_return() function may be used on the same aiocb structure more than once, as a proprietary extension from LynuxWorks. This can be disabled by a new proprietary library call aio_setparam(). Refer to the aio_setparam() man page for more information.
The aio_prio field from Draft 9 was unused and has been replaced with the aio_reqprio field. With this field, POSIX.1b asynchronous I/O can be queued in a priority order.
The priority of an asynchronous process is the process priority minus the aio_reqprio value. Priority of asynchronous I/O can be lowered, but not raised, with respect to the process priority. However, as a proprietary feature from LynuxWorks, the priority of an asynchronous I/O operation can be raised with respect to the process priority. This is achieved by the aio_setparam() library call, which is specific to LynxOS. Refer to the aio_setparam() man page for more information.
Asynchronous Read and Write
The following example shows a code comparison for an asynchronous write operation. Also, it shows the use of two new functions for POSIX.1b; namely, aio_return() and aio_error().
In POSIX.1b code the sa_flags flag is set to SA_SIGINFO, and the sigev_notify field is set to SIGEV_SIGNAL to ensure the use of a
real-time signal.
Draft 9 Code
Equivalent POSIX.1b Code
List Directed I/O
The following example illustrates how a Draft 9 program doing list-directed I/O can be migrated to POSIX.1b. In Draft 9, LIO_NOWAIT ignores the final event argument while LIO_ASYNC ensures a final event delivery. In POSIX.1b, LIO_NOWAIT ensures a final signal delivery on completion of the last listio job. If, however, the final signal argument is NULL, no signal is sent.
Draft 9 Code
Equivalent POSIX.1b Code
Changes from Draft 9 to POSIX.1b
All Draft 9 functionality has an equivalent in POSIX.1b, but there are differences in the data structure entries and the way parameters are passed to functions.
Data Structures
The data structure aiocb changed a lot from Draft 9 to POSIX.1b. Also, the liocb data structure has been eliminated because of the changes to aiocb.
The following is a comparison of the aiocb data structures for Draft 9
and POSIX.1b.
aiocb Structure No Equivalent No Equivalent No Equivalent No Equivalent No Equivalent No Equivalent No Equivalent No EquivalentPOSIX.1b structure includes the file descriptor, buffer, and listio opcode fields. The new aio_nbytes field has the same semantics as defined by the read() and write() synopses. Therefore, the synopses for the aio functions have changed as follows:
- File descriptor, buffer, and number of bytes are not passed as separate arguments to aio_read() and aio_write().
- listio opcode is not passed as a separate argument to lio_listio().
The aio_whence field has been eliminated. The aio_offset argument is treated as an offset from the beginning of the file. The effect is as if aio_whence is always SEEK_SET.
The aio_errno field has been eliminated. Instead, a new function, aio_error() with the aiocb argument does the same job.
The aio_flag field has been eliminated. It is superseded by the
aio_sigevent field.The aio_nobytes field has been eliminated. The new aio_return() function retrieves the return status from an aiocb structure. aio_return() can be called only once per structure; this structure may not be passed to aio_error() or aio_return() again.
There is no relation between the new aio_nbytes field and the old aio_nobytes field. The aio_return() function may be used on the same aiocb structure more than once, as a proprietary extension from LynuxWorks. This can be disabled by a new proprietary library call aio_setparam(). Refer to the aio_setparam() man page for more information.
Priority of asynchronous I/O can be lowered, but not raised, with respect to the process priority. However, a proprietary feature of LynxOS allows the priority of an asynchronous I/O operation to be raised with respect to the process priority. This is done by the aio_setparam() library call. Refer to the aio_setparam() man page for more information.
Timed Suspension
The Draft 9 iosuspend() function suspends the process until the completion
of I/O. The aio_suspend() function from POSIX.1b adds an option for timed suspension. It takes an extra timespec argument for timeout. If this argument is NULL, the behavior is the same as suspension until the completion of I/O.
Cancellation Notification
With the acancel() function from Draft 9, no event notification is given when an asynchronous I/O function is successfully cancelled. However, with the aio_cancel() function from POSIX.1b, normal signal delivery occurs for all asynchronous I/O functions that are cancelled.
listio Signal Delivery
POSIX.1b provides only two mode values as opposed to the three values from Draft 9. The LIO_ASYNC value has been removed. The LIO_NOWAIT argument ensures a final signal delivery, and is equivalent to LIO_ASYNC from Draft 9. If the final signal parameter passed to lio_listio() is NULL, a final signal is not sent. This is equivalent to the LIO_NOWAIT behavior from Draft 9.
aio_fsync()
The POSIX.1b aio_fsync() function (equivalent to the Draft 9 afsync() function) provides fsync() behavior with the O_SYNC flag, and fdatasync() behavior with the O_DSYNC flag. The difference is that for synchronized I/O file integrity completion, the O_FSYNC flag is used in Draft 9, while the O_SYNC flag is used in POSIX.1b. Refer to the synchronous I/O section for the semantics of these functions.
Interoperability
Asynchronous I/O is fully inter-operable. A process using Draft 9 asynchronous I/O is compatible with a process performing POSIX.1b asynchronous I/O to the same file.
![]() LynuxWorks, Inc. 855 Branham Lane East San Jose, CA 95138 http://www.lynuxworks.com 1.800.255.5969 |
![]() |
![]() |
![]() |
![]() |