nbuf.4

来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 4 代码 · 共 141 行

4
141
字号
.\" SCCSID: @(#)nbuf.4	8.1	9/11/90.TH nbuf 4.SH Namenbuf \- select multiple-buffer operation to a raw device.SH Syntax.nf.ft B#include <sys/ioctl.h>.PP.nf.ft Bioctl(d, FIONBUF, count)int d;int *count;.fi.PP.nf.ft Bstatus=ioctl(d, FIONBDONE, buffer)int d, status;char **buffer;.fi.ft R.SH Description.NXR "nbuf keyword".NXR "I/O operation" "multiple buffers and"The I/O operations to raw devices are usually performed througha single buffer. This means that the issuing processmust wait for a buffer to complete before the process cando anything else. An.I N-buffered I/O operation allows a processto begin an I/O operation and continue doing something elseuntil the operation has finished. Once .I N-bufferedoperationis enabled, .MS read 2and .MS write 2acts as before except thatbuffer completion is not guaranteed when the call returns.If the operation starts without errors,.MS read 2 and .MS write 2 returnas if the operation were successful.That is, the number of requested byteshave transferred and file pointers are updated. On read operations,the process must not use the contents of the started bufferuntil the buffer actually completes. On write operations,the processmust not reuse the buffer until the operation actually completes.A second .PN ioctl is used to check the status of previously issued .I N-buffered read/write requests to determine when the operation has really completed..PP.I N-buffered I/O is used through a set of .PN ioctl calls.Setting the.I requestargument in an.PN ioctlcall to FIONBUF enables .I count buffers to be used with the raw deviceassociated with the file descriptor .IR d . If .I countis zero,the N-buffered operation is terminated and any pending buffersare completed. A .I countless than zero is invalid.Any started I/O buffer's status is checked by the .PN ioctlcall with the.I requestargument set to FIONBDONE,with the address of the buffer used as an argument. The status fieldreturns the actual byte count transferred or any error encounteredon the I/O operation. The FIONBDONE ioctl must be called before re-using a buffer. FIONBDONE blocks the process untilthe given buffer completes (unless FNDELAY has been specifiedwith.MS fcntl 2 ,at which point EWOULDBLOCK is returned).In addition, a signal can be generated whenever a buffer completes, if FIOASYNC has been specified with.MS fcntl 2 ..PPThe.MS select 2call is also useful in checking on the status of pending buffers. The.MS select 2call returns immediately if less than .I countoperations have been started on an N-buffered channel. Otherwise,.PN select blocks the specified amount of time for a buffer to become done. At this point, FIONBDONE must be used to returnactual status of the pending buffer..SH DiagnosticsThe.PN ioctlcall fails if one or more of the following are true:.TP 15[EBADF]The \fId\fP argument is not a valid descriptor..TP 15[ENOTTY]The \fId\fP argument is not associated with a characterspecial device..TP 15[ENOTTY]The specified request does not apply to the kindof object which the descriptor \fId\fP references..TP 15[EINVAL]The \fIrequest\fP or \fIargp\fP argument is not valid. Returned for FIONBDONE, ifrequested buffer was never started. Also returnedfor FIONBUF, if this device does not support .I N-buffered I/O..SH See Alsofcntl(2), ioctl(2), select(2)

⌨️ 快捷键说明

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