Changeset 99760 in vbox
- Timestamp:
- May 11, 2023 10:10:41 PM (19 months ago)
- Location:
- trunk/include/iprt
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/cpp/hardavlrange.h
r98103 r99760 43 43 44 44 /** @defgroup grp_rt_cpp_hardavl Hardened AVL Trees 45 * @ingroup grp_rt_cpp 45 46 * @{ 46 47 */ -
trunk/include/iprt/dvm.h
r99739 r99760 45 45 46 46 47 /** @defgroup grp_dvm IPRT Disk Volume Management 47 /** @defgroup grp_rt_dvm IPRT Disk Volume Management 48 * @ingroup grp_rt 48 49 * @{ 49 50 */ -
trunk/include/iprt/expreval.h
r98103 r99760 46 46 47 47 /** @defgroup grp_rt_expr_eval RTExprEval - Expression Evaluator 48 * @ingroup grp_rt 48 49 * @{ */ 49 50 -
trunk/include/iprt/file.h
r98103 r99760 1075 1075 1076 1076 1077 /** @ page pg_rt_filelock RT File locking API description1077 /** @defgroup grp_rt_fileio_locking RT File locking API 1078 1078 * 1079 1079 * File locking general rules: … … 1103 1103 * 1104 1104 * Additional reading: 1105 * http://en.wikipedia.org/wiki/File_locking 1106 * http://unixhelp.ed.ac.uk/CGI/man-cgi?fcntl+2 1107 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/lockfileex.asp 1105 * - http://en.wikipedia.org/wiki/File_locking 1106 * - http://unixhelp.ed.ac.uk/CGI/man-cgi?fcntl+2 1107 * - http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/lockfileex.asp 1108 * 1109 * @{ 1108 1110 */ 1109 1111 … … 1137 1139 /** 1138 1140 * Changes a lock type from read to write or from write to read. 1141 * 1139 1142 * The region to type change must correspond exactly to an existing locked region. 1140 1143 * If change can't be done due to locking conflict and non-blocking mode is used, error is … … 1171 1174 */ 1172 1175 RTDECL(int) RTFileUnlock(RTFILE File, int64_t offLock, uint64_t cbLock); 1176 1177 /** @} */ 1173 1178 1174 1179 … … 1441 1446 #ifdef IN_RING3 1442 1447 1443 /** @page pg_rt_asyncio RT File async I/O API 1444 * 1445 * File operations are usually blocking the calling thread until 1446 * they completed making it impossible to let the thread do anything 1447 * else in-between. 1448 * The RT File async I/O API provides an easy and efficient way to 1449 * access files asynchronously using the native facilities provided 1450 * by each operating system. 1448 /** @defgroup grp_rt_fileio_async RT File Async I/O API 1449 * 1450 * File operations are usually blocking the calling thread until they completed 1451 * making it impossible to let the thread do anything else in-between. The RT 1452 * File async I/O API provides an easy and efficient way to access files 1453 * asynchronously using the native facilities provided by each operating system. 1451 1454 * 1452 1455 * @section sec_rt_asyncio_objects Objects 1453 1456 * 1454 1457 * There are two objects used in this API. 1455 * The first object is the request. A request contains every information 1456 * needed two complete the file operation successfully like the start offset 1457 * and pointer to the source or destination buffer. 1458 * Requests are created with RTFileAioReqCreate() and destroyed with 1459 * RTFileAioReqDestroy(). 1460 * Because creating a request may require allocating various operating 1461 * system dependent resources and may be quite expensive it is possible 1462 * to use a request more than once to save CPU cycles. 1463 * A request is constructed with either RTFileAioReqPrepareRead() 1464 * which will set up a request to read from the given file or 1465 * RTFileAioReqPrepareWrite() which will write to a given file. 1466 * 1467 * The second object is the context. A file is associated with a context 1468 * and requests for this file may complete only on the context the file 1469 * was associated with and not on the context given in RTFileAioCtxSubmit() 1470 * (see below for further information). 1471 * RTFileAioCtxWait() is used to wait for completion of requests which were 1472 * associated with the context. While waiting for requests the thread can not 1473 * respond to global state changes. That's why the API provides a way to let 1474 * RTFileAioCtxWait() return immediately no matter how many requests 1475 * have finished through RTFileAioCtxWakeup(). The return code is 1476 * VERR_INTERRUPTED to let the thread know that he got interrupted. 1458 * 1459 * The first object is the request. A request contains every information needed 1460 * two complete the file operation successfully like the start offset and 1461 * pointer to the source or destination buffer. Requests are created with 1462 * RTFileAioReqCreate() and destroyed with RTFileAioReqDestroy(). Because 1463 * creating a request may require allocating various operating system dependent 1464 * resources and may be quite expensive it is possible to use a request more 1465 * than once to save CPU cycles. A request is constructed with either 1466 * RTFileAioReqPrepareRead() which will set up a request to read from the given 1467 * file or RTFileAioReqPrepareWrite() which will write to a given file. 1468 * 1469 * The second object is the context. A file is associated with a context and 1470 * requests for this file may complete only on the context the file was 1471 * associated with and not on the context given in RTFileAioCtxSubmit() (see 1472 * below for further information). RTFileAioCtxWait() is used to wait for 1473 * completion of requests which were associated with the context. While waiting 1474 * for requests the thread can not respond to global state changes. That's why 1475 * the API provides a way to let RTFileAioCtxWait() return immediately no matter 1476 * how many requests have finished through RTFileAioCtxWakeup(). The return code 1477 * is VERR_INTERRUPTED to let the thread know that he got interrupted. 1477 1478 * 1478 1479 * @section sec_rt_asyncio_request_states Request states 1479 1480 * 1480 * Created:1481 * @b Created: 1481 1482 * After a request was created with RTFileAioReqCreate() it is in the same state 1482 * like it just completed successfully. RTFileAioReqGetRC() will return VINF_SUCCESS 1483 * and a transfer size of 0. RTFileAioReqGetUser() will return NULL. The request can be 1484 * destroyed RTFileAioReqDestroy(). It is also allowed to prepare a the request 1485 * for a data transfer with the RTFileAioReqPrepare* methods. 1486 * Calling any other method like RTFileAioCtxSubmit() will return VERR_FILE_AIO_NOT_PREPARED 1487 * and RTFileAioReqCancel() returns VERR_FILE_AIO_NOT_SUBMITTED. 1488 * 1489 * Prepared: 1490 * A request will enter this state if one of the RTFileAioReqPrepare* methods 1491 * is called. In this state you can still destroy and retrieve the user data 1492 * associated with the request but trying to cancel the request or getting 1493 * the result of the operation will return VERR_FILE_AIO_NOT_SUBMITTED. 1494 * 1495 * Submitted: 1496 * A prepared request can be submitted with RTFileAioCtxSubmit(). If the operation 1497 * succeeds it is not allowed to touch the request or free any resources until 1498 * it completed through RTFileAioCtxWait(). The only allowed method is RTFileAioReqCancel() 1499 * which tries to cancel the request. The request will go into the completed state 1500 * and RTFileAioReqGetRC() will return VERR_FILE_AIO_CANCELED. 1501 * If the request completes not matter if successfully or with an error it will 1502 * switch into the completed state. RTFileReqDestroy() fails if the given request 1503 * is in this state. 1504 * 1505 * Completed: 1483 * like it just completed successfully. RTFileAioReqGetRC() will return 1484 * VINF_SUCCESS and a transfer size of 0. RTFileAioReqGetUser() will return 1485 * NULL. The request can be destroyed RTFileAioReqDestroy(). It is also allowed 1486 * to prepare a the request for a data transfer with the RTFileAioReqPrepare* 1487 * methods. Calling any other method like RTFileAioCtxSubmit() will return 1488 * VERR_FILE_AIO_NOT_PREPARED and RTFileAioReqCancel() returns 1489 * VERR_FILE_AIO_NOT_SUBMITTED. 1490 * 1491 * @b Prepared: 1492 * A request will enter this state if one of the RTFileAioReqPrepare* methods is 1493 * called. In this state you can still destroy and retrieve the user data 1494 * associated with the request but trying to cancel the request or getting the 1495 * result of the operation will return VERR_FILE_AIO_NOT_SUBMITTED. 1496 * 1497 * @b Submitted: 1498 * A prepared request can be submitted with RTFileAioCtxSubmit(). If the 1499 * operation succeeds it is not allowed to touch the request or free any 1500 * resources until it completed through RTFileAioCtxWait(). The only allowed 1501 * method is RTFileAioReqCancel() which tries to cancel the request. The request 1502 * will go into the completed state and RTFileAioReqGetRC() will return 1503 * VERR_FILE_AIO_CANCELED. If the request completes not matter if successfully 1504 * or with an error it will switch into the completed state. RTFileReqDestroy() 1505 * fails if the given request is in this state. 1506 * 1507 * @b Completed: 1506 1508 * The request will be in this state after it completed and returned through 1507 * RTFileAioCtxWait(). RTFileAioReqGetRC() returns the final result code 1508 * and the number of bytes transferred. 1509 * The request can be used for new data transfers. 1509 * RTFileAioCtxWait(). RTFileAioReqGetRC() returns the final result code and the 1510 * number of bytes transferred. The request can be used for new data transfers. 1510 1511 * 1511 1512 * @section sec_rt_asyncio_threading Threading 1512 1513 * 1513 1514 * The API is a thin wrapper around the specific host OS APIs and therefore 1514 * relies on the thread safety of the underlying API. 1515 * The interesting functions with regards to thread safety are RTFileAioCtxSubmit()1516 * andRTFileAioCtxWait(). RTFileAioCtxWait() must not be called from different1515 * relies on the thread safety of the underlying API. The interesting functions 1516 * with regards to thread safety are RTFileAioCtxSubmit() and 1517 * RTFileAioCtxWait(). RTFileAioCtxWait() must not be called from different 1517 1518 * threads at the same time with the same context handle. The same applies to 1518 * RTFileAioCtxSubmit(). However it is possible to submit new requests from a different 1519 * thread while waiting for completed requests on another thread with RTFileAioCtxWait(). 1519 * RTFileAioCtxSubmit(). However it is possible to submit new requests from a 1520 * different thread while waiting for completed requests on another thread with 1521 * RTFileAioCtxWait(). 1520 1522 * 1521 1523 * @section sec_rt_asyncio_implementations Differences in implementation 1522 1524 * 1523 * Because the host APIs are quite different on every OS and every API has other limitations 1524 * there are some things to consider to make the code as portable as possible. 1525 * 1526 * The first restriction at the moment is that every buffer has to be aligned to a 512 byte boundary. 1527 * This limitation comes from the Linux io_* interface. To use the interface the file 1528 * must be opened with O_DIRECT. This flag disables the kernel cache too which may 1529 * degrade performance but is unfortunately the only way to make asynchronous 1530 * I/O work till today (if O_DIRECT is omitted io_submit will revert to sychronous behavior 1531 * and will return when the requests finished and when they are queued). 1532 * It is mostly used by DBMS which do theire own caching. 1533 * Furthermore there is no filesystem independent way to discover the restrictions at least 1534 * for the 2.4 kernel series. Since 2.6 the 512 byte boundary seems to be used by all 1535 * file systems. So Linus comment about this flag is comprehensible but Linux 1536 * lacks an alternative at the moment. 1537 * 1538 * The next limitation applies only to Windows. Requests are not associated with the 1539 * I/O context they are associated with but with the file the request is for. 1540 * The file needs to be associated with exactly one I/O completion port and requests 1541 * for this file will only arrive at that context after they completed and not on 1542 * the context the request was submitted. 1543 * To associate a file with a specific context RTFileAioCtxAssociateWithFile() is 1544 * used. It is only implemented on Windows and does nothing on the other platforms. 1545 * If the file needs to be associated with different context for some reason 1546 * the file must be closed first. After it was opened again the new context 1547 * can be associated with the other context. 1548 * This can't be done by the API because there is no way to retrieve the flags 1549 * the file was opened with. 1525 * Because the host APIs are quite different on every OS and every API has other 1526 * limitations there are some things to consider to make the code as portable as 1527 * possible. 1528 * 1529 * The first restriction at the moment is that every buffer has to be aligned to 1530 * a 512 byte boundary. This limitation comes from the Linux io_* interface. To 1531 * use the interface the file must be opened with O_DIRECT. This flag disables 1532 * the kernel cache too which may degrade performance but is unfortunately the 1533 * only way to make asynchronous I/O work till today (if O_DIRECT is omitted 1534 * io_submit will revert to sychronous behavior and will return when the 1535 * requests finished and when they are queued). It is mostly used by DBMS which 1536 * do theire own caching. Furthermore there is no filesystem independent way to 1537 * discover the restrictions at least for the 2.4 kernel series. Since 2.6 the 1538 * 512 byte boundary seems to be used by all file systems. So Linus comment 1539 * about this flag is comprehensible but Linux lacks an alternative at the 1540 * moment. 1541 * 1542 * The next limitation applies only to Windows. Requests are not associated with 1543 * the I/O context they are associated with but with the file the request is 1544 * for. The file needs to be associated with exactly one I/O completion port and 1545 * requests for this file will only arrive at that context after they completed 1546 * and not on the context the request was submitted. To associate a file with a 1547 * specific context RTFileAioCtxAssociateWithFile() is used. It is only 1548 * implemented on Windows and does nothing on the other platforms. If the file 1549 * needs to be associated with different context for some reason the file must 1550 * be closed first. After it was opened again the new context can be associated 1551 * with the other context. This can't be done by the API because there is no way 1552 * to retrieve the flags the file was opened with. 1553 * 1554 * @{ 1550 1555 */ 1551 1556 … … 1817 1822 RTDECL(int) RTFileAioCtxWakeup(RTFILEAIOCTX hAioCtx); 1818 1823 1824 /** @} */ 1825 1819 1826 #endif /* IN_RING3 */ 1820 1827
Note:
See TracChangeset
for help on using the changeset viewer.