Asynchronous Input and Output

team bbl


I/O operations on a file can be either synchronous or asynchronous. For synchronous I/O operations, the process calling the I/O request is blocked until the I/O operation is complete and regains control of execution only when the request is completely satisfied or fails. For asynchronous I/O operations, the process calling the I/O request immediately regains control of execution after the I/O operation is queued to the device. When the I/O operation is completed (either successfully or unsuccessfully), the calling process can be notified of the event by a signal passed through the io control block structure for the asynchronous I/O function. Alternatively, the calling process can poll the io control block structure for completion status.

Asynchronous I/O permits efficient overlap of CPU and I/O processing, which can dramatically increase the performance of demanding applications.

Using Asynchronous I/O

Asynchronous I/O is most commonly used in real-time applications requiring high-speed or high-volume data collection or low-priority journaling functions. Compute-intensive processes can use asynchronous I/O instead of blocking. For example, an application can collect intermittent data from multiple channels. Because the data arrives asynchronouslythat is, when it is available rather than according to a set schedulethe receiving process must queue up the request to read data from one channel and immediately be free to receive the next data transmission from another channel. Another application might require such a high volume of reads, writes, and computations that it becomes practical to queue up a list of I/O operation requests and continue processing while the I/O requests are being serviced. Applications can perform multiple I/O operations to multiple devices while making a minimum number of function calls.

You can perform asynchronous I/O operations using any open file descriptor.

Asynchronous I/O Functions

The asynchronous I/O functions combine a number of tasks normally performed by the user during synchronous I/O operations. With synchronous I/O, the application typically calls the lseek function, performs the I/O operation, and then waits to receive the return status.

Asynchronous I/O functions provide the following capabilities:

  • Both regular and special files can handle I/O requests.

  • One file descriptor can handle multiple read and write operations.

  • Multiple read and write operations can be issued to multiple open file descriptors.

  • Both sequential and random access devices can handle I/O requests.

  • Outstanding I/O requests can be canceled.

  • The process can be suspended to wait for I/O completion.

  • I/O requests can be tracked when the request is queued, in progress, and completed.

The following functions perform and manage asynchronous I/O operations:

Function

Description

aio_cancel

Cancels one or more requests pending against a file descriptor.

aio_error

Returns the error status of a specified operation.

aio_fsync

Asynchronously writes system buffers containing a file's modified data to permanent storage.

aio_read

Initiates a read request on the specified file descriptor.

aio_return

Returns the status of a completed operation.

aio_suspend

Suspends the calling process until at least one of the specified requests has completed.

aio_write

Initiates a write request to the specified file descriptor.

lio_listio

Initiates a list of requests.


    team bbl



    Performance Tuning for Linux Servers
    Performance Tuning for Linux Servers
    ISBN: 0137136285
    EAN: 2147483647
    Year: 2006
    Pages: 254

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net