📄 streams.doc10.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="../../wrs.css"><title>WindNet STREAMS Components WindNet STREAMS for Tornado </title></head><body bgcolor="FFFFFF"><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="../../icons/contents.gif"></a><a href="streams.doc9.html"><img border="0" alt="[Prev]" src="../../icons/prev.gif"></a><a href="streams.doc11.html"><img border="0" alt="[Next]" src="../../icons/next.gif"></a></p><font face="Helvetica, sans-serif" class="sans"><h3 class="H2"><i><a name="81487" class="autotag">3.4 WindNet STREAMS Utilities</a></i></h3></font><dl class="margin"><dd><dl class="margin"><dd><p class="Body"><a name="80869" class="autotag"> </a>The WindNet STREAMS for Tornado component release provides a set of utilities to help build various streams configurations and to debug STREAMS modules and drivers.</p><p class="Body"><a name="87968" class="autotag"> </a>The <b class="keyword">autopush</b> facility configures streams by opening devices onto which lists of modules are automatically pushed before the open system call is completed. It can also remove a previous setting or get information on a setting. A set of three routines comprise the <b class="keyword">autopush</b> facility in WindNet STREAMS: <b class="routine"><i class="routine">autopushGet</i></b><b>( )</b>, <b class="routine"><i class="routine">autopushAdd</i></b><b>( )</b>, and <b class="routine"><i class="routine">autopushDelete</i></b><b>( )</b>. </p><p class="Body"><a name="84482" class="autotag"> </a>The debugging utilities, <b class="keyword">strace</b> and <b class="keyword">strerr</b>, the <b class="routine"><i class="routine">strlog</i></b><b>( )</b> routine, and numerous STREAMS show routines are described in <a href="streams.doc20.html#80244"><i class="title">§5. WindNet STREAMS Debugging</i></a>, along with examples showing how to use each facility.</p></dd></dl></dd></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="84484" class="autotag">3.4.1 The Autopush Utility</a></i></h4></font><dl class="margin"><dd><dl class="margin"><dd><p class="Body"><a name="88245" class="autotag"> </a>The autopush utility works in conjunction with the STREAMS Administration Driver (SAD) when pushing modules onto specified devices during an open. The SAD driver stores the list of modules to push for specified drivers. When a driver is opened, the stream head references the SAD cache to see if that driver has been configured for autopush. If so, any modules listed for the specified device are pushed.</p></dd></dl></dd></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="84498" class="autotag"><b class="routine"><i class="routine">autopushGet</i></b><b>( )</b></a></i></h4></font><dl class="margin"><dd><dl class="margin"><dd><p class="Body"><a name="84486" class="autotag"> </a>The <b class="routine"><i class="routine">autopushGet</i></b><b>( )</b> utility obtains autopush configuration information for a device from the STREAMS Administration Driver (SAD) and displays it. The device name is that of either a clone device or a minor device. If it is a clone device, autopush information is displayed for all minor devices. If it is a minor device, then autopush information is displayed only for the specific minor device. </p><p class="Body"><a name="80836" class="autotag"> </a>For example, the following command prints autopush information for all minor devices of the <b class="file">/dev/echo </b>device:</p></dd></dl><dl class="margin"><dd><pre class="Code"><a name="80837" class="autotag">-> autopushGet "/dev/echo" </a></pre></dd></dl><dl class="margin"><dd><p class="Body"><a name="80838" class="autotag"> </a>If no modules have been pushed onto the <b class="file">/dev/echo</b> device, console output would be: </p></dd></dl><dl class="margin"><dd><pre class="Code"><a name="80839" class="autotag"><tt><font class="output" color="#55AA55">Device(13,0) not configured for autopush</font></tt></a></pre></dd></dl><dl class="margin"><dd><p class="Body"><a name="80840" class="autotag"> </a>In this case, the number 13 specifies the major number of the <b class="file">/dev/echo</b> device. The number 0 specifies the minor number. </p><p class="Body"><a name="80841" class="autotag"> </a>The following command prints autopush information for the minor device 2 of the <b class="file">/dev/echo</b> device:</p></dd></dl><dl class="margin"><dd><pre class="Code"><a name="84559" class="autotag">-> autopushGet "/dev/echo2"</a></pre></dd></dl><dl class="margin"><dd><p class="Body"><a name="80842" class="autotag"> </a>The console output would be:</p></dd></dl><dl class="margin"><dd><pre class="Code"><a name="80843" class="autotag"><tt><font class="output" color="#55AA55">Device (13,2) not configured for autopush</font></tt></a></pre></dd></dl></dd></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="80844" class="autotag"><b class="routine"><i class="routine">autopushAdd</i></b><b>( )</b> </a></i></h4></font><dl class="margin"><dd><dl class="margin"><dd><p class="Body"><a name="80845" class="autotag"> </a>The <b class="routine"><i class="routine">autopushAdd</i></b><b>( )</b> utility augments a list of STREAMS modules that have been automatically pushed onto a device. The <b class="routine"><i class="routine">autopushAdd</i></b><b>( )</b>routine sets up the autopush configuration information for the device passed. The routine takes a string specifying the device name and the names of modules to be pushed. If a clone device is given, the modules are pushed on all minor devices. Modules are pushed onto specific minor devices if minor devices are specified as the device parameters. </p><p class="Body"><a name="80846" class="autotag"> </a>For example, the following command automatically pushes <b class="keyword">pass</b> and <b class="keyword">spass</b> modules onto all minor devices of the <b class="file">/dev/echo </b>device at open time:</p></dd></dl><dl class="margin"><dd><pre class="Code"><a name="80847" class="autotag">-> autopushAdd "/dev/echo pass spass"</a></pre></dd></dl><dl class="margin"><dd><p class="Body"><a name="80848" class="autotag"> </a>To list the configuration of the <b class="file">/dev/echo </b>device, use <b class="routine"><i class="routine">autopushGet</i></b><b>( )</b>. The console output of <b class="routine"><i class="routine">autopushGet</i></b><b>( )</b> would be as follows:</p></dd></dl><dl class="margin"><dd><pre class="Code"><a name="80849" class="autotag"><tt><font class="output" color="#55AA55">Major Minor Last Minor 2 module(s)</font></tt></a><a name="80850" class="autotag"><tt><font class="output" color="#55AA55">------- ------ ------------ ------------</font></tt></a><a name="84414" class="autotag"><tt><font class="output" color="#55AA55">13 ALL --- pass spass </font></tt></a></pre></dd></dl><dl class="margin"><dd><p class="Body"><a name="84681" class="autotag"> </a>The following command automatically pushes <b class="keyword">pass</b> and <b class="keyword">spass</b> modules onto the minor device 2 of the <b class="file">/dev/echo</b> device.</p></dd></dl><dl class="margin"><dd><pre class="Code"><a name="84415" class="autotag">autopushAdd "/dev/echo2 pass spass"</a></pre></dd></dl><dl class="margin"><dd><p class="Body"><a name="84677" class="autotag"> </a>The console output of the <b class="routine"><i class="routine">autopushGet</i></b><b>( )</b> command would be as follows. </p></dd></dl><dl class="margin"><dd><pre class="Code"><a name="80854" class="autotag"><tt><font class="output" color="#55AA55">Major Minor Last Minor 2 module(s)</font></tt></a><a name="80855" class="autotag"><tt><font class="output" color="#55AA55">------ ------ ------------ ------------</font></tt></a><a name="80856" class="autotag"><tt><font class="output" color="#55AA55">13 2 ----- pass spass</font></tt></a></pre></dd></dl></dd></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="80857" class="autotag"><b class="routine"><i class="routine">autopushDelete</i></b><b>( )</b> </a></i></h4></font><dl class="margin"><dd><dl class="margin"><dd><p class="Body"><a name="80858" class="autotag"> </a>The <b class="routine"><i class="routine">autopushDelete</i></b><b>( )</b> utility removes from the STREAMS Administration Driver (SAD) autopush information for the device passed. If the device name passed is a clone device, then autopush information for all minor devices is removed. If the device name is a minor device, then autopush information is removed only for that specific minor device. </p><p class="Body"><a name="84725" class="autotag"> </a>For example, the following command removes autopush information for all minor devices of <b class="file">/dev/echo</b>:</p></dd></dl><dl class="margin"><dd><pre class="Code"><a name="80860" class="autotag">-> autopushDelete "/dev/echo"</a></pre></dd></dl><dl class="margin"><dd><p class="Body"><a name="80861" class="autotag"> </a>To list the configuration of the <b class="file">/dev/echo </b>device, use <b class="routine"><i class="routine">autopushGet</i></b><b>( )</b>. The console output of <b class="routine"><i class="routine">autopushGet</i></b><b>( )</b> would be as follows:</p></dd></dl><dl class="margin"><dd><pre class="Code"><a name="80862" class="autotag"><tt><font class="output" color="#55AA55">Device(13,0) not configured for autopush</font></tt></a></pre></dd></dl><dl class="margin"><dd><p class="Body"><a name="84750" class="autotag"> </a>The following command removes autopush information for the minor number 2 of <b class="file">/dev/echo2</b>. </p></dd></dl><dl class="margin"><dd><pre class="Code"><a name="80863" class="autotag">-> autopushDelete "/dev/echo2"</a></pre></dd></dl><dl class="margin"><dd><p class="Body"><a name="80864" class="autotag"> </a>The console output of <b class="routine"><i class="routine">autopushGet</i></b><b>( )</b> would be as follows:</p></dd></dl><dl class="margin"><dd><pre class="Code"><a name="81026" class="autotag"><tt><font class="output" color="#55AA55">Device (13, 2) not configured for autopush </font></tt></a></pre></dd></dl></dd></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="88893" class="autotag">3.4.2 WindNet STREAMS Pipes and FIFOs</a></i></h4></font><dl class="margin"><dd><dl class="margin"><dd><p class="Body"><a name="88896" class="autotag"> </a>A streams pipe is a full-duplex connection between two file descriptors.</p><p class="Body"><a name="88897" class="autotag"> </a><a href="streams.doc10.html#88961"><i class="title">Figure 12</i></a> shows the structure of a streams pipe. Each file descriptor has its own stream head with the write queue pointing to the other's read queue. Data written to one file descriptor is placed on the read queue at the other end of the pipe. Streams pipes can be used as a bidirectional data transfer path in WindNet STREAMS. <div class="frame"><h4 class="EntityTitle"><a name="88961" class="autotag"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 12. Streams Pipe</font></a></h4><div class="CellBody"><a name="88959" class="autotag"> </a><img class="figure" border="0" alt="" src="images/streams.doc.anc10.gif"></div></div></p><p class="Body"><a name="89310" class="autotag"> </a>WindNet STREAMS creates streams pipes using <b class="routine"><i class="routine">strmPipe</i></b><b>( )</b>, as follows:</p><dl class="margin"><dd><pre class="Code2"><a name="89295" class="autotag">{</a><a name="89296" class="autotag">int pipeFds [2]; /* Values filled by the strmPipe function */</a><a name="89297" class="autotag"></a><a name="89298" class="autotag">if (strmPipe (&pipeFds[0]) == ERROR)</a><a name="89299" class="autotag"> /* Pipe was not created */</a><a name="89300" class="autotag">else</a><a name="89301" class="autotag"> /* Pipe was created successful. */</a><a name="89302" class="autotag">}</a></pre></dd></dl><p class="Body"><a name="88911" class="autotag"> </a>For more information about using streams pipes in WindNet STREAMS, see the manual entry for <b class="routine"><i class="routine">strmPipe</i></b><b>( )</b>. For a comprehensive discussion of streams pipes, as well as the <b class="keyword">pipemod</b> driver, refer to <i class="title">UNIX System V Network Programming</i>, by Stephen Rago. </p><p class="Body"><a name="89266" class="autotag"> </a>FIFOs are first-in-first-out streams configuration. WindNet STREAMS constructs a FIFO using <b class="routine"><i class="routine">strmMkfifo</i></b><b>( )</b>, as follows:</p><dl class="margin"><dd><pre class="Code2"><a name="89277" class="autotag">{</a><a name="89278" class="autotag">int fifoFd; /* Set by function Mkfifo */</a><a name="89279" class="autotag"></a><a name="89280" class="autotag">fifoFd = strmMkfifo ();</a><a name="89281" class="autotag">}</a></pre></dd></dl><p class="Body"><a name="89282" class="autotag"> </a>For both of the pipe and FIFO build procedures, the queues of the stream heads are interconnected to provide pipe and FIFO facilities.</p></dd></dl></dd></dl><a name="foot"><hr></a><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="../../icons/contents.gif"></a><a href="streams.doc9.html"><img border="0" alt="[Prev]" src="../../icons/prev.gif"></a><a href="streams.doc11.html"><img border="0" alt="[Next]" src="../../icons/next.gif"></a></p></body></html><!---This file generated April 10, 1998, 12:25PM PDTby WRS Documentation (jeff), Wind River Systems, Inc. conversion tool: Quadralay WebWorks Publisher 3.5.0 template: CSS Template, Jan 1998 - Jefro --->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -