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

📄 streams.doc13.html

📁 vxworks相关论文
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="../../wrs.css"><title>Porting STREAMS Protocols to WindNet STREAMS    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.doc12.html"><img border="0" alt="[Prev]" src="../../icons/prev.gif"></a><a href="streams.doc14.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="71734" class="autotag">4.1&nbsp;&nbsp;The WindNet STREAMS Synchronization Model</a></i></h3></font><dl class="margin"><dd><dl class="margin"><dd><p class="Body"><a name="90625" class="autotag"> </a>In a multi-threaded environment where data is shared between instances of a STREAMS component, synchronization of thread execution is necessary.  WindNet STREAMS includes built-in facilities that free the development engineer from having to design into the STREAMS component <i class="term">synchronization</i> services enabling access to shared resources.  When discussing synchronization, both modules and drivers can be considered components.  WindNet STREAMS synchronization relies on the following rules, as defined by the STREAMS programming specifications; refer to the <i class="title">UNIX System V Release 4 Programmer's Guide: STREAMS </i>(Prentice Hall) and <i class="title">STREAMS Modules and Drivers </i>(Prentice Hall). </p></dd></dl><dl class="margin"><dd><p class="listspace"><ul class="Bullet" type="disc"><li><a name="90626" class="autotag"> </a>The STREAMS environment controls all component entry points completely.  Component open, close, put, and service procedures can be called only from the STREAMS framework. </li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="71737" class="autotag"> </a>The STREAMS definition explicitly states that components cannot assume a specific thread context in their put and service routines.  This means any thread can execute a put or service routine, including threads from other user contexts or from other system threads. </li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="71738" class="autotag"> </a>The STREAMS definition explicitly disallows components from invoking the WindNet STREAMS routine <b class="routine"><i class="routine">strmSleep</i></b><b>(&nbsp;)</b> from put and service routines.</li></ul></p></dd></dl><dl class="margin"><dd><p class="Body"><a name="81989" class="autotag"> </a>Based on these rules, the WindNet STREAMS synchronization model can provide the following services:</p></dd></dl><dl class="margin"><dd><p class="listspace"><ul class="Bullet" type="disc"><li><a name="91552" class="autotag"> </a>Access to component instances (that is, STREAMS queues) is controlled by the STREAMS framework, and no longer requires you to develop code to achieve synchronization.  In particular, most components written for a single-threaded SVR4 STREAMS environment can run in a multi-threaded environment, like WindNet STREAMS, without any code changes. </li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="71741" class="autotag"> </a>In the typical case, multiple parallel threads of execution incur essentially no overhead, when the desired resource is available.  Even if there is contention for a resource, requests are serialized and processed with minimal overhead.</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="82036" class="autotag"> </a>The design is optimized for efficient data movement:  Put and service procedures incur low synchronization overhead.  Access for open and close procedures is considered low frequency and demands higher overhead. </li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="82037" class="autotag"> </a>Deadlocks cannot occur because execution threads never block.  If a resource is unavailable, the execution thread which needs the resource simply adds itself to a list of jobs needing the resource.  The thread which currently owns the resource will process this list of waiting jobs as part of its cleanup upon releasing control of the resource.</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="71744" class="autotag"> </a>A simple method is provided to ensure synchronized access to global data structures, such as routing tables, which are shared by different instances of a component or even separate components.  For more information, <a href="streams.doc13.html#71841"><i class="title">&#167;4.1.3.2&nbsp;Updating Shared Data with strmSyncWriteAccess(&nbsp;)</i></a>. </li></ul></p></dd></dl><dl class="margin"><dd><p class="Body"><a name="74346" class="autotag"> </a>A STREAMS component written for an SVR3 environment assumes that only a single thread can execute at any one time.  This type of component can operate in a multi-threaded environment like WindNet STREAMS.  With minor modifications, some components written originally for single-threaded execution can take advantage of multi-threaded functionality for gains in performance.  Both of these types of components require different levels of synchronization.  Components written to handle multi-threaded execution take yet another synchronization level.  WindNet STREAMS accommodates the extremes as well as the cases in between.  Each STREAMS component ported to WindNet STREAMS must be installed and associated with a suitable synchronization level.  Before assigning a synchronization level to a STREAMS component, make sure that you have read <a href="streams.doc12.html#75822"><i class="title">&#167;4.&nbsp;Porting STREAMS Protocols to WindNet STREAMS</i></a>.</p></dd></dl></dd></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="71746" class="autotag">4.1.1&nbsp;&nbsp;Synchronization Levels</a></i></h4></font><dl class="margin"><dd><dl class="margin"><dd><p class="Body"><a name="82284" class="autotag"> </a>Synchronization levels control the degree of parallelism allowed between separate threads of execution in a STREAMS component.  The four constants listed in <a href="streams.doc13.html#82355"><i class="title">Table&nbsp;5</i></a> specify levels of synchronization.  Synchronization levels are assigned when configuring components into WindNet STREAMS; see <a href="streams.doc16.html#72104"><i class="title">&#167;4.4&nbsp;Configuration of STREAMS Drivers and Modules in WindNet STREAMS</i></a>.  <a href="streams.doc13.html#87215"><i class="title">Figure&nbsp;13</i></a> shows two active instances of STREAMS Component A and Component B.  Both instances form a STREAMS data path and execute under WindNet STREAMS.  The explanations of the different levels of synchronization in the following subsections refer to the configuration of components in <a href="streams.doc13.html#87215"><i class="title">Figure&nbsp;13</i></a>.  The synchronization level constants can be found in the file<b class="keyword"> h/streams/sqlvl.h</b>.<p class="table"><h4 class="EntityTitle"><a name="82355" class="autotag"><font face="Helvetica, sans-serif" size="-1" class="sans">Table 5.  &nbsp;&nbsp;Synchronization Levels</font></a></h4><table border="0" cellpadding="3" cellspacing="0"><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="82359" class="autotag"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Synchronization Level</font></b></div></th><th rowspan="1" colspan="1"><div class="CellHeadingC" align="center"><a name="82361" class="autotag"> </a><b><font face="Helvetica, sans-serif" size="-1" class="sans">Description</font></b></div></th></tr><tr><td colspan="20"><hr class="tablerule2"></td></tr><tr valign="middle"><th rowspan="1" colspan="1"></th><th rowspan="1" colspan="1"></th></tr><tr><td colspan="20"><hr class="tablerule2"></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="82367" class="autotag"> </a><b>SQLVL_QUEUE</b></div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="82369" class="autotag"> </a>Synchronization is required for a single queue.</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="82371" class="autotag"> </a><b>SQLVL_QUEUEPAIR</b></div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="82373" class="autotag"> </a>Synchronization is required for a queue pair.</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="82375" class="autotag"> </a><b>SQLVL_MODULE</b></div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="82377" class="autotag"> </a>Synchronization is required for all queues in all instances of a component.</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="82379" class="autotag"> </a><b>SQLVL_GLOBAL</b></div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="82381" class="autotag"> </a>Synchronization is required for all queues in all instances of a family of cooperating components.</div></td></tr><tr valign="top"><td colspan=1 rowspan=1>

⌨️ 快捷键说明

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