⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c-iosys6.html

📁 this about vxworks operations systems
💻 HTML
📖 第 1 页 / 共 3 页
字号:
</tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="91441"> </a>&nbsp;&nbsp;&nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="91444"> </a><b class="symbol_UC">AIO_TASK_PRIORITY</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="91446"> </a>0</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="91449"> </a><b class="symbol_UC">AIO_IO_PRIO_DFLT</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="91451"> </a>50</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="91454"> </a><b class="file">h/aioSysDrv.h</b> &nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="91456"> </a>&nbsp;&nbsp;&nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="91459"> </a><b class="symbol_UC">AIO_TASK_STACK_SIZE</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="91461"> </a>0</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="91464"> </a><b class="symbol_UC">AIO_IO_STACK_DFLT</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="91466"> </a>0x7000</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="91469"> </a><b class="file">h/aioSysDrv.h</b> &nbsp;</div></td></tr><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p></p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="84241">3.6.2  &nbsp;&nbsp;AIO Control Block</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84243"> </a>Each of the AIO calls takes an AIO control block (<b class="symbol_lc">aiocb</b>) as an argument to describe the AIO operation. The calling routine must allocate space for the control block, which is associated with a single AIO operation. No two concurrent AIO operations can use the same control block; an attempt to do so yields undefined results.</p><dd><p class="Body"><a name="95557"> </a>The <b class="symbol_lc">aiocb</b> and the data buffers it references are used by the system while performing the associated request. Therefore, after you request an AIO operation, you must not modify the corresponding <b class="symbol_lc">aiocb</b> before calling <b class="routine"><i class="routine">aio_return</i></b><b>(&nbsp;)</b>; this function frees the <b class="symbol_lc">aiocb</b> for modification or reuse.</p></dl></dl><dl class="margin"><dd><p class="table" callout><table border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td valign="top" width="40"><br><img border="0" alt="*" src="icons/caution.gif"></td><td><hr><div class="CalloutCell"><a name="95575"><b class="symbol_UC"><font face="Helvetica, sans-serif" size="-1" class="sans">CAUTION:  </font></b></a>If a routine allocates stack space for the <b class="symbol_lc">aiocb</b>, that routine must call <b class="routine"><i class="routine">aio_return</i></b><b>(&nbsp;)</b> to free the <b class="symbol_lc">aiocb</b> before returning.</div></td></tr><tr valign="top"><td></td><td><hr></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p callout><dl class="margin"><dd><p class="Body"><a name="84248"> </a>The <b class="symbol_lc">aiocb</b> structure is defined in <b class="file">aio.h</b>. It contains the following fields:</p></dl><dl class="margin"><dd><div class="Item"><a name="84249"> </a><b class="symbol_lc">aio_fildes</b> </div><dl class="margin"><dl class="margin"><dd><div class="Indent2"><a name="86859"> </a>file descriptor for I/O</div><br></dl></dl><dd><div class="Item"><a name="84250"> </a><b class="symbol_lc">aio_offset</b> </div><dl class="margin"><dl class="margin"><dd><div class="Indent2"><a name="86861"> </a>offset from the beginning of the file</div><br></dl></dl><dd><div class="Item"><a name="84251"> </a><b class="symbol_lc">aio_buf</b> </div><dl class="margin"><dl class="margin"><dd><div class="Indent2"><a name="86863"> </a>address of the buffer from/to which AIO is requested</div><br></dl></dl><dd><div class="Item"><a name="84252"> </a><b class="symbol_lc">aio_nbytes</b> </div><dl class="margin"><dl class="margin"><dd><div class="Indent2"><a name="86865"> </a>number of bytes to read or write</div><br></dl></dl><dd><div class="Item"><a name="84253"> </a><b class="symbol_lc">aio_reqprio</b> </div><dl class="margin"><dl class="margin"><dd><div class="Indent2"><a name="86867"> </a>priority reduction for this AIO request</div><br></dl></dl><dd><div class="Item"><a name="84254"> </a><b class="symbol_lc">aio_sigevent</b> </div><dl class="margin"><dl class="margin"><dd><div class="Indent2"><a name="91472"> </a>signal to return on completion of an operation (optional)</div><br></dl></dl><dd><div class="Item"><a name="91473"> </a><b class="symbol_lc">aio_lio_opcode</b> </div><dl class="margin"><dl class="margin"><dd><div class="Indent2"><a name="91474"> </a>operation to be performed by a <b class="routine"><i class="routine">lio_listio</i></b><b>(&nbsp;)</b> call</div><br></dl></dl><dd><div class="Item"><a name="84256"> </a><b class="symbol_lc">aio_sys</b> </div><dl class="margin"><dl class="margin"><dd><div class="Indent2"><a name="86873"> </a>VxWorks-specific data (non-POSIX)</div><br></dl></dl></dl><dl class="margin"><dd><p class="Body"><a name="84257"> </a>For full definitions and important additional information, see the reference entry for <b class="library">aioPxLib</b>.<b></b></p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="84259">3.6.3  &nbsp;&nbsp;Using AIO</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84263"> </a>The routines <b class="routine"><i class="routine">aio_read</i></b><b>(&nbsp;)</b>, <b class="routine"><i class="routine">aio_write</i></b><b>(&nbsp;)</b>, or <b class="routine"><i class="routine">lio_listio</i></b><b>(&nbsp;)</b> initiate AIO operations. The last of these, <b class="routine"><i class="routine">lio_listio</i></b><b>(&nbsp;)</b>, allows you to submit a number of asynchronous requests (read and/or write) at one time. In general, the actual I/O (reads and writes) initiated by these routines<b class="routine"><i class="routine"> </i></b>does not happen immediately after the AIO request. For that reason, their return values do not reflect the outcome of the actual I/O operation, but only whether a request is successful--that is, whether the AIO routine is able to put the operation on a queue for eventual execution. </p><dd><p class="Body"><a name="84266"> </a>After the I/O operations themselves execute, they also generate return values that reflect the success or failure of the I/O. There are two routines that you can use to get information about the success or failure of the I/O operation: <b class="routine"><i class="routine">aio_error</i></b><b>(&nbsp;)</b> and <b class="routine"><i class="routine">aio_return</i></b><b>(&nbsp;)</b>. You can use <b class="routine"><i class="routine">aio_error</i></b><b>(&nbsp;)</b>to get the status of an AIO operation (success, failure, or in progress), and <b class="routine"><i class="routine">aio_return</i></b><b>(&nbsp;)</b> to obtain the return values from the individual I/O operations. Until an AIO operation completes, its error status is <b class="symbol_UC">EINPROGRESS</b>. To cancel an AIO operation, call <b class="routine"><i class="routine">aio_cancel</i></b><b>(&nbsp;)</b>. </p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="84271">AIO with Periodic Checks for Completion</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84273"> </a>The following code uses a pipe for the asynchronous I/O operations. The example creates the pipe, submits an AIO read request, verifies that the read request is still in progress, and submits an AIO write request. Under normal circumstances, a synchronous read to an empty pipe blocks and the task does not execute the write, but in the case of AIO, we initiate the read request and continue. After the write request is submitted, the example task loops, checking the status of the AIO requests periodically until both the read and write complete. Because the AIO control blocks are on the stack, we must call <b class="routine"><i class="routine">aio_return</i></b><b>(&nbsp;)</b> before returning from <b class="routine"><i class="routine">aioExample</i></b><b>(&nbsp;)</b>.</p></dl></dl><h4 class="EntityTitle"><a name="84274"><font face="Helvetica, sans-serif" size="-1" class="sans">Example 3-2:&nbsp;&nbsp;Asynchronous I/O</font></a></h4><dl class="margin"><dl class="margin"><dd><pre class="Code"><b><a name="84275">/* aioEx.c - example code for using asynchronous I/O */</a></b><dd> <b><a name="84277">/* includes */</a></b><dd> <b><a name="84279">#include "vxWorks.h" #include "aio.h" #include "errno.h"</a></b><dd> <b><a name="84281">/* defines */</a></b><dd>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -