VirtualBox

Changeset 19125 in vbox for trunk/include/iprt


Ignore:
Timestamp:
Apr 22, 2009 10:46:25 PM (16 years ago)
Author:
vboxsync
Message:

Runtime/Aio: Add description for the RT File async I/O API

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/file.h

    r19039 r19125  
    767767/** @page pg_rt_asyncio RT File async I/O API
    768768 *
    769  * @todo Write something
     769 * File operations are usually blocking the calling thread until
     770 * they completed making it impossible to let the thread do anything
     771 * else inbetween.
     772 * The RT File async I/O API provides an easy and efficient way to
     773 * access files asynchronously using the native facilities provided
     774 * by each operating system.
     775 *
     776 * There are two objects used in this API.
     777 * The first object is the request. A request contains every information
     778 * needed two complete the file operation successfully like the start offset
     779 * and pointer to the source or destination buffer.
     780 * Requests are created with RTFileAioReqCreate() and destroyed with
     781 * RTFileAioReqDestroy().
     782 * Because creating a request may require allocating various operating
     783 * system dependent ressources and may be quite expensive it is possible
     784 * to use a request more than once to save CPU cycles.
     785 * A request is constructed with either RTFileAioReqPrepareRead()
     786 * which will set up a request to read from the given file or
     787 * RTFileAioReqPrepareWrite() which will write to a given file.
     788 *
     789 * The second object is the context. Requests are associated with a context
     790 * during RTFileAioCtxSubmit() which will also submit the requests to the
     791 * operating system.
     792 * RTFileAioCtxWait() is used to wait for completion of requests which were
     793 * associated with the context. While waiting for requests the thread can not
     794 * respond to global state changes. Thatswhy the API provides a way to let
     795 * RTFileAioCtxWait() return immediately no matter how many requests
     796 * have finished through RTFileAioCtxWakeup(). The return code is
     797 * VERR_INTERRUPTED to let the thread know that he got interrupted.
     798 *
     799 * Threading:
     800 *
     801 * The API is a thin wrapper around the specific host OS APIs and therefore
     802 * relies on the thread safety of the underlying API.
     803 * The interesting functions with regards to thread safety are RTFileAioCtxSubmit()
     804 * and RTFileAioCtxWait(). RTFileAioCtxWait() must not be called from different
     805 * threads at the same time with the same context handle. The same applies to
     806 * RTFileAioCtxSubmit(). However it is possible to submit new requests from a different
     807 * thread while waiting for completed requests on another thread with RTFileAioCtxWait().
     808 *
     809 * Differences in implementation:
     810 * Because the host APIs are quite different on every OS and every API has other limitations
     811 * there are some things to consider to make the code as portable as possible.
     812 *
     813 * The only restriction at the moment is that every buffer has to be aligned to a 512 byte boundary.
     814 * This limitation comes from the Linux io_* interface. To use the interface the file
     815 * must be opened with O_DIRECT. This flag disables the kernel cache too which may
     816 * degrade performance but is unfortunately the only way to make asynchronous
     817 * I/O work till today (if O_DIRECT is omitted io_submit will revert to sychronous behavior
     818 * and will return when the requests finished and when they are queued).
     819 * It is mostly used by DBMS which do theire own caching.
     820 * Furthermore there is no filesystem independent way to discover the restrictions at least
     821 * for the 2.4 kernel series. Since 2.6 the 512 byte boundary seems to be used by all
     822 * file systems. So Linus comment about this flag is comprehensible but Linux
     823 * lacks an alternative at the moment.
    770824 */
    771825
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette