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

📄 fifo.9

📁 7号信令功能代码,为开源代码
💻 9
字号:
.\".\" Copyright (C) 2000  John A. Boyd Jr.  protologos, LLC.\".\" This library is free software; you can redistribute it and/or.\" modify it under the terms of the GNU Library General Public.\" License as published by the Free Software Foundation; either.\" version 2 of the License, or (at your option) any later version..\".\" This library is distributed in the hope that it will be useful,.\" but WITHOUT ANY WARRANTY; without even the implied warranty of.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU.\" Library General Public License for more details..\".\" You should have received a copy of the GNU Library General Public.\" License along with this library; if not, write to the.\" Free Software Foundation, Inc., 59 Temple Place - Suite 330, Cambridge,.\" MA 02139, USA..\".TH FIFO 9 "24 Apr 2000" "LiS 2.9" "Linux STREAMS".SH NAME.B fifo\- pseudo-driver for.BR STREAMS "\-based".I fifos.SH DESCRIPTIONThe.B fifopseudo-driver(which is internal to LiS) provides.BR STREAMS "\-based" .I fifosas single character special files, and.BR STREAMS "\-based" .I pipesas pairs of character special files which are interconnected (see.BR pipe "(3)).  ".sp.BR STREAMS "\-based".I fifosdiffer from typical.BR STREAMS "\-based"character special files in that there are not separate.I "stream head"and.I driverqueue pair within the.BR STREAMS "\-based"file.  Instead, a.I fifois created with only a single queue pair for the.IR "stream head" .Moreover, in a typical.I driverqueue pair, the write queue is not connected to a next queue.In a.IR fifo ,the write queue is directed to the read queue of the pair.A.I pipecomprises a pair of.IR fifos ", "with the write queue of each pair directed to the read queue of the other.The two.B fifoscomprising a.B pipeare referred to as.IR peers ", "and each somewhat represents a.I driverto the other.As a degenerate case, a.B fifois its own peer..sp.B STREAMS.I modulesmay be pushed onto.B fifosand.BR pipes ", "but should not expect a.I driverbelow them; instead, the.BR SAMESTR "()"function should be used from the write queue of a pair to determine ifthe module is the lowest in the.BR STREAMS "\-based"file (this is called the.IR midpoint "). "The structure of a.B fifoor.B pipeis preserved when modules are pushed (and popped); i.e., the writequeue at the.I midpointwill always be directed at the read queue of the.IR peer ".".spInput and output are handled at a.B fifostream head as they would normally be handledat a stream head.  In LiS, an.BR "fifo open" "() "entry point exists to assign minor device numbers to new opens under the.B fifomajor device number, and a.BR close "() "entry point is used correspondingly to release them.  These functionsare kept in a.I streamtabdata structure (as they would normally be for any.B STREAMSdriver or module) which is private to the LiS implementation..SH "APPLICATION USAGE"In the current Linux kernels, character special major numbers are limitedto 16 bits, and major and minor device numbers to 8 bis each.  This limitsa system to 256 total major device numbers and 256 total minor devicesper major device number.  This is a rather severe limitation wheremechanisms like.B fifosand.B pipesare concerned..spHowever, a driver may handle more than one major device number.  The.B fifopseudo-driver uses this to overcome this limitation, by supporting theautomatic allocation and use of multiple major device numbers for.B fifosand.BR pipes .Specifying more than 256 minor devices is done in the usual manner, i.e.,by specifying the number of "units" in the appropriate.B Configfile.  Enough major device numbers will be allocated to cover therequested number of minor devices (if available, else an error willoccur in .BR strconf "(8)). "The number allocated will include one minor device per major numberto be used as a.BR fifo "\-specific".I cloneminor device (specifically, minor number 0), which exhibits special behavior..spNormally, when cloning is done via the.B clonepseudo-driver, the.B clonemajor device number is used, along with the desired actual major numberas the minor device number.  When an.BR open "() "is performed on such a device, the.BR "clone open" "() "routine in turn calls the appropriate driver's.BR open "(), "with the.I sflagparameter set to.BR CLONEOPEN .The driver's.BR open "() "is expected in this case to allocate an unused minor device number,and return it via an entirely new device number in the.I "devp" parameter.  In this way, a driver can change the device number to beused for a.BR STREAMS "\-based"file.When minor device 0 for a specified for a.B fifomajor device, the driver will also clone a new minor device number.However, LiS opens.B fifodevices differently; specifically, when an already-opened.BR fifo "\-specific"clone minor device is reopened, the new and subsequent opens will usethe already-opened clone.Thus, using minor device 0 for a.B fifowhen creating a file system node will ensure that all concurrentopens of the associated path name will use the same.BR STREAMS "\-based"file; at the same time, opens of different file system nodes viadifferent paths will open their respectively different.BR STREAMS "\-based"files.This is essentially how kernel-based.B fifosbehave -applications and users of.BR STREAMS "\-based".B fifosdon't have to keep track of minor numbers to achieve this same behaviorwhen it is desired..spIt is in fact recommended that only two forms of file system nodes be used for.BR STREAMS "\-based " fifos ": "the.B clonemajor number as major number with a.B fifomajor number as minor number, to be used when.I everyopen of the associated path must clone a new.BR fifo ", "and a.B fifomajor number as major number with 0 as the minor number, to be usedwhen new opens are to clone a new.B fifobut subsequent concurrent opens are to use the already opened.BR fifo ". "These are represented by two device special file paths created when LiSis installed:.RB "/" dev "/" fifofor the former, and.RB "/" dev "/" fifo.0for the latter.  It is recommended that these be used, possiblyalong with the equivalent of.BR stat "(2) "to determine appropriate major device numbers for the.B cloneand.B fifopseudo-drivers, which are also determined when LiS is installed.It can be noted that.B pipesare actually created as instances of the former, after which the writequeues are peer-connected..spThe.B fifopseudo-driver allocates minor devices in.I round-robinfashion; i.e., a list of available minor devices is kept, and once aminor number is finally closed, it is put at the end of this list.Thus, a.B fifominor device which is opened and closed will not be immediately reused..SH WARNINGSBecause.BR STREAMS "\-based".B fifosand.B pipesare implemented as character special devices, they do not appear as.B pipedevices when examined with.BR stat "(2) "or the equivalent (e.g., .BR ls "(1)); "i.e. the.B S_IFIFOindication is not set in the mode -.B S_IFCHRis set instead, and the actual device number is indicated in the.I st_rdevfield of the.I statdata structure..spBecause of the potential use of multiple major numbers, applicationsshould not depend on a.B fifoor.B pipehaving a specific major device number, nor should an application depend onall.B fifosand.B pipeshaving the same major device number..SH "SEE ALSO".BR clone "(9), ".BR connld "(9), ".BR fifo "(4), ".BR ls "(1), ".BR pipe "(3), ".BR pipemod "(9), ".BR STREAMS "(4), ".BR stat "(2), ".BR strconf "(8)".SH HISTORYUnix System V Release 4 (SVR4).SH BUGSPlease report bugs (and/or comments and suggestions) to the LiS mailing list..SH AUTHORJohn Boyd, protologos LLC.

⌨️ 快捷键说明

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