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

📄 2.1.t

📁 早期freebsd实现
💻 T
字号:
.\" Copyright (c) 1983, 1993.\"	The Regents of the University of California.  All rights reserved..\".\" Redistribution and use in source and binary forms, with or without.\" modification, are permitted provided that the following conditions.\" are met:.\" 1. Redistributions of source code must retain the above copyright.\"    notice, this list of conditions and the following disclaimer..\" 2. Redistributions in binary form must reproduce the above copyright.\"    notice, this list of conditions and the following disclaimer in the.\"    documentation and/or other materials provided with the distribution..\" 3. All advertising materials mentioning features or use of this software.\"    must display the following acknowledgement:.\"	This product includes software developed by the University of.\"	California, Berkeley and its contributors..\" 4. Neither the name of the University nor the names of its contributors.\"    may be used to endorse or promote products derived from this software.\"    without specific prior written permission..\".\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION).\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF.\" SUCH DAMAGE..\".\"	@(#)2.1.t	8.1 (Berkeley) 6/8/93.\".sh "Generic operations.PP.PPMany system abstractions support theoperations \fIread\fP, \fIwrite\fP and \fIioctl\fP.  We describethe basics of these common primitives here.Similarly, the mechanisms whereby normally synchronous operationsmay occur in a non-blocking or asynchronous fashion arecommon to all system-defined abstractions and are described here..NH 3Read and write.PPThe \fIread\fP and \fIwrite\fP system calls can be appliedto communications channels, files, terminals and devices.They have the form:.DScc = read(fd, buf, nbytes);result int cc; int fd; result caddr_t buf; int nbytes;cc = write(fd, buf, nbytes);result int cc; int fd; caddr_t buf; int nbytes;.DEThe \fIread\fP call transfers as much data as possible from theobject defined by \fIfd\fP to the buffer at address \fIbuf\fP ofsize \fInbytes\fP.  The number of bytes transferred isreturned in \fIcc\fP, which is \-1 if a return occurred beforeany data was transferred because of an error or use of non-blockingoperations..PPThe \fIwrite\fP call transfers data from the buffer to theobject defined by \fIfd\fP.  Depending on the type of \fIfd\fP,it is possible that the \fIwrite\fP call will accept some portionof the provided bytes; the user should resubmit the other bytesin a later request in this case.Error returns because of interrupted or otherwise incomplete operationsare possible..PPScattering of data on input or gathering of data for outputis also possible using an array of input/output vector descriptors.The type for the descriptors is defined in \fI<sys/uio.h>\fP as:.DS._fstruct iovec {	caddr_t	iov_msg;	/* base of a component */	int	iov_len;	/* length of a component */};.DEThe calls using an array of descriptors are:.DScc = readv(fd, iov, iovlen);result int cc; int fd; struct iovec *iov; int iovlen;cc = writev(fd, iov, iovlen);result int cc; int fd; struct iovec *iov; int iovlen;.DEHere \fIiovlen\fP is the count of elements in the \fIiov\fP array..NH 3Input/output control.PPControl operations on an object are performed by the \fIioctl\fPoperation:.DSioctl(fd, request, buffer);int fd, request; caddr_t buffer;.DEThis operation causes the specified \fIrequest\fP to be performedon the object \fIfd\fP.  The \fIrequest\fP parameter specifieswhether the argument buffer is to be read, written, read and written,or is not needed, and also the size of the buffer, as well as therequest.Different descriptor types and subtypes within descriptor typesmay use distinct \fIioctl\fP requests.  For example,operations on terminals control flushing of input and outputqueues and setting of terminal parameters; operations ondisks cause formatting operations to occur; operations on tapescontrol tape positioning..PPThe names for basic control operations are defined in \fI<sys/ioctl.h>\fP..NH 3Non-blocking and asynchronous operations.PPA process that wishes to do non-blocking operations on one ofits descriptors sets the descriptor in non-blocking mode asdescribed in section 1.5.4.  Thereafter the \fIread\fP call willreturn a specific EWOULDBLOCK error indication if there is no data to be\fIread\fP.  The process may\fIselect\fP the associated descriptor to determine when a read ispossible..PPOutput attempted when a descriptor can accept less than is requestedwill either accept some of the provided data, returning a shorter than normallength, or return an error indicating that the operation would block.More output can be performed as soon as a \fIselect\fP call indicatesthe object is writeable..PPOperations other than data input or outputmay be performed on a descriptor in a non-blocking fashion.These operations will return with a characteristic error indicatingthat they are in progressif they cannot complete immediately.  The descriptormay then be \fIselect\fPed for \fIwrite\fP to find outwhen the operation has been completed.  When \fIselect\fP indicatesthe descriptor is writeable, the operation has completed.Depending on the nature of the descriptor and the operation,additional activity may be started or the new state may be tested.

⌨️ 快捷键说明

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