﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>IT博客-Just think, Just do it -随笔分类-学习C C++</title><link>http://www.cnitblog.com/zfly/category/1777.html</link><description /><language>zh-cn</language><lastBuildDate>Tue, 27 Sep 2011 21:47:24 GMT</lastBuildDate><pubDate>Tue, 27 Sep 2011 21:47:24 GMT</pubDate><ttl>60</ttl><item><title>Byte and Bit Order Dissection</title><link>http://www.cnitblog.com/zfly/archive/2006/09/22/17184.html</link><dc:creator>zfly</dc:creator><author>zfly</author><pubDate>Fri, 22 Sep 2006 03:13:00 GMT</pubDate><guid>http://www.cnitblog.com/zfly/archive/2006/09/22/17184.html</guid><wfw:comment>http://www.cnitblog.com/zfly/comments/17184.html</wfw:comment><comments>http://www.cnitblog.com/zfly/archive/2006/09/22/17184.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/zfly/comments/commentRss/17184.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zfly/services/trackbacks/17184.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Skip navigation										.																																																																																																																																										...&nbsp;&nbsp;<a href='http://www.cnitblog.com/zfly/archive/2006/09/22/17184.html'>阅读全文</a><img src ="http://www.cnitblog.com/zfly/aggbug/17184.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zfly/" target="_blank">zfly</a> 2006-09-22 11:13 <a href="http://www.cnitblog.com/zfly/archive/2006/09/22/17184.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>big endian vs little endian</title><link>http://www.cnitblog.com/zfly/archive/2006/09/21/17156.html</link><dc:creator>zfly</dc:creator><author>zfly</author><pubDate>Thu, 21 Sep 2006 09:42:00 GMT</pubDate><guid>http://www.cnitblog.com/zfly/archive/2006/09/21/17156.html</guid><wfw:comment>http://www.cnitblog.com/zfly/comments/17156.html</wfw:comment><comments>http://www.cnitblog.com/zfly/archive/2006/09/21/17156.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/zfly/comments/commentRss/17156.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zfly/services/trackbacks/17156.html</trackback:ping><description><![CDATA[
		<p>// 测试2平台的 byte order, 经实测的结果见注释：供 porting code  分析参考<br /><br />// x86 platform<br /><br />#include "stdafx.h"<br />#include "stdio.h"</p>
		<p>int main(int argc, char* argv[])<br />{<br /> long int str[2] = {0x41424344, 0x0}; /* ASCII "ABCD" */</p>
		<p> struct<br />    {<br />      unsigned short y;<br />      unsigned short x;<br />    } p; </p>
		<p>   <br />   p.x = 0x1234;   <br />   p.y = 0x5678;</p>
		<p>   unsigned long *lparam,a;</p>
		<p>   lparam = (unsigned long *)&amp;p;<br />   a =  *lparam;</p>
		<p>   printf ("%s\n", (char *)&amp;str);       // x86    : "DCBA"  PowerPc: "ABCD"                                  <br />   printf ("%0x\n", a);                      // x86    :  12345678 (打印并非按内存次序)<br />   printf ("%0x\n", *((char*)&amp;a+1)); // x86    :  56</p>
		<p>                                  // powerpc: "ABCD"<br />                                  // powerpc: 56781234<br />                                  // powerpc: 78<br />           <br />   //  x86:                                         PowerPc<br />   //  &amp;a 内存分配 78 56 34 12       56 78 12 34 <br />   //  &amp;p 内存分配 78 56 34 12                 <br /> return 0;<br />}</p>
		<p>/*--------*/<br />/* PowerPC application test */<br /><br />#include "stdio.h"<br />#include &lt;sysLib.h&gt;<br />#include &lt;vxWorks.h&gt;<br />#include &lt;taskLib.h&gt;</p>
		<p>void t1()<br />{<br />  long int str[2] = {0x41424344, 0x0}; // ASCII "ABCD" </p>
		<p> struct<br />    {<br />      unsigned short y;<br />      unsigned short x;<br />    } p; </p>
		<p>   <br />   p.x = 0x1234;   <br />   p.y = 0x5678;</p>
		<p>   unsigned long *lparam,a;</p>
		<p>   lparam = (unsigned long *)&amp;p;<br />   a =  *lparam;</p>
		<p>   printf ("%s\n", (char *)&amp;str);  <br />   printf ("%0x\n", a);         <br /> }</p>
		<p>int t2()<br />{</p>
		<p>   long id;<br />   id=  taskSpawn("abc",120,VX_FP_TASK,20000,(FUNCPTR)t1,<br />   0,0,0,0,0,0,0,0,0,0);<br />   return 0;<br />}</p>
		<p> </p>
<img src ="http://www.cnitblog.com/zfly/aggbug/17156.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zfly/" target="_blank">zfly</a> 2006-09-21 17:42 <a href="http://www.cnitblog.com/zfly/archive/2006/09/21/17156.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Interrupt-Driven or Polled I/O?</title><link>http://www.cnitblog.com/zfly/archive/2006/08/03/14650.html</link><dc:creator>zfly</dc:creator><author>zfly</author><pubDate>Thu, 03 Aug 2006 09:29:00 GMT</pubDate><guid>http://www.cnitblog.com/zfly/archive/2006/08/03/14650.html</guid><wfw:comment>http://www.cnitblog.com/zfly/comments/14650.html</wfw:comment><comments>http://www.cnitblog.com/zfly/archive/2006/08/03/14650.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/zfly/comments/commentRss/14650.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zfly/services/trackbacks/14650.html</trackback:ping><description><![CDATA[
		<p>
				<u>
						<b>
								<font size="5">Interrupt-Driven or Polled I/O?</font>
						</b>
				</u>
		</p>
		<p>When designing an embedded system, a fundamental decision is the type of I/O scheme. Should we use interrupt-driven or polled I/O? We'll explore how this important decision has an impact not only on the firmware but on the hardware as well.<br /><br /></p>
		<p>
				<font size="4">
						<b>
								<u>Fishing for I/O</u>
						</b>
				</font>
		</p>
		<p>Polled I/O is much like fishing: there is a lot of waiting. In a polled I/O scheme, software is written to check the status of an I/O device. If there is no data to be received (Rx) or if the device is not ready to transmit (Tx), the software must wait. This technique is called busy-waiting. After waiting for some time, eventually the software can receive or transmit some data, and the rest of the software can execute (see Diagram 1).</p>
		<p align="center">
				<img height="376" src="http://www.base2software.com/eiarchives/ie200209/Polled_RxTx_Flow.jpg" width="561" />
		</p>
		<p align="center">
				<b>
						<u>Diagram 1: Flowchart for polled I/O</u>
				</b>
		</p>
		<p align="left">If this sounds inefficient, that's because it is. It's a very simple way of dealing with I/O with no surprises for the developer, but a lot of CPU time is spent waiting for data to transfer.</p>
		<p>Interrupt-driven I/O uses a little hardware to aid in efficiency. When the I/O device has already received some data or the I/O device is ready to transmit, an interrupt is generated, and the appropriate interrupt service routine (ISR) handles reading or writing some data. Interrupts add a level of complexity, and can be very difficult to debug, but the resulting system wastes no time waiting for data to transfer (see Diagram 2).</p>
		<p align="center">
				<img height="208" src="http://www.base2software.com/eiarchives/ie200209/Intr_RxTx_Flow.jpg" width="291" />
		</p>
		<p align="center">
				<b>
						<u>Diagram 2: Flowchart for interrupt-driven I/O</u>
				</b>
		</p>
		<p align="left">Yes, ISRs can be this simple. The above diagram shows separate ISRs for the receiver and transmitter if there are two separate interrupts. Sometimes there is only one interrupt for both functions, so the ISR is a little more complicated.<br /><br /></p>
		<p>
				<b>
						<font size="4">
								<u>Development Time</u>
						</font>
				</b>
		</p>
		<p>From the simple example above, it may appear that interrupts and ISRs are very easy to implement. In many cases they are, but they can also be very complicated. The development cost of ISRs is generally higher than polled I/O. Consider that you're not only developing the functionality of the polled I/O routines, but you've also got to deal with how interrupts work in your particular system. Polled I/O occurs at very specific points in the firmware (i.e. whenever the polled I/O routines are called). Interrupts can happen at anytime. An interrupt bug can cause anything from simple system crashes to really frustrating intermittent data loss and unreliable system performance.<br /><br /></p>
		<p>
				<font size="4">
						<b>
								<u>Which Is Best?</u>
						</b>
				</font>
		</p>
		<p>The decision to use polled or interrupt-driven I/O is usually pretty easy. If you've got the interrupt, use it! In the long run, even though it may take more time to develop, interrupt-driven I/O leads to a solid design, predictable performance, and holds up well to modifications of application code. However, if you've got a very simple design, using a straightforward polled I/O scheme may be preferable. There are a few factors which can influence your design.</p>
		<blockquote>
				<p>
						<b>Throughput.</b> If your system throughput requirements are very high, you must use interrupt-driven I/O. Polled I/O won't work because the CPU efficiency won't be high enough to move the data and do everything else. However, if you've got a specialized system with extremely high data rate requirements, it may actually be faster to use polled I/O. That's because polled I/O doesn't incur any interrupt overhead or interrupt latency (see below).</p>
				<p>
						<b>Interrupt latency.</b> Interrupt latency is the time it takes for the processor to respond to an interrupt event. These times range from 100's of nanoseconds to 10's of microseconds. In very rare cases, if interrupt latency is long or unpredictable, it may be preferable to poll for an event in very controlled conditions to ensure quick capture of an event.</p>
				<p>
						<b>Interrupt availability.</b> Most of today's microcontrollers have several external interrupts. If a hardware interrupt is not available, you will have no choice but to poll for I/O (see Simulating Interrupt-Driven I/O below). It's best to work with the electrical engineers to make sure that the microcontroller you choose works for both the electrical and firmware designs.</p>
		</blockquote>
		<p>By the way, there is no reason that you can't incorporate both types of I/O in a system. For example, perhaps your Ethernet driver uses interrupts and your serial port driver doesn't. It's all a matter of using a suitable technique for each situation.<br /><br /></p>
		<p>
				<b>
						<font size="4">
								<u>Simulating Interrupt-Driven I/O</u>
						</font>
				</b>
		</p>
		<p>So what if you've got a system where there are no more external interrupts and you want some interrupt-driven I/O? You can simulate interrupt-driven I/O by using a dedicated task in an RTOS. While you can't really address interrupt latency with this technique, it gives CPU time to other tasks when there is no data to receive or transmit. An example task is shown below which handles receiving and transmitting characters on a UART.</p>
		<p align="center">
				<img height="396" src="http://www.base2software.com/eiarchives/ie200209/UartTask.jpg" width="374" />
		</p>
		<p align="center">
				<b>
						<u>Diagram 3: Flowchart of UARTTask</u>
				</b>
		</p>
		<p>
				<br />
				<u>
						<font size="4">
								<b>Conclusion</b>
						</font>
				</u>
		</p>
		<p>Both polling and interrupt-driven techniques should be in the embedded designer's toolbox. While we recommend using interrupt-driven I/O whenever possible, it doesn't really matter which technique you use as long as the final design meets product requirements, is easy to understand, and is easy to maintain.</p>
<img src ="http://www.cnitblog.com/zfly/aggbug/14650.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zfly/" target="_blank">zfly</a> 2006-08-03 17:29 <a href="http://www.cnitblog.com/zfly/archive/2006/08/03/14650.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>IEC104</title><link>http://www.cnitblog.com/zfly/archive/2006/08/02/14571.html</link><dc:creator>zfly</dc:creator><author>zfly</author><pubDate>Wed, 02 Aug 2006 09:51:00 GMT</pubDate><guid>http://www.cnitblog.com/zfly/archive/2006/08/02/14571.html</guid><wfw:comment>http://www.cnitblog.com/zfly/comments/14571.html</wfw:comment><comments>http://www.cnitblog.com/zfly/archive/2006/08/02/14571.html#Feedback</comments><slash:comments>24</slash:comments><wfw:commentRss>http://www.cnitblog.com/zfly/comments/commentRss/14571.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zfly/services/trackbacks/14571.html</trackback:ping><description><![CDATA[
		<p>
				<font style="BACKGROUND-COLOR: #d3d3a9">发现Triangle MicroWorks, Inc公司不愧为专门写60870-5规约的公司，最近在看他们写的IEC 104 Master /Slave,写的确实精致。<br />回调函数，定时器用得很不错，层次，C中应用C++类的实现很清晰啊。<br /></font>
		</p>
<img src ="http://www.cnitblog.com/zfly/aggbug/14571.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zfly/" target="_blank">zfly</a> 2006-08-02 17:51 <a href="http://www.cnitblog.com/zfly/archive/2006/08/02/14571.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>枯燥！C 代码，读程序... ....</title><link>http://www.cnitblog.com/zfly/archive/2006/08/01/14521.html</link><dc:creator>zfly</dc:creator><author>zfly</author><pubDate>Tue, 01 Aug 2006 09:51:00 GMT</pubDate><guid>http://www.cnitblog.com/zfly/archive/2006/08/01/14521.html</guid><wfw:comment>http://www.cnitblog.com/zfly/comments/14521.html</wfw:comment><comments>http://www.cnitblog.com/zfly/archive/2006/08/01/14521.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/zfly/comments/commentRss/14521.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zfly/services/trackbacks/14521.html</trackback:ping><description><![CDATA[偷一下懒，上来发点信息。看C代码真是枯燥，歇会。<br /><br />C中书写class风格，实现封装：<br />strcut a{<br />ListMember memb;<br />InterfaceStruct  context;<br />}<br /><br />InterfaceStruct{<br />CallFuction A;<br />CallFuction B;<br />....<br />}<br /><br />通讯的分层： physical, link, transmit,application <br /><br />内存池的实现：动态分配，固定分配......<img src ="http://www.cnitblog.com/zfly/aggbug/14521.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zfly/" target="_blank">zfly</a> 2006-08-01 17:51 <a href="http://www.cnitblog.com/zfly/archive/2006/08/01/14521.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>http://www.xialala.com/</title><link>http://www.cnitblog.com/zfly/archive/2006/02/17/6668.html</link><dc:creator>zfly</dc:creator><author>zfly</author><pubDate>Fri, 17 Feb 2006 05:16:00 GMT</pubDate><guid>http://www.cnitblog.com/zfly/archive/2006/02/17/6668.html</guid><wfw:comment>http://www.cnitblog.com/zfly/comments/6668.html</wfw:comment><comments>http://www.cnitblog.com/zfly/archive/2006/02/17/6668.html#Feedback</comments><slash:comments>11</slash:comments><wfw:commentRss>http://www.cnitblog.com/zfly/comments/commentRss/6668.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zfly/services/trackbacks/6668.html</trackback:ping><description><![CDATA[<P><FONT style="BACKGROUND-COLOR: #d5d5d5">呵呵，这个网站，真是好！！<BR>以前提供下载的，音乐站点，前段时间由于版权问题，被迫改版。<BR><BR>2年前就发现了,今天重新上去，呵呵，还好不赖,所以推荐给大家！！<BR><BR>真是个好站点，好，好，好！！<BR>想听音乐，去看看吧。<BR><BR><A href="http://www.xialala.com/">http://www.xialala.com/</A><BR>.....<BR>.<BR>.<BR>.<BR>.<BR><BR></FONT></P><img src ="http://www.cnitblog.com/zfly/aggbug/6668.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zfly/" target="_blank">zfly</a> 2006-02-17 13:16 <a href="http://www.cnitblog.com/zfly/archive/2006/02/17/6668.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Nibble Memory 动态内存管理技术</title><link>http://www.cnitblog.com/zfly/archive/2006/02/07/6481.html</link><dc:creator>zfly</dc:creator><author>zfly</author><pubDate>Tue, 07 Feb 2006 02:57:00 GMT</pubDate><guid>http://www.cnitblog.com/zfly/archive/2006/02/07/6481.html</guid><wfw:comment>http://www.cnitblog.com/zfly/comments/6481.html</wfw:comment><comments>http://www.cnitblog.com/zfly/archive/2006/02/07/6481.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/zfly/comments/commentRss/6481.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zfly/services/trackbacks/6481.html</trackback:ping><description><![CDATA[<P><FONT size=1>在常见的规约编程中要用到内存分配，如要求严格则可利用Nibble Memory 策略，如要求更加<BR>严格且需要大块内存如数据库设计中的内存分配，则需自己些分配策略，我以前些的文章中<BR>有一些介绍，如firebird、MaxDB中，SQLite、apache中。在通讯规约中如电力规约,还有其他大型<BR>规约中那种频繁使用小块内存的协议栈，可考虑使用Nibble Memory 。<BR><BR>&nbsp;ICCP(TASE.2)是建立在MMS和ASN TCP/IP或ISO协议之上，在实现时可用Nibble Memory 策略，<BR>一些开源代码可参考snacc 、yaz等代码中。这些高质量代码往往可为我所用。<IMG height=19 src="http://www.cnitblog.com/Emoticons/regular_smile.gif" width=19 border=0><BR></FONT></P><img src ="http://www.cnitblog.com/zfly/aggbug/6481.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zfly/" target="_blank">zfly</a> 2006-02-07 10:57 <a href="http://www.cnitblog.com/zfly/archive/2006/02/07/6481.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ASN.1 -- MMS --ICCP ( TABSE2) --- 笔记            @_@</title><link>http://www.cnitblog.com/zfly/archive/2006/02/06/6450.html</link><dc:creator>zfly</dc:creator><author>zfly</author><pubDate>Mon, 06 Feb 2006 01:39:00 GMT</pubDate><guid>http://www.cnitblog.com/zfly/archive/2006/02/06/6450.html</guid><wfw:comment>http://www.cnitblog.com/zfly/comments/6450.html</wfw:comment><comments>http://www.cnitblog.com/zfly/archive/2006/02/06/6450.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/zfly/comments/commentRss/6450.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zfly/services/trackbacks/6450.html</trackback:ping><description><![CDATA[<P><FONT size=1>MMS的ASN.1规定( 8825-1 BER 8825-2 PER )</FONT></P>
<P><FONT size=1>&nbsp; 8&nbsp; 7&nbsp;&nbsp; 6&nbsp; 5&nbsp; 4&nbsp; 3&nbsp; 2&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Length&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Content<BR>-------------------------------------------------------------------------<BR>|Class |X |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Tag&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>-------------------------------------------------------------------------&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>Class:&nbsp;&nbsp;&nbsp; <BR>0 0 Universal<BR>0 1 Application<BR>1 0 Context-speciatic:指Type不需传送，双方约定 IMPLICIT<BR>1 1 prviate</FONT></P>
<P><FONT size=1>X :<BR>0 ---- primitive&nbsp;&nbsp; -----指定:content without a Structure 只有 1个Length 1个Content<BR>1 ---- contructed&nbsp; -----指定:content with addition structure <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (如squence,squence of , implicit squence ,implicit squence of )<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (Type , Length ,Content )任意个嵌套T-L-C<BR>Tag:<BR>ASN.1中Tag可能超过5个Bits,但是MMS中不会出现</FONT></P>
<P><FONT size=1>Length: 指Content的长度。可以任意长度，&nbsp; </FONT></P>
<P><FONT size=1>例子：<BR>1.单个OCTET STRING (ASN.1 key word )<BR>Type (= OCTET STRING), Length (= 5 Octets) and Content (= 24 65 4F EF F3 hex）<BR>&nbsp;T&nbsp; L&nbsp; C<BR>&nbsp;-&nbsp; -&nbsp; --------------<BR>&nbsp;04 05 24 65 4F EF F3<BR>&nbsp;<BR>2.有上下文中的[2]IMPLICIT OCTET STRING (多[2]IMPLICIT )<BR>&nbsp;T&nbsp; L&nbsp; C<BR>&nbsp;-&nbsp; -&nbsp; --------------<BR>&nbsp;82 05 24 65 4F EF F3<BR>&nbsp;--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;1 0 0 0 0 0 1 0&nbsp; 05&nbsp; 24 65 4F EF F3<BR>&nbsp;---&nbsp;&nbsp; ---------<BR>&nbsp;1 0 : Context-speciatic<BR>&nbsp;0 0 0 1 0: 02 primitive , value = 2<BR>&nbsp;<BR>&nbsp;3.有上下文中的[2] OCTET STRING (多个[2] 无关键字IMPLICIT )<BR>&nbsp; T&nbsp;&nbsp;&nbsp;&nbsp; L&nbsp; C<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -----------------------<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; T&nbsp;&nbsp;&nbsp; L&nbsp;&nbsp; C<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp; --------------<BR>&nbsp; 82&nbsp;&nbsp; 07&nbsp; 04&nbsp;&nbsp; 05&nbsp; 24 65 4F EF F3<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -----------------------&gt; OCTET STRING<BR>&nbsp;<BR>&nbsp;82: <BR>&nbsp; 1 0 1 0 0 0 1 0<BR>&nbsp; --- - ---------<BR>&nbsp; 1 0 : Context-speciatic<BR>&nbsp; 1&nbsp;&nbsp; : constructed<BR>&nbsp; <BR>The DER are particularly advisable for the coding of short messages; 适合短消息<BR>the CER are suitable for very long messages 适合长消息&nbsp;&nbsp;&nbsp;&nbsp; </FONT></P>
<P><FONT size=1>The "A0" in the first line says that it is a MMS definition <BR>(A = 1010 hex for the first four bits of the ASN.1 types - context-specific and constructed). <BR>The "0" is the tag that contains the number in square brackets on the right.&nbsp; </FONT></P>
<P><FONT size=1>数据映射到MMS</FONT></P>
<P><FONT size=1>ICCP (具体到购买何种Block)<BR>ICCP Server ObjectS<BR>1.Association<BR>2.Data Value<BR>3.Data Set<BR>4.Transfer Set<BR>5.Account&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>6.Device<BR>7.Program <BR>8.Event<BR>9.Conformance Blocks and Associated Objects&nbsp; <BR>9-1 Block 1 (Periodic Power System Data)保护事项对象是可选的<BR>&nbsp;&nbsp;&nbsp; Indication Point Object、 Status Points、Analog Points、Quality Codes<BR>&nbsp;&nbsp;&nbsp; Time Stamp、COV Counter、Protection Equipment Event Object<BR>&nbsp;&nbsp;&nbsp; <BR>9-2 Block 2 (Extended Data Set Condition Monitoring)<BR>&nbsp;&nbsp;&nbsp; 主要是用来report-by-exception, or RBE，以节省带宽。<BR>&nbsp;&nbsp;&nbsp; <BR>9-3 Block 3 (Block Data Transfer)&nbsp;<BR>&nbsp;&nbsp;&nbsp; 主要用来如何利用ASN.1节省传送字节<BR>&nbsp;&nbsp;&nbsp; <BR>9-4&nbsp;Block 4 (Information Messages)<BR>9-5&nbsp;Block 5 (Device Control)<BR>9-6&nbsp;Block 6 (Program Control)<BR>9-7&nbsp;Block 7 (Event Reporting)&nbsp;&nbsp;&nbsp;&nbsp; <BR>9-8&nbsp;Block 8 (Additional User Objects)<BR>9-9&nbsp;Block 9 (Time Series Data)</FONT></P>
<P><FONT size=1>Three TASE.2 operations are defined for use in managing associations: Associate, Conclude, and Abort<BR>Associate:用在客户端，用来跟服务器建立联系。 Conclude, Abort服务器、客户端均可用。</FONT></P>
<P><FONT size=1>数据传送机制<BR>a)&nbsp;One Shot Data<BR>b)&nbsp;Periodic Data<BR>c)&nbsp;Event Data<BR>d)&nbsp;Exception Data(如不变不送，... ... )</FONT></P>
<P><FONT size=1>Direct-Control (NonSBO)noninterlocked <BR>Select-Before-Operateinterlocked. (SBO) 带选择控制&nbsp; </FONT></P>
<P><FONT size=1>包含tag的service or data <BR>-------------------------------<BR>尚未知道的tag？？？？？<BR>#define AARE_apdu1&nbsp;0x61<BR>#define&nbsp;AARQ_apdu0&nbsp;0x60<BR>#define&nbsp;ABRT_apdu4&nbsp;0x64<BR>#define&nbsp;RLRE_apdu3&nbsp;0x63<BR>#define&nbsp;RLRQ_apdu2&nbsp;0x62</FONT></P>
<P><FONT size=1>#define&nbsp;acse_result_diagnostic3&nbsp;0xa3<BR>#define&nbsp;acse_result2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0xa2<BR>#define&nbsp;acse_service_user1&nbsp;&nbsp;&nbsp;&nbsp; 0xa1</FONT></P>
<P><FONT size=1>Data ::= CHOICE {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;-- context tag 0 is reserved for AccessResult&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;IF ( str1 )&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n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-- shall not be negative<BR>&nbsp;&nbsp;floating-point [7] IMPLICIT FloatingPoint,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --&nbsp; [8] is reserved&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;octet-string&nbsp;&nbsp; [9] IMPLICIT OCTET STRING,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;visible-string [10] IMPLICIT VisibleString,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;generalized-time [11] IMPLICIT GeneralizedTime,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;binary-time&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [12] IMPLICIT TimeOfDay,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;bcd&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [13]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size=1>GetNameList-Request ::= SEQUENCE {<BR>&nbsp;objectClass [0] ObjectClass,<BR>&nbsp;objectScope [1] CHOICE {<BR>&nbsp;vmdSpecific [0] IMPLICIT NULL,<BR>&nbsp;domainSpecific [1] IMPLICIT Identifier,<BR>&nbsp;aaSpecific&nbsp;&nbsp;&nbsp;&nbsp; [2] IMPLICIT NULL },<BR>&nbsp;continueAfter&nbsp; [2] IMPLICIT Identifier OPTIONAL }<BR>GetNameList-Response ::= SEQUENCE {<BR>&nbsp;listOfIdentifier [0] IMPLICIT SEQUENCE OF Identifier,<BR>&nbsp;moreFollows&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [1] IMPLICIT BOOLEAN DEFAULT TRUE }&nbsp; </FONT></P>
<P><FONT size=1>AcknowledgeEventNotification-Request ::= SEQUENCE {<BR>&nbsp;eventEnrollmentName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [0] ObjectName,<BR>&nbsp;acknowledgedState&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [2] IMPLICIT EC-State,<BR>&nbsp;timeOfAcknowledgedTransition [3] EventTime }&nbsp;<BR>&nbsp;<BR>ConfirmedServiceRequest包含很多choice</FONT></P>
<P><FONT size=1>flex ,yacc/bison 的脚本???&nbsp;&nbsp;&nbsp; </FONT></P>
<P><FONT size=1>RFC1006<BR>主要描述ISO 高4层利用TCP/IP的传输层功能来进行传输，实现ISO<BR>具体描述各种原语TP和TCP的对应关系</FONT></P>
<P><FONT size=1>参考文档:<BR>Transport service&nbsp; [ISO8072] <BR>Transport protocol [ISO8073]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></P>
<P><FONT size=1>In order to achieve good performance, the default TPDU size is<BR>65531 octets, instead of 128 octets. In order to negotiate a<BR>smaller (standard) TPDU size, the negotiation mechanism<BR>specified in [ISO8073] is used<BR>连接利用TCP 102端口</FONT></P>
<P><FONT size=1>TCP TP最大区别:TCP包是流式的，没有边界<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TP发送的是离散的对象(NSDUs).&nbsp;&nbsp; <BR>TP0 <BR>TP4 <BR>&nbsp;initiate negotiation初始化需要商讨的东西(Vendor需发布的东西)</FONT></P>
<P><FONT size=1>CASM<BR>ASCE </FONT></P>
<P><BR>&nbsp;</P><img src ="http://www.cnitblog.com/zfly/aggbug/6450.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zfly/" target="_blank">zfly</a> 2006-02-06 09:39 <a href="http://www.cnitblog.com/zfly/archive/2006/02/06/6450.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>下步学习内容！（下一代规约... ...  ASN.1不学不行啊！！)</title><link>http://www.cnitblog.com/zfly/archive/2006/01/16/6199.html</link><dc:creator>zfly</dc:creator><author>zfly</author><pubDate>Mon, 16 Jan 2006 04:30:00 GMT</pubDate><guid>http://www.cnitblog.com/zfly/archive/2006/01/16/6199.html</guid><wfw:comment>http://www.cnitblog.com/zfly/comments/6199.html</wfw:comment><comments>http://www.cnitblog.com/zfly/archive/2006/01/16/6199.html#Feedback</comments><slash:comments>11</slash:comments><wfw:commentRss>http://www.cnitblog.com/zfly/comments/commentRss/6199.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zfly/services/trackbacks/6199.html</trackback:ping><description><![CDATA[<P><FONT size=2>TASE.2 consists of three documents<BR>&nbsp;IEC 870-6-503 TASE.2 Services and Protocol<BR>&nbsp;IEC 870-6-702 TASE.2 Profiles<BR>&nbsp;IEC 870-6-802 TASE.2 Object Models</FONT></P>
<P><FONT size=2>Telecontrol Application Service Element (TASE.2)<BR>Inter-Control Centre Communications Protocol, ICCP</FONT></P>
<P><FONT size=2>RFC1006</FONT></P>
<P><FONT size=2>ASN.1 ACSE </FONT></P>
<P><FONT size=2>Abstract Syntax Notation 1 (ASN.1)<BR>( ISO/IEC 8824 and 8825 )</FONT></P>
<P><FONT size=2>ISO/IEC 8824-1:1998, Information technology - Abstract Syntax Notation One (ASN.1): Specification of<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; basic notation<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>ISO/IEC 8824-2:1998, Information technology - Abstract Syntax Notation One (ASN.1): Information object<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; specification<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>ISO/IEC 8825-1:1998, Information technology - ASN.1 encoding rules: Specification of Basic Encoding<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Rules (BER), Canonical Encoding Rules (CER, and Distinguished Encoding Rules (DER)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>ISO/IEC 8825-2:1998, Information technology - ASN.1 encoding rules: Specification of Packed Encoding<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Rules (PER)</FONT></P>
<P><FONT size=2>ISO/ISP 14226-1:1996 Industrial automation systems -- International Standardized Profile AMM11:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MMS General Applications Base Profile -- Part 1: Specification of ACSE, <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Presentation and Session protocols for use by MMS </FONT></P>
<P><FONT size=2>ISO/ISP 14226-2:1996 Industrial automation systems -- International Standardized Profile AMM11: <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MMS General Applications Base Profile -- Part 2: Common MMS requirements </FONT></P>
<P><FONT size=2>ISO/ISP 14226-3:1996 Industrial automation systems -- International Standardized Profile AMM11: <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MMS General Applications Base Profile -- Part 3: Specific MMS requirements<BR>&nbsp;<BR>学习好地方<BR></FONT><A href="http://www.ncepu.com.ru/home/html/f72.html"><FONT size=2>http://www.ncepu.com.ru/home/html/f72.html</FONT></A><FONT size=2>(有些参考论文)<BR></FONT><A href="http://corba.blogbus.com/index.html"><FONT size=2>http://corba.blogbus.com/index.html</FONT></A><FONT size=2>(个人blog)<BR><BR>====================================<BR>&nbsp;IEC 870-6-503 TASE.2 Services and Protocol<BR>&nbsp;IEC 870-6-702 TASE.2 Profiles<BR>&nbsp;IEC 870-6-802 TASE.2 Object Models<BR>文档google到了，只是比较旧的<BR><BR>最近得好好学习ASN.1了，这玩艺看样子，应用挺广的<BR>不学不行啊！！<BR><BR>有正学习ASN.1的相互交流啊！！！<BR><BR>ASN.1 --- MMS ----ICCP -----IEC 61850<BR><BR>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<BR>An asterisk (*) following two names, "A" and "B", denotes the "empty" lexical item (see 11.7), or one of the permitted sequences of lexical items associated with "A", or an alternating series of one of the sequences of lexical items associated with "A" and one of the sequences of lexical items associated with "B", both starting and finishing with one associated with "A". Thus:&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;C ::= A B * (空或者以A开头和以A结尾的条目)<BR>is equivalent to:<BR>&nbsp;&nbsp;C ::= D | empty<BR>&nbsp;D ::= A | A B D<BR>"D" being an auxiliary name not appearing elsewhere in the productions.<BR>EXAMPLE – "C ::= A B *" is the shorthand notation for the following alternatives of C:<BR>&nbsp;&nbsp;empty<BR>&nbsp;A<BR>&nbsp;A B A<BR>&nbsp;A B A B A<BR>&nbsp;A B A B A B A<BR>--------------------------------------<BR>E ::= A B +&nbsp; (以A开头和以A结尾的条目,不能为空)<BR>--------------------------------------<BR>F ::= A ? (为空或A串)<BR><BR><FONT face=宋体>编码的基本原则是类型—长度—值的三段式结构，简称TLV（Type</FONT><SPAN lang=EN-US>—</SPAN><SPAN lang=EN-US style="FONT-FAMILY: 宋体">Length--Value）结构</SPAN><BR></FONT><FONT size=2><FONT color=#ff0000><STRONG>ASN.1</STRONG><FONT color=#000000><FONT face=宋体>编码的基本型结构和递归型结构</FONT></FONT><BR clear=all></FONT>ASN.1 TAG含义：<BR>Bits 7,6&nbsp;&nbsp;&nbsp;&nbsp; Type of tag<BR>Bit&nbsp; 5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Primitive or Constructed Flag<BR>Bit&nbsp; 4-0&nbsp;&nbsp;&nbsp;&nbsp; Tag value</FONT><BR><BR><IMG height=181 src="http://ww.mhkj.com/JIAOCAI/finish/htmls/contents/chapter9/neirong/602.files/image001.gif" width=397 v:shapes="_x0000_s1026 _x0000_s1027 _x0000_s1028 _x0000_s1029 _x0000_s1030 _x0000_s1031 _x0000_s1032 _x0000_s1033 _x0000_s1034 _x0000_s1035 _x0000_s1036 _x0000_s1037 _x0000_s1038 _x0000_s1039 _x0000_s1040 _x0000_s1041 _x0000_s1042 _x0000_s1043 _x0000_s1044 _x0000_s1045 _x0000_s1046"><BR><BR><IMG height=195 src="http://ww.mhkj.com/JIAOCAI/finish/htmls/contents/chapter9/neirong/602.files/image002.gif" width=250 v:shapes="_x0000_s1047 _x0000_s1048 _x0000_s1049 _x0000_s1050 _x0000_s1051 _x0000_s1052 _x0000_s1053 _x0000_s1054 _x0000_s1055 _x0000_s1056 _x0000_s1057 _x0000_s1058 _x0000_s1059 _x0000_s1060 _x0000_s1061 _x0000_s1062 _x0000_s1063 _x0000_s1064 _x0000_s1065 _x0000_s1066 _x0000_s1067 _x0000_s1068 _x0000_s1069 _x0000_s1070 _x0000_s1071 _x0000_s1072 _x0000_s1073 _x0000_s1074 _x0000_s1075 _x0000_s1076 _x0000_s1077 _x0000_s1078 _x0000_s1079 _x0000_s1080 _x0000_s1081 _x0000_s1082"><BR><BR><FONT size=2>ASN.1有四种类型：<BR>简单类型，它相当于原子，没有下层组件；<BR>结构类型，有组成部分；<BR>标签类型，由其它类型生成；<BR>其它类型，包括CHOICE和ANY类型。<BR>可以使用ASN.1的分配符（::=）给类型和值指定名字，这些名字可以用于定义其它类型或值。<BR><BR>除了CHOICE和ANY类型以外，每种ASN.1类型都有一个标签，由一个类和一个非负的标签数组成。标签值可以唯一区分ASN.1类型。也就是说，ASN.1类型的名字并不影响它的抽象含义，只有标签值才有这个作用。有四类标签：<BR><BR>●Universal：该类型的含义在所有的application中都相同。这种类型只在X.208中定义。<BR>●Application：该类型的含义由application决定，如X.500目录服务。两个不同的application中的类型可以具有相同的application-specific标签但是可以具有不同的含义。<BR>●Private：,该类型的含义根据给定的企业而不同。<BR>●Context-specific：该类型的含义根据给定的结构类型而不同。Context-specific标签用于在一个给定的结构类型上下文中区分使用相同的下层标签的组件类型。在两个不同的结构类型中组件类型可以具有相同的标签但是含义不同。<BR><BR>MMS中<BR>Bits 7,6&nbsp;&nbsp;&nbsp; Bit 5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Description, key words<BR>--------&nbsp;&nbsp;&nbsp;&nbsp; -----&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;-------------------------<BR>0 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Description: Universal Tag, Primitive<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Example keywords: INTEGER, BITSTRING, BOOLEAN<BR>0 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Description: Universal Tag, Constructed<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Example keyword: SEQUENCE, SEQUENCE OF<BR>1 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Description: Context Specific, Primitive<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Example Keyword: IMPLICIT<BR>1 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Description: Context Specific, Constructed<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Example Keywords: IMPLICIT SEQUENCE<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IMPLICIT SEQUENCE OF<BR>-----------------------------------------------------------------------------------------<BR>识别符由小写字母开头，类型索引由大写字母开头。<BR>类型索引由大写字母开头。<BR><BR>简单类型（Simple&nbsp;types）<BR>&nbsp;&nbsp;&nbsp; ●BIT&nbsp;STRING:由0和1任意组成的比特流<BR>&nbsp;&nbsp;&nbsp;&nbsp;●IA5String:由IA5(ASCII)字符任意组成的字符流<BR>&nbsp;&nbsp;&nbsp;&nbsp;●INTEGER:一个任意的整数<BR>&nbsp;&nbsp;&nbsp;&nbsp;●NULL:null值<BR>&nbsp;&nbsp;&nbsp;&nbsp;●OBJECT&nbsp;IDENTIFIER:对象识别符，有一列整数构成，用于确定对象，如算法或属性类型<BR>&nbsp;&nbsp;&nbsp;&nbsp;●OCTET&nbsp;STRING:任意的octet（8bit值）流<BR>&nbsp;&nbsp;&nbsp;&nbsp;●PrintableString:任意可打印字符流<BR>&nbsp;&nbsp;&nbsp;&nbsp;●T61String:T.61（8bit）字符的任意流<BR>&nbsp;&nbsp;&nbsp;&nbsp;●UTCTime:"coordinated&nbsp;universal&nbsp;time"或者格林威治平均时（GMT）值。<BR><BR>结构化类型<BR>&nbsp;&nbsp;&nbsp; ●SEQUENCE:一个或多个类型的有序集合<BR>&nbsp;&nbsp;&nbsp;&nbsp;●SEQUENCE&nbsp;OF:0个或某个给定类型多次出现的有序集合<BR>&nbsp;&nbsp;&nbsp;&nbsp;●SET:一个或多个类型的无序集合<BR>&nbsp;&nbsp;&nbsp;&nbsp;●SET&nbsp;OF:0个或某给定类型多次出现的无序集合<BR><BR>隐式和显式标签类型<BR>●隐式标签类型是在其它类型基础上通过改变其下层类型的标签生成的。<BR>●显式标签是在其它类型基础上通过在其下层类型的标签之外添加一个外层标签生成的。从效果上看，显式标签类型是包含一个组件的结构类型，该组件即下层类型。<BR><BR>其他类型<BR>包括CHOICE和ANY类型。<BR>●CHOICE类型表示一个联合体，它具有一个或多个备选项（alternative）；<BR>●ANY类型表示任意类型的任意值，其中任意类型可能在使用对象识别符或整数值注册中定义。<BR><BR>基本编码规则BER（Basic&nbsp;Encoding&nbsp;Rules）<BR>●三种编码方法<BR>&nbsp;&nbsp; 基本的，&nbsp;&nbsp;&nbsp;&nbsp; 定长编码；<BR>&nbsp; &nbsp;结构化的，定长编码；<BR>&nbsp;&nbsp; 结构化的，不定长编码<BR><BR>简单的non-string类型使用第一种（简单、定长编码）；结构类型可使用任一种结构化的编码方法；简单的string类型根据值的长度是否已知可使用任一种方法。隐式标签定义的类型可使用下层类型的方法，显式标签定义的类型使用结构化的编码方法。<BR><BR>&nbsp;每种BER编码方法都有三或四部分：<BR></FONT><FONT color=#000000 size=2>&nbsp;●Identifier&nbsp;octets:定义了ASN.1值的类和标签值，指明编码方法是简单化的还是结构化的。<BR>&nbsp;●Length&nbsp;octets:对于定长编码方法，它指出了内容octet的个数；对于结构化、非定长编码方法，它指名长度是不确定的。<BR>&nbsp;●Contents&nbsp;octets:对于简单的、定长编码方法，它给出了值的具体表示；对于结构化的方法，它给出了值的内容的BER编码的串联。<BR>&nbsp;●End-of-contents&nbsp;octets:对于结构化、非定长的编码方法，它表示内容结束；对于其它方法，没有该部分。<BR><BR>简单定长方法（Primitive,&nbsp;definite-length&nbsp;method）<BR>这种方法用于简单类型及通过对简单类型使用隐式标签生成的类型。它要求值的长度是事先预知的<BR><BR></FONT><FONT color=#000000><FONT size=2><U>1.Identifier&nbsp;octets，有两种形式：较小的标签值（标签值在0和30之间）和较大的标签值（标签值大于等于31）<BR></U>&nbsp;●Low-tag-number&nbsp;form：一个octet。Bit8和bit7表示类（如表2），bit6值为0，表示编码方法为简单化的。Bit5－1给出了标签值。如下表所示：<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Class&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;Bit&nbsp;8&nbsp;&nbsp;&nbsp;&nbsp;Bit&nbsp;7<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;universal&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;application&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;context-specific&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;1<BR>●High-tag-number&nbsp;form：两个或多个octet。第一个octet形式如low-tag-number&nbsp;form，但是bit5－1均为1。第二个和以后的octet给出标签值，基于128，最高位在先，以便使用尽可能少的数字，每个octet的bit8都置为1，最后一个为0。<BR><BR></FONT></FONT><FONT size=2><FONT color=#000000><U>2.Length&nbsp;octets：有两种格式：短型（长度在0至127之间）和长型（长度在0至21008-1之间）</U><BR>●Short&nbsp;form:&nbsp;一个octet，bit8为0，bit7－1表示长度。<BR>●Long&nbsp;form:&nbsp;2－127个octet。第一个octet的Bit8为1，bit7－1表示后面有多少个用于表示实际长度的octet。第二个和随后的octet给出实际长度，基于256，高位数字在先。<BR><BR></FONT><FONT color=#000000>3.Contents&nbsp;octets：给出了值的具体表示（如果类型是由隐式标签定义的，则给出了下层类型的值）</FONT></FONT></P>
<H3><FONT color=#000000>3.2&nbsp;结构化定长方法（Constructed,&nbsp;definite-length&nbsp;method）</FONT></H3>
<P><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<FONT size=2>结构化的、定长方法适用于简单的string类型、结构类型、在二者基础上通过隐式标签生成的类型和在任何类型基础上由显式标签生成的类型。要求值的长度事先已知。BER编码方法各部分如下：<BR><BR></FONT></FONT><FONT color=#000000><FONT size=2><U>&nbsp;1．Identifier&nbsp;octets：与第3.1节介绍的一样，但bit6的值为1，表示编码方法是结构化的。</U><BR>&nbsp;<U>2．Length&nbsp;octets：见第3.1节。</U><BR>&nbsp;<U>3．Contents&nbsp;octets，值的组件的BER编码的串联</U></FONT></FONT></P>
<P><FONT color=#000000 size=2>●对于简单string类型和在其基础上由隐式标签生成的类型，是值的连续子串的BER编码的串联（隐式标签的下层值）<BR>●对于结构类型和在其基础上由隐式标签生成的类型，是值的组件的BER编码的串联（隐式标签的下层值）<BR>●对于在任何类型基础上使用显式标签生成的类型，是下层值的BER编码特定类型的细节见第5节。</FONT></P>
<P><FONT color=#000000 size=2>3.3&nbsp;结构化非定长方法（Constructed,&nbsp;indefinite-length&nbsp;method）</FONT></P>
<P><FONT color=#000000 size=2>&nbsp;&nbsp;&nbsp;&nbsp;结构化的、非定长编码用于简单string类型、结构类型、在二者基础上使用隐式标签生成的类型和在任何类型基础上使用显式标签生成的类型。不要求事先知道值的长度。BER编码各部分如下：<BR></FONT><FONT color=#000000><BR><FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp;●Identifier&nbsp;octets，见第3.2节<BR>&nbsp;&nbsp;&nbsp;&nbsp;●Length&nbsp;octets.一个octet，值为80<BR>&nbsp;&nbsp;&nbsp;&nbsp;●Contents&nbsp;octets.见第3.2节。<BR>&nbsp;&nbsp;&nbsp;&nbsp;●End-of-contents&nbsp;octets两个octet，为00&nbsp;&nbsp;00。<BR></FONT></FONT><BR><FONT color=#000000><FONT size=2>&nbsp;由于end-of-contents&nbsp;octet出现在通常普通BER编码出现的位置（例如，在一个sequence值的内容octet出现的位置），可把00和00分别视为identifier和length&nbsp;octet。因此end-of-contents&nbsp;octet实际上是一个具有universal&nbsp;class，标签值为0，长度为0的值的简单定长编码。<BR>----------------------------------------------------------------<BR>部分摘自:<BR>RSA实验室技术笔记<BR>作者：Burton&nbsp;S.Kaliski&nbsp;Jr.<BR>最终修订日期：Nov&nbsp;1，1993<BR>翻译：David(</FONT><A class=l2 href="mailto:david@javaresearch.org" target=_blank><FONT size=2>David@javaresearch.org</FONT></A><FONT size=2>),2002年6月<BR>----------------------------------------------------------------</FONT></FONT></P><img src ="http://www.cnitblog.com/zfly/aggbug/6199.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zfly/" target="_blank">zfly</a> 2006-01-16 12:30 <a href="http://www.cnitblog.com/zfly/archive/2006/01/16/6199.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Cygwin(或linux) 中环境变量的配置(要区分BASH 和TCSH）</title><link>http://www.cnitblog.com/zfly/archive/2006/01/09/6094.html</link><dc:creator>zfly</dc:creator><author>zfly</author><pubDate>Mon, 09 Jan 2006 04:54:00 GMT</pubDate><guid>http://www.cnitblog.com/zfly/archive/2006/01/09/6094.html</guid><wfw:comment>http://www.cnitblog.com/zfly/comments/6094.html</wfw:comment><comments>http://www.cnitblog.com/zfly/archive/2006/01/09/6094.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/zfly/comments/commentRss/6094.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zfly/services/trackbacks/6094.html</trackback:ping><description><![CDATA[<P>Cygwin 中环境变量的配置：<BR>eg:<BR>1. To see the current value of a particular<BR>&nbsp;variable, use "printenv ".<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp; &gt; printenv HOME<BR>&nbsp;&nbsp; /home/yap</P>
<P>2. ":"-separated paths :为分割符<BR>3. set PATH in BASH Shell as follows:<BR>&nbsp;&nbsp; &gt; export PATH=.:/home/yap/bin:/bin:/usr/local/bin<BR>&nbsp;&nbsp; <BR>4. in TCSH Shell, you would do:<BR>&nbsp;&nbsp; &gt; setenv PATH=.:/home/yap/bin:/bin:/usr/local/bin<BR>&nbsp; <BR>&nbsp;This says to look first in the current directory ".", then /home/yap/bin,<BR>&nbsp;then /bin, and finally /usr/local/bin.&nbsp; </P>
<P>5. <BR>&nbsp;Better still, since you do not know what the previous value<BR>&nbsp;of PATH is, it is best to simply append what you want to<BR>&nbsp;the front or back of the current value of PATH. <BR>&nbsp;<BR>&nbsp;&gt; export PATH=.:/home/yap/bin:`printenv PATH`</P><img src ="http://www.cnitblog.com/zfly/aggbug/6094.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zfly/" target="_blank">zfly</a> 2006-01-09 12:54 <a href="http://www.cnitblog.com/zfly/archive/2006/01/09/6094.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一些C经典用法（笔记）</title><link>http://www.cnitblog.com/zfly/archive/2006/01/09/6088.html</link><dc:creator>zfly</dc:creator><author>zfly</author><pubDate>Mon, 09 Jan 2006 01:38:00 GMT</pubDate><guid>http://www.cnitblog.com/zfly/archive/2006/01/09/6088.html</guid><wfw:comment>http://www.cnitblog.com/zfly/comments/6088.html</wfw:comment><comments>http://www.cnitblog.com/zfly/archive/2006/01/09/6088.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/zfly/comments/commentRss/6088.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zfly/services/trackbacks/6088.html</trackback:ping><description><![CDATA[<P><FONT size=1>2006.1.7 :<U>底层C编写的常用 用法</U></FONT><FONT size=1><BR>&nbsp; /* The following macros process structure members:&nbsp; to determine the&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */<BR>&nbsp; /* offset of a structure member from the beginning of the structure, and&nbsp;&nbsp; */<BR>&nbsp; /* to detemine the size of a member of a structure.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */</FONT></P>
<P><FONT size=1>&nbsp; #define DEFS_OFFSET(s,m)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (DEFS_UI16)&amp;(((s *)0)-&gt;m)<BR>&nbsp; #define DEFS_MEMBER_SIZE(s,m)&nbsp; sizeof(((s *)0)-&gt;m)</FONT></P>
<P><FONT size=1>&nbsp; /* The following macros make it easier to specify binary numbers. For&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */<BR>&nbsp; /* example, to specify a byte in binary:&nbsp; DEFS_BINARY(01100001) or to&nbsp;&nbsp; */<BR>&nbsp; /* specify a word in binary:&nbsp; DEFS_BINARY_WORD(00111101,11001010)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */</FONT></P>
<P><FONT size=1>&nbsp; #define DEFS_BINARY_CONVERT(byte) (((byte &amp; 0x10000000L) / 0x200000L) +&nbsp; \<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((byte &amp; 0x01000000L) / 0x040000L) +&nbsp; \<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((byte &amp; 0x00100000L) / 0x008000L) +&nbsp; \<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n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&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((byte &amp; 0x00000001L) / 0x000001L))</FONT></P>
<P><FONT size=1>&nbsp; #define DEFS_BINARY(byte) DEFS_BINARY_CONVERT(0x##byte)</FONT></P>
<P><FONT size=1>&nbsp; #define DEFS_BINARY_WORD(high,low) (DEFS_BINARY_CONVERT(0x##high) * 256) + \</FONT></P>
<P><FONT size=1><U>2006.1.7 字节交换顺序</U><BR><BR>/* This is a set of routines for demonstrating the effects of<BR>&nbsp;byte ordering between little endian and big endian machines</FONT></P>
<P><FONT size=1>&nbsp;Big Endian (B_ENDIAN == TRUE):</FONT></P>
<P><FONT size=1>&nbsp;&nbsp;MSB [ n | n+1 | n+2 | n+3 ] LSB</FONT></P>
<P><FONT size=1>&nbsp;Little Endian (B_ENDIAN == FALSE):</FONT></P>
<P><FONT size=1>&nbsp;&nbsp;MSB [ n+3 | n+2 | n+1 | n] LSB</FONT></P>
<P><FONT size=1>&nbsp;little/big-endian is bitness as well.&nbsp; For example,</FONT></P>
<P><FONT size=1>&nbsp;&nbsp;struct {<BR>&nbsp;&nbsp;&nbsp;short b:5,&nbsp;&nbsp; --- we _want_ signed for the example ---<BR>&nbsp;&nbsp;&nbsp;c:11;<BR>&nbsp;&nbsp;};</FONT></P>
<P><FONT size=1>&nbsp;is stored in little-endian (gint32el) ['+' denotes sign bit]:</FONT></P>
<P><FONT size=1>&nbsp;tf_Bitstream view --&gt;<BR>&nbsp;&nbsp; 0123456789A BCDEF<BR>&nbsp;&nbsp;|-----c----+|--b-+|</FONT></P>
<P><FONT size=1>&nbsp;Whereas bigendian (Motorola) stores it thus:</FONT></P>
<P><FONT size=1>&nbsp;tf_Bitstream view --&gt;<BR>&nbsp;&nbsp; FEDCB A9876543210<BR>&nbsp;&nbsp;|+-b--|+----c-----| </FONT></P>
<P><FONT size=1>&nbsp;So, you have to invert bits as well to convert endianness.</FONT></P>
<P><FONT size=1>&nbsp;#define Gettf_Bit(Val,Idx) ( ( (Val) &amp; (1&lt;&lt;(Idx)) ) )<BR>&nbsp;#define Settf_Bit(Val,Idx,tf_Bit) ( ( (Val) &amp; (~(1&lt;&lt;Idx)) ) | ((tf_Bit)&lt;&lt;(Idx)) )<BR>&nbsp;for ( i = 0; i &lt; sizeof(Val)*8; i++)<BR>&nbsp;&nbsp;&nbsp; NewVal = Settf_Bit(NewVal,sizeof(Val)*8-i-1, Gettf_Bit(Val,i));<BR>*/&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></P>
<P><FONT size=1><U>DNP<BR></U>DnpMasterStart<BR>&nbsp; --&gt; taskSpawn ("tDnpMaster", priority, VX_FP_TASK, 0x8000,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (FUNCPTR) DnpMasterTask,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (int) ini_name, 0, 0, 0, 0, 0, 0, 0, 0, 0)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp; dnpMasterTask ---&gt; dnp_init()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ---&gt; ca_task_initialize()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ---&gt; ca_add_fd_registration()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ---&gt; 从配置文件中得到dnp的配置信息<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ---&gt; pdpdvrs_initDNP()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ---&gt; addr_init()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ---&gt; dnp_loop()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp; DnpMasterAddDevice<BR>&nbsp; DnpMasterAdd8550<BR>&nbsp; DnpMasterAddText<BR>&nbsp; <BR>&nbsp; DNP　PEER TO PEER<BR>&nbsp; <BR>&nbsp; 一些debug信息<BR>&nbsp; <BR>&nbsp; 物理层<BR>&nbsp; 　．利用查表法来确定链路层的长度<BR>&nbsp; ---&gt;． pdpphys_initPhysRecMgr 物理层初始化，分配内存<BR>&nbsp; 　&nbsp; ． valid_address() <BR>&nbsp; 　　． pdpphys_parseDNPframe()　<BR>&nbsp; <BR>&nbsp; <BR>&nbsp; DnpMasterTask<BR>&nbsp;&nbsp;<BR><BR>========================================================<BR><BR>&nbsp; <U>串口：从温旧梦<BR></U><BR>&nbsp; 　非重叠模式优点　．直接<BR>&nbsp; 　　　　　　　　　．易移植<BR>&nbsp; 　　　　　　缺点　．线程中读、写相互堵塞<BR>&nbsp; 　　　　　　　　　．线程间相互堵塞（包括读之间，写之间，读写之间）<BR>&nbsp; <BR>&nbsp; 　　　　　　单片机，嵌入式如vxworks，任务中相对简单的程序中常用<BR>&nbsp; <BR>&nbsp; 　重叠模式　优点　．灵活，效率高（后台执行操作）<BR>&nbsp; 　　　　　　　　　．多线程间，线程中，读写操作不会相互堵塞<BR>&nbsp; 　　　　　　缺点　．不那么直接<BR>&nbsp; 　　　　　　　　　．不易于移植<BR>&nbsp; 　<BR>&nbsp; EV_RXCHAR：事件通知模式用在非重叠模是一个比较好的方式，因为程序不用轮询串口，以节省CPU的thread quantum<BR>&nbsp; 　　　　　 方式如下：<BR>&nbsp; 　　　　　DWORD dwCommEvent;<BR>&nbsp;&nbsp;&nbsp;DWORD dwRead;<BR>&nbsp;&nbsp;&nbsp;char&nbsp; chRead;<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;if (!SetCommMask(hComm, EV_RXCHAR))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Error setting communications event mask.<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;for ( ; ; ) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (WaitCommEvent(hComm, &amp;dwCommEvent, NULL)) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (ReadFile(hComm, &amp;chRead, 1, &amp;dwRead, NULL))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // A byte has been read; process it.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // An error occurred in the ReadFile call.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Error in WaitCommEvent.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;问题出现在：当多个字节连续的发送，第１个byte到，引起EV_RXCHAR 事件发生，<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WaitCommEvent指示可读．第２个byte紧接着到，EV_RXCHAR只是在内部置位，<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 当第１个byte读完，调用WaitCommEvent时，系统再次指示EV_RXCHAR 事件发生，<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 可读第２个byte,问题出现在当第２个字符到达，而没有被读出时，第３个字符到<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 达了，此时系统也期望将对应于第３个字符的EV_RXCHAR置位，但是系统中的<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EV_RXCHAR标志位已经被第２个已经置位了，于是就被忽略，当第２个自负读出<BR>&nbsp;&nbsp;　　　　　　后，只能在系统缓冲区，等待第４个字符到，而读出第３个字符，这样代码和系统<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 就失去同步。<BR>&nbsp;&nbsp;&nbsp;　　　　　　（我觉得这种情况在一般情况下不会出现,在单片机、<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 嵌入式应该是一个一个字符往外蹦，）<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;　　　　　　而且WaitCommEvent会导致很多其它事件丢失，在高速情况下。<BR>&nbsp;&nbsp;　　　　　　　　<BR>&nbsp;&nbsp;　　解决办法是：利用ClearCommError判断缓冲中的字符个数，一次性读完所有到达字符 </FONT></P><BR><img src ="http://www.cnitblog.com/zfly/aggbug/6088.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zfly/" target="_blank">zfly</a> 2006-01-09 09:38 <a href="http://www.cnitblog.com/zfly/archive/2006/01/09/6088.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>FASTDB的表=对象的映射</title><link>http://www.cnitblog.com/zfly/archive/2006/01/04/5992.html</link><dc:creator>zfly</dc:creator><author>zfly</author><pubDate>Wed, 04 Jan 2006 01:11:00 GMT</pubDate><guid>http://www.cnitblog.com/zfly/archive/2006/01/04/5992.html</guid><wfw:comment>http://www.cnitblog.com/zfly/comments/5992.html</wfw:comment><comments>http://www.cnitblog.com/zfly/archive/2006/01/04/5992.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/zfly/comments/commentRss/5992.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zfly/services/trackbacks/5992.html</trackback:ping><description><![CDATA[<DT><B>FIELD(</B>name<B>)</B> 
<DD>Non-indexed field with specified name. <BR><BR>
<DT><B>KEY(</B>name, index_type<B>)</B> 
<DD>Indexed field. <I>index_type</I> should be a combination of <CODE>HASHED</CODE> and <CODE>INDEXED</CODE> flags. When the <CODE>HASHED</CODE> flag is specified, FastDB will create a hash table for the table using this field as a key. When the <CODE>INDEXED</CODE> flag is specified, FastDB will create a (special kind of index) T-tree for the table using this field as a key.<BR><BR></DD>
<DT><B>RELATION(</B>reference, inverse_reference<B>)</B> 
<DD>Specifies <I>one-to-one, one-to-many</I> or <I>many-to-many</I> relationships between classes (tables). Both <I>reference</I> and <I>inverse_reference</I> fields should be of reference or of array of reference type. <CODE>inverse_reference</CODE> is a field of the referenced table containing the inverse reference(s) to the current table. Inverse references are automatically updated by FastDB and are used for query optimization</DD><img src ="http://www.cnitblog.com/zfly/aggbug/5992.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zfly/" target="_blank">zfly</a> 2006-01-04 09:11 <a href="http://www.cnitblog.com/zfly/archive/2006/01/04/5992.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>wDo系统实现的初步想法！</title><link>http://www.cnitblog.com/zfly/archive/2005/12/26/5796.html</link><dc:creator>zfly</dc:creator><author>zfly</author><pubDate>Mon, 26 Dec 2005 07:35:00 GMT</pubDate><guid>http://www.cnitblog.com/zfly/archive/2005/12/26/5796.html</guid><wfw:comment>http://www.cnitblog.com/zfly/comments/5796.html</wfw:comment><comments>http://www.cnitblog.com/zfly/archive/2005/12/26/5796.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/zfly/comments/commentRss/5796.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zfly/services/trackbacks/5796.html</trackback:ping><description><![CDATA[just do it at first !!!<BR>in first , design not&nbsp;too complex <BR><BR>Maybe to study python a bit more .<BR><A href="/Files/zfly/thinkX.rar"><BR>http://www.cnitblog.com/Files/zfly/thinkX.rar</A><BR><BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ----------------<BR>&nbsp;module0&nbsp;&nbsp; ch0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | rt point&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;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bsp;&nbsp;&nbsp;&nbsp; Draw-&gt; ----|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;\- thread3 ( write rt database to hd database )<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Explore-&gt;--|<BR><BR>------------------------------------------------------------------------------<BR>1、完成利用template产生u16 ,i16 ,f32 ,f64等模拟量初步工作。<BR>2、完成报警类型定义<BR><BR><img src ="http://www.cnitblog.com/zfly/aggbug/5796.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zfly/" target="_blank">zfly</a> 2005-12-26 15:35 <a href="http://www.cnitblog.com/zfly/archive/2005/12/26/5796.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>哪位兄弟有《数据库系统实现》一书啊！</title><link>http://www.cnitblog.com/zfly/archive/2005/12/22/5681.html</link><dc:creator>zfly</dc:creator><author>zfly</author><pubDate>Thu, 22 Dec 2005 01:36:00 GMT</pubDate><guid>http://www.cnitblog.com/zfly/archive/2005/12/22/5681.html</guid><wfw:comment>http://www.cnitblog.com/zfly/comments/5681.html</wfw:comment><comments>http://www.cnitblog.com/zfly/archive/2005/12/22/5681.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/zfly/comments/commentRss/5681.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zfly/services/trackbacks/5681.html</trackback:ping><description><![CDATA[&nbsp; 那位兄弟有啊？<BR>&nbsp;&nbsp; 从网上下载的只有4章，不全。<BR>《数据库系统实现》英文版、中文版均可！可交换资料！！！<BR><img src ="http://www.cnitblog.com/zfly/aggbug/5681.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zfly/" target="_blank">zfly</a> 2005-12-22 09:36 <a href="http://www.cnitblog.com/zfly/archive/2005/12/22/5681.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>哎，老有人问我Modbus CRC 算法！！ 今天贴出代码！！（超值）以后不再回答</title><link>http://www.cnitblog.com/zfly/archive/2005/12/13/5334.html</link><dc:creator>zfly</dc:creator><author>zfly</author><pubDate>Tue, 13 Dec 2005 06:21:00 GMT</pubDate><guid>http://www.cnitblog.com/zfly/archive/2005/12/13/5334.html</guid><wfw:comment>http://www.cnitblog.com/zfly/comments/5334.html</wfw:comment><comments>http://www.cnitblog.com/zfly/archive/2005/12/13/5334.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cnitblog.com/zfly/comments/commentRss/5334.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zfly/services/trackbacks/5334.html</trackback:ping><description><![CDATA[<P><IMG height=20 src="http://www.cnitblog.com/Emoticons/hitwall.gif" width=25 border=0>void CRC16(BYTE *Array, BYTE *Rcvbuf,unsigned int Len)<BR>{<BR>&nbsp;unsigned int&nbsp; IX,IY,CRC;<BR>&nbsp;CRC=0xFFFF;//set all 1</P>
<P>&nbsp;if (Len&lt;=0) <BR>&nbsp;&nbsp;CRC = 0;<BR>&nbsp;else<BR>&nbsp;{<BR>&nbsp;&nbsp;Len--;<BR>&nbsp;&nbsp;for (IX=0;IX&lt;=Len;IX++)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;CRC=CRC^(unsigned int)(Array[IX]);<BR>&nbsp;&nbsp;&nbsp;for(IY=0;IY&lt;=7;IY++)<BR>&nbsp;&nbsp;&nbsp;if ((CRC&amp;1)!=0&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;CRC=(CRC&gt;&gt;1)^0xA001;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;&nbsp;CRC=CRC&gt;&gt;1;&nbsp;&nbsp;&nbsp;&nbsp;//<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;Rcvbuf[0] = (CRC &amp; 0xff00)&gt;&gt;8;//高位置<BR>&nbsp;Rcvbuf[1] = (CRC &amp; 0x00ff);&nbsp; //低位置<BR>}<BR></P><img src ="http://www.cnitblog.com/zfly/aggbug/5334.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zfly/" target="_blank">zfly</a> 2005-12-13 14:21 <a href="http://www.cnitblog.com/zfly/archive/2005/12/13/5334.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MySQL in a Main Memory Database Context</title><link>http://www.cnitblog.com/zfly/archive/2005/12/12/5310.html</link><dc:creator>zfly</dc:creator><author>zfly</author><pubDate>Mon, 12 Dec 2005 05:12:00 GMT</pubDate><guid>http://www.cnitblog.com/zfly/archive/2005/12/12/5310.html</guid><wfw:comment>http://www.cnitblog.com/zfly/comments/5310.html</wfw:comment><comments>http://www.cnitblog.com/zfly/archive/2005/12/12/5310.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/zfly/comments/commentRss/5310.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zfly/services/trackbacks/5310.html</trackback:ping><description><![CDATA[<A href="http://www.diku.dk/publikationer/tekniske.rapporter/2004/04-02.pdf">http://www.diku.dk/publikationer/tekniske.rapporter/2004/04-02.pdf</A><img src ="http://www.cnitblog.com/zfly/aggbug/5310.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zfly/" target="_blank">zfly</a> 2005-12-12 13:12 <a href="http://www.cnitblog.com/zfly/archive/2005/12/12/5310.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>闲来无事，有VC++项目找我！！</title><link>http://www.cnitblog.com/zfly/archive/2005/12/06/5197.html</link><dc:creator>zfly</dc:creator><author>zfly</author><pubDate>Tue, 06 Dec 2005 04:12:00 GMT</pubDate><guid>http://www.cnitblog.com/zfly/archive/2005/12/06/5197.html</guid><wfw:comment>http://www.cnitblog.com/zfly/comments/5197.html</wfw:comment><comments>http://www.cnitblog.com/zfly/archive/2005/12/06/5197.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/zfly/comments/commentRss/5197.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zfly/services/trackbacks/5197.html</trackback:ping><description><![CDATA[关于界面、图像、通讯、内存、电力规约找我吧！（7-8年编程经验)<BR>linux下的c编程也可。<BR><BR>合作、兼职、外包均可！！！<img src ="http://www.cnitblog.com/zfly/aggbug/5197.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zfly/" target="_blank">zfly</a> 2005-12-06 12:12 <a href="http://www.cnitblog.com/zfly/archive/2005/12/06/5197.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Write Scalable Winsock Apps Using Completion Ports</title><link>http://www.cnitblog.com/zfly/archive/2005/12/05/5182.html</link><dc:creator>zfly</dc:creator><author>zfly</author><pubDate>Mon, 05 Dec 2005 07:08:00 GMT</pubDate><guid>http://www.cnitblog.com/zfly/archive/2005/12/05/5182.html</guid><wfw:comment>http://www.cnitblog.com/zfly/comments/5182.html</wfw:comment><comments>http://www.cnitblog.com/zfly/archive/2005/12/05/5182.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/zfly/comments/commentRss/5182.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zfly/services/trackbacks/5182.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 异步IO、APC、IO完成端口、线程池与高性能服务器kraft @ 2005-11-13 18:37原作者姓名 Fang(fangguicheng@21cn.com)异步IO、APC、IO完成端口、线程池与高性能服务器之一 异步IO背景：轮询 PIO DMA 中断&nbsp;&nbsp;&nbsp;&nbsp;早期IO设备的速度与CPU相比，还不是太悬殊。CPU定时轮询一遍IO设备，看看有无处理要...&nbsp;&nbsp;<a href='http://www.cnitblog.com/zfly/archive/2005/12/05/5182.html'>阅读全文</a><img src ="http://www.cnitblog.com/zfly/aggbug/5182.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zfly/" target="_blank">zfly</a> 2005-12-05 15:08 <a href="http://www.cnitblog.com/zfly/archive/2005/12/05/5182.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Apache 服务器端程序Win32下的编写？？</title><link>http://www.cnitblog.com/zfly/archive/2005/11/29/4989.html</link><dc:creator>zfly</dc:creator><author>zfly</author><pubDate>Tue, 29 Nov 2005 06:09:00 GMT</pubDate><guid>http://www.cnitblog.com/zfly/archive/2005/11/29/4989.html</guid><wfw:comment>http://www.cnitblog.com/zfly/comments/4989.html</wfw:comment><comments>http://www.cnitblog.com/zfly/archive/2005/11/29/4989.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/zfly/comments/commentRss/4989.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zfly/services/trackbacks/4989.html</trackback:ping><description><![CDATA[有谁研究过apache的WinNT下的服务器端程序的编写？<BR>1 parent process<BR>1 child&nbsp;&nbsp; process + n threads <BR>通过Win32完全端口进行控制I/O request 的并发模式。<BR><BR>有一些疑点好几天没看懂，能否交流交流？<BR><BR>---------------------------------------------------------------------------------<BR>2005.11.30<BR>看了好多东东，win32下的调试技术，还没过关！！<BR>望破解高手能互相交流一下，进程间的调试技术。<BR><BR>父进程对本身创建子进程，不像linux 中的fork()，调试起来有点麻烦，总是不能进入到<BR>子进程中的断点，经过昨天+今天的痛定思痛总于能debug 了。<BR><BR><img src ="http://www.cnitblog.com/zfly/aggbug/4989.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zfly/" target="_blank">zfly</a> 2005-11-29 14:09 <a href="http://www.cnitblog.com/zfly/archive/2005/11/29/4989.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>内存分配策略及计算 </title><link>http://www.cnitblog.com/zfly/archive/2005/10/31/3719.html</link><dc:creator>zfly</dc:creator><author>zfly</author><pubDate>Mon, 31 Oct 2005 02:38:00 GMT</pubDate><guid>http://www.cnitblog.com/zfly/archive/2005/10/31/3719.html</guid><wfw:comment>http://www.cnitblog.com/zfly/comments/3719.html</wfw:comment><comments>http://www.cnitblog.com/zfly/archive/2005/10/31/3719.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/zfly/comments/commentRss/3719.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zfly/services/trackbacks/3719.html</trackback:ping><description><![CDATA[<P><FONT face="Courier New" size=1>内存分配策略及计算 <BR>1、General-purpose allocation can provide any size of memory block that a caller might request(the request size, or block size). General-purpose allocation is very flexible, but has several&nbsp;drawbacks, two of which are: a) performance, because it has to do more work; and b) fragmentation,&nbsp;because as blocks are allocated and freed we can end up with lots of little noncontiguous areas of <BR>&nbsp; unallocated memory.（通用分配策略)<BR>&nbsp;<BR>2、Fixed-size allocation always returns a block of the same fixed size. This is obviously less&nbsp;flexible than general-purpose allocation, but it can be done much faster and doesn't result in&nbsp;the same kind of fragmentation.(固定尺寸分配策略)<BR>&nbsp;&nbsp; <BR>In practice, you'll often see combinations of the above. For example, perhaps your memory manager uses a general-purpose allocation scheme for all requests over some size S, and as an optimization provides a fixed-size allocation scheme for all requests up to size S. It's usually unwieldy to have a separate arena for requests of size 1, another for requests of size 2, and so on; what normally happens is that the manager has a separate arena for requests of multiples of a certain size, say 16 bytes. If you request 16 bytes, great, you only use 16 bytes; if you request 17 bytes, the request is allocated from the 32-byte arena, and 15 bytes are wasted. This is a source of possible overhead, but more about that in a moment.</FONT></P>
<P><FONT face="Courier New" size=1>Who selects the memory management strategy? There are several possible layers of memory manager involved, each of which may override the previous (lower-level) one:(内存分配策略的选择)</FONT></P>
<P><FONT face="Courier New" size=1>1.The operating system kernel provides the most basic memory allocation services. This underlying&nbsp; allocation strategy, and its characteristics, can vary from one operating systems platform to another,&nbsp;&nbsp; and this level is the most likely to be affected by hardware considerations.<BR>&nbsp;<BR>2.The compiler's default runtime library builds its allocation services, such as C++'s operator new&nbsp; and C's malloc, upon the native allocation services. The compiler's services might just be a thin&nbsp;&nbsp; wrapper around the native ones and inherit their characteristics, or the compiler's services might&nbsp; override the native strategies by buying larger chunks from the native services and then parceling&nbsp;those out according to their own methods.<BR>&nbsp;<BR>3.The standard containers and allocators in turn use the compiler's services, and possibly further&nbsp;override them to implement their own strategies and optimizations.<BR>&nbsp;<BR>4.Finally, user-defined containers and/or user-defined allocators can further reuse any of the lower-level&nbsp; services (for example, they may want to directly access native services if portability doesn't matter)&nbsp; and do pretty much whatever they please.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 包容关系<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT style="BACKGROUND-COLOR: #ffffff">------------------------------------------------+</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp; user-defined containters and/or allocators&nbsp;&nbsp; |<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp; +------------------------------------------+<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp; | stardard containters&nbsp; and/or allocators&nbsp; |<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp; +--------------------------------------------|<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; operator new and allocator&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |------------------------------------------------<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 操作系统核心&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ------------------------------------------------|<BR>When you ask for n bytes of memory using new or malloc, you actually use up at least n bytes of memory because typically the memory manager must add some overhead to your request. Two common considerations that affect this overhead are:</FONT></P>
<P><FONT face="Courier New" size=1>1. Housekeeping overhead.<BR>In a general-purpose (i.e., not fixed-size) allocation scheme, the memory manager will have to somehow remember how big each block is so that it later knows how much memory to release when you call delete or free. Typically the manager remembers the block size by storing that value at the beginning of the actual block it allocates, and then giving you a pointer to "your" memory that's offset past the housekeeping information. (See Figure 2.) Of course, this means it has to allocate extra space for that value, which could be a number as big as the largest possible valid allocation and so is typically the same size as a pointer. <BR>When freeing the block, the memory manager will just take the pointer you give it, subtract the number of housekeeping bytes and read the size, then perform the deallocation.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; size&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; +&nbsp;&nbsp;&nbsp; n bytes&nbsp;&nbsp;&nbsp; 用于通用分配策略<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (housrkeeping info)&nbsp;&nbsp;&nbsp; (我申请的)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>2. Chunk size overhead.<BR>Even when you don't need to store extra information, a memory manager will often reserve more bytes than you asked for because memory is often allocated in certain-sized chunks.</FONT></P>
<P><FONT face="Courier New" size=1>For one thing, some platforms require certain types of data to appear on certain byte boundaries (e.g., some require pointers to be stored on 4-byte boundaries) and either break or perform more slowly if they're not. This is called alignment, and it calls for extra padding within, and possibly at the end of, the object's data. Even plain old built-in C-style arrays are affected by this need for alignment because it contributes to sizeof(struct).固定分配大小，须填充以补齐字节</FONT></P>
<P><FONT face="Courier New" size=1>For example:</FONT></P>
<P><FONT face="Courier New" size=1>// Example 1: Assume sizeof(long) == 4 and longs have a 4-byte<BR>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alignment requirement.(32位操作系统,不同的操作系统有不同)<BR>struct X1<BR>{<BR>&nbsp; char c1; // at offset 0, 1 byte<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // bytes 1-3: 3 padding bytes<BR>&nbsp; long l;&nbsp; // bytes 4-7: 4 bytes, aligned on 4-byte boundary<BR>&nbsp; char c2; // byte 8: 1 byte<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // bytes 9-11: 3 padding bytes (see narrative)<BR>}; // sizeof(X1) == 12<BR>n == 1 + 3 + 4 + 1 == 9, and m == sizeof(X1) == 12</FONT></P>
<P><FONT face="Courier New" size=1>struct X2<BR>{<BR>&nbsp; long l;&nbsp; // bytes 0-3<BR>&nbsp; char c1; // byte 4<BR>&nbsp; char c2; // byte 5<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // bytes 6-7: 2 padding bytes<BR>}; // sizeof(X2) == 8<BR>&nbsp;<BR>容器的内存空间分配<BR>Each standard container uses a different underlying memory structure and therefore imposes different overhead per contained object:<BR>1、vector&lt;T&gt; internally stores a contiguous C-style array of T objects, and so has no extra per-element&nbsp;&nbsp;&nbsp; overhead at all (besides padding for alignment, of course; note that here "contiguous" has the same meaning as it does for C-style arrays, as shown in Figure 3).<BR>&nbsp;&nbsp;&nbsp;&nbsp; <BR>2、deque&lt;T&gt; can be thought of as a vector&lt;T&gt; whose internal storage is broken up into chunks.&nbsp;&nbsp;A deque&lt;T&gt; stores chunks, or "pages," of objects; the actual page size isn't specified by the standard,&nbsp;&nbsp;&nbsp; and depends mainly on how big T objects are and on the size choices made by your standard library implementer.&nbsp;&nbsp; This paging requires the deque to store one extra pointer of management information per page, which usually&nbsp;&nbsp;&nbsp; works out to a mere fraction of a bit per contained object; for example, on a system with 8-bit bytes and<BR>&nbsp;&nbsp; 4-byte ints and pointers, a deque&lt;int&gt; with a 4K page size incurs an overhead per int of 0.03125 bits -&nbsp;&nbsp;&nbsp; just 1/32 of a bit. There's no other per-element overhead because deque&lt;T&gt; doesn't store any extra pointers&nbsp;&nbsp;&nbsp; or other information for individual T objects. There is no requirement that a deque's pages be C-style arrays,&nbsp;&nbsp; but that's the usual implementation.<BR>&nbsp;<BR>3、list&lt;T&gt; is a doubly-linked list of nodes that hold T elements. This means that for each T element,&nbsp;&nbsp;&nbsp; list&lt;T&gt; also stores two pointers, which point to the previous and next nodes in the list. Every time we&nbsp;&nbsp; insert a new T element, we also create two more pointers, so a list&lt;T&gt; requires at least two pointers'&nbsp;&nbsp;&nbsp; worth of overhead per element.<BR>&nbsp;<BR>4、set&lt;T&gt; (and, for that matter, a multiset&lt;T&gt;, map&lt;Key,T&gt;, or multimap&lt;Key,T&gt;) also stores nodes that hold&nbsp;&nbsp;&nbsp; T (or pair&lt;const Key,T&gt;) elements. The usual implementation of a set is as a tree with three extra&nbsp;&nbsp;&nbsp; pointers per node. Often people see this and think, 'why three pointers? isn't two enough, one for the&nbsp;&nbsp;&nbsp; left child and one for the right child?' The reason three are needed is that we also need an "up" pointer&nbsp;&nbsp;&nbsp; to the parent node, otherwise determining the 'next' element starting from some arbitrary iterator can't<BR>&nbsp;&nbsp;&nbsp; be done efficiently enough. (Besides trees, other internal implementations of set are possible; for&nbsp;&nbsp;&nbsp;&nbsp; example, an alternating skip list can be used, which still requires at least three pointers per element&nbsp;&nbsp;&nbsp;&nbsp; in the set.)<BR>&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp; Container&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Typical housekeeping data overhead per contained object <BR>&nbsp;&nbsp;&nbsp;&nbsp; ----------&nbsp;&nbsp;&nbsp; ---------------------------------------------------------<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vector&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; No overhead per T.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; deque&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Nearly no overhead per T — typically just a fraction of a bit.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; list&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Two pointers per T.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set, multiset&nbsp; Three pointers per T.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; map, multimap&nbsp; Three pointers per pair&lt;const Key, T&gt;.<BR>&nbsp;<BR>&nbsp;多分配的结构：<BR>&nbsp;&nbsp;&nbsp;&nbsp; vector&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; None; objects are not allocated individually. (See sidebar.)<BR>&nbsp;&nbsp;&nbsp;&nbsp; deque&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; None; objects are allocated in pages, and nearly always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p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp; }; // or equivalent&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }; // or equivalent <BR>&nbsp; 在如下条件：<BR>&nbsp;1、Pointers and ints are 4 bytes long. (Typical for 32-bit platforms.) <BR>&nbsp;2、sizeof(string) is 16. Note that this is just the size of the immediate string object<BR>&nbsp;&nbsp;&nbsp; and ignores any data buffers the string may itself allocate; the number and size of <BR>&nbsp;&nbsp;&nbsp; string's internal buffers will vary from implementation to implementation, but doesn't <BR>&nbsp;&nbsp;&nbsp; affect the comparative results below. (This sizeof(string) is the actual value of one<BR>&nbsp;&nbsp;&nbsp;&nbsp; popular implementation.)<BR>&nbsp;3、The default memory allocation strategy is to use fixed-size allocation where the block <BR>&nbsp;&nbsp;&nbsp; sizes are multiples of 16 bytes. (Typical for Microsoft Visual C++.)<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Container&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Basic node&nbsp;&nbsp;&nbsp; Actual size of allocation block for node, <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; data size&nbsp;&nbsp;&nbsp;&nbsp; including internal node data alignment <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; and block allocation overhead <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ----------------------&nbsp;&nbsp; ------------------&nbsp;&nbsp; -----------------------------------------<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; list&lt;char&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 9 bytes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 16 bytes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set&lt;char&gt;, multiset&lt;char&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 13 bytes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 16 bytes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; list&lt;int&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 12 bytes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 16 bytes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set&lt;int&gt;, multiset&lt;int&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 16 bytes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 16 bytes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; list&lt;string&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 24 bytes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 32 bytes<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set&lt;string&gt;, multiset&lt;string&gt;&nbsp; 28 bytes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 32 bytes<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ----------------------------------------------------------------------------------------- <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 条件： Same actual overhead per contained object&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (implementation-dependent assumptions: sizeof(string) == 16,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4-byte pointers and ints, and 16-byte fixed-size allocation blocks)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;内存算法:<BR>&nbsp;best-first:<BR>&nbsp; - The first block in the heap that is big enough is allocated<BR>&nbsp; - Each free block keeps a pointer to the next free block<BR>&nbsp; - These pointers may be adjusted as memory is allocated<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; We can keep track of free space in a separate list called the free list<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;nearest-fit <BR>&nbsp;worst-fit<BR>&nbsp;next-fit ......<BR>&nbsp;<BR>&nbsp;memory leak: If a dynamically allocated variable leaves its scope before being<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; recycled, the memory cannot be recycled and the program will <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gradually drain away memory until the computer halts.<BR>&nbsp;dangling pointer: The invalid reference in this kind of situation is known as a<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dangling pointer.&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; |-----------|------------------------------------|------------------------------|<BR>&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | Manual Memory&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp; Automatic Memory&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<BR>&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | Management&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp; Management&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<BR>&nbsp;&nbsp;&nbsp; |-----------|------------------------------------|------------------------------|<BR>&nbsp;&nbsp;&nbsp; | Benefits&nbsp; |&nbsp;&nbsp; size (smaller)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp; constrains complexity&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<BR>&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp; speed (faster)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<BR>&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp; control (you decide when to free)|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<BR>&nbsp;&nbsp;&nbsp; |-----------|------------------------------------|------------------------------|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; | Costs&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp; complexity&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |larger total memory footprint |&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp; memory leaks&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |“comparable” performance&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp; dangling pointers&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<BR>&nbsp;&nbsp;&nbsp; |-----------|------------------------------------|------------------------------|<BR>&nbsp; If you rewrite all of the functions in a program&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp; as inline macros, you can increase the speed at which the&nbsp;&nbsp; <BR>&nbsp; program executes. This is because the processor doesn’t have to&nbsp;&nbsp; <BR>&nbsp; waste time jumping around to different memory locations. In addition,&nbsp;&nbsp;&nbsp; <BR>&nbsp; because execution will not frequently jump to a nonlocal spot&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp; in memory, the processor will be able to spend much of its time executing<BR>&nbsp; code in the cache.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp; <BR>&nbsp; Likewise, you can make a program smaller by isolating every bit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp; of redundant code and placing it in its own function. While this will<BR>&nbsp; decrease the total number of machine instructions, this tactic will&nbsp; <BR>&nbsp; make a program slower because not only does the processor spend&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp; most of its time jumping around memory, but the processor’s cache&nbsp;&nbsp; <BR>&nbsp; will also need to be constantly refreshed.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp; <BR>&nbsp; memory alloc:<BR>&nbsp; 1. Bitmapped Allocation<BR>&nbsp;&nbsp;&nbsp;&nbsp; 利用bitmap来记录内存分配的占位符,利用BST数来记录分配内存的大小<BR>&nbsp; 2. Sequential Fit<BR>&nbsp;&nbsp;&nbsp;&nbsp; The sequential fit technique organizes memory into a linear linked&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp; list of free and reserved regions . When an allocation request occurs,<BR>&nbsp;&nbsp;&nbsp;&nbsp; the memory manager moves sequentially through the list until it finds <BR>&nbsp;&nbsp;&nbsp;&nbsp; a free block of memory that can service/fit the request (hence the name “sequential fit”).&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp; 分配和回收、归并&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp; 其中选择空闲节点的匹配可选算法<BR>&nbsp;&nbsp;&nbsp;&nbsp; [ best-fit<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nearest-fit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; worst-fit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; next-fit ......&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ]<BR>&nbsp; 3.Segregated Lists<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp; Garbage Collection的种类<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp; Reference counting collectors: identify garbage by maintaining a&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp; running tally of the number of pointers that reference each block of<BR>&nbsp;&nbsp; allocated memory. When the number of references to a particular&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp; block of memory reaches zero, the memory is viewed as garbage&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp; and reclaimed. There are a number of types of reference counting&nbsp;&nbsp; <BR>&nbsp;&nbsp; algorithms, each one implementing its own variation of the counting<BR>&nbsp;&nbsp; mechanism (i.e., simple reference counting, deferred reference&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp; counting, 1-bit reference counting, etc.).&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Follows these rules:<BR>&nbsp;&nbsp;&nbsp; - When an object is created, create a reference count (RC) field<BR>&nbsp;&nbsp;&nbsp; - Set the reference count to 1 upon creation, to account for&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the object which initially points to this object&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; - When an object with pointers is created, increment the RC of&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; all of the objects pointed to by this object by 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; - When an object with pointers is destroyed (goes out of scope, etc.)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; decrement the RC of all objects pointed to by this object by 1<BR>&nbsp;&nbsp;&nbsp; - When a pointer is modified, decrement the RC of the old target<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; by 1 and increment the RC of the new target by 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; - When an object’s RC reaches 0, reclaim the object as free spa<BR>&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp; Tracing garbage collectors traverse the application run-time environment<BR>&nbsp;&nbsp; (i.e., registers, stack, heap, data section) in search of&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp; pointers to memory in the heap. Think of tracing collectors as&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp; pointer hunter-gatherers. If a pointer is found somewhere in the&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp; run-time environment, the heap memory that is pointed to is&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp; assumed to be “alive” and is not recycled. Otherwise, the allocated&nbsp;&nbsp; <BR>&nbsp;&nbsp; memory is reclaimed. There are several subspecies of tracing garbage&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp; collectors, including mark-sweep, mark-compact, and copying&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp; garbage collectors.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp; <BR>suballocator:they are talking about a specialpurpose&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; application component that is implemented by the programmer&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; and based on existing services provided by application libraries<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (like malloc() and free()). </FONT></P>
<P><FONT face="Courier New" size=1>Suballocators are user code which reserve the system-provided<BR>heap and then manage that memory itself&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></P><img src ="http://www.cnitblog.com/zfly/aggbug/3719.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zfly/" target="_blank">zfly</a> 2005-10-31 10:38 <a href="http://www.cnitblog.com/zfly/archive/2005/10/31/3719.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>守护程序的编写</title><link>http://www.cnitblog.com/zfly/archive/2005/10/24/3526.html</link><dc:creator>zfly</dc:creator><author>zfly</author><pubDate>Mon, 24 Oct 2005 05:16:00 GMT</pubDate><guid>http://www.cnitblog.com/zfly/archive/2005/10/24/3526.html</guid><wfw:comment>http://www.cnitblog.com/zfly/comments/3526.html</wfw:comment><comments>http://www.cnitblog.com/zfly/archive/2005/10/24/3526.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/zfly/comments/commentRss/3526.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zfly/services/trackbacks/3526.html</trackback:ping><description><![CDATA[<P>STARTUPINFO<BR>The STARTUPINFO structure is used with the CreateProcess function to specify main <BR>window properties if a new window is created for the new process. For graphical <BR>user interface (GUI) processes, this information affects the first window created <BR>by the CreateWindow function and shown by the ShowWindow function. For console <BR>processes, this information affects the console window if a new console is created <BR>for the process.</P>
<P>DuplicateHandle<BR>The DuplicateHandle function duplicates an object handle. The duplicate handle refers <BR>to the same object as the original handle. Therefore, any changes to the object are <BR>reflected through both handles.DuplicateHandle can be called by either the source <BR>process or the target process. It can also be invoked where the source and target <BR>process are the same. Note that DuplicateHandle should not be used to duplicate <BR>handles to I/O completion ports. </P>
<P>监护程序的编写<BR>&nbsp; win9X -&gt; 编写console 程序<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; createpipe()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DuplicateHandle()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CreateProcess()获得console的输入,输出handle<BR><BR>&nbsp;&nbsp; windoww2000 xp<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OpenSCManager()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OpenService()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ControlService()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; QueryServiceStatus()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StartService()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>守护程序的编写:对长时间远行程序的监控，非正常退出时，重新运行服务。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </P><img src ="http://www.cnitblog.com/zfly/aggbug/3526.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zfly/" target="_blank">zfly</a> 2005-10-24 13:16 <a href="http://www.cnitblog.com/zfly/archive/2005/10/24/3526.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>学习UDP 上实现 TCP的部分功能！！</title><link>http://www.cnitblog.com/zfly/archive/2005/10/19/3392.html</link><dc:creator>zfly</dc:creator><author>zfly</author><pubDate>Wed, 19 Oct 2005 01:36:00 GMT</pubDate><guid>http://www.cnitblog.com/zfly/archive/2005/10/19/3392.html</guid><wfw:comment>http://www.cnitblog.com/zfly/comments/3392.html</wfw:comment><comments>http://www.cnitblog.com/zfly/archive/2005/10/19/3392.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/zfly/comments/commentRss/3392.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zfly/services/trackbacks/3392.html</trackback:ping><description><![CDATA[<P><FONT style="BACKGROUND-COLOR: #d5d5d5">UDP层上实现TCP的可靠数据传输，在游戏等领域实时要求比较高的情况下使用。</FONT></P><img src ="http://www.cnitblog.com/zfly/aggbug/3392.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zfly/" target="_blank">zfly</a> 2005-10-19 09:36 <a href="http://www.cnitblog.com/zfly/archive/2005/10/19/3392.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>最近学习笔记，不断更新中... ...</title><link>http://www.cnitblog.com/zfly/archive/2005/10/11/3224.html</link><dc:creator>zfly</dc:creator><author>zfly</author><pubDate>Tue, 11 Oct 2005 03:05:00 GMT</pubDate><guid>http://www.cnitblog.com/zfly/archive/2005/10/11/3224.html</guid><wfw:comment>http://www.cnitblog.com/zfly/comments/3224.html</wfw:comment><comments>http://www.cnitblog.com/zfly/archive/2005/10/11/3224.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/zfly/comments/commentRss/3224.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zfly/services/trackbacks/3224.html</trackback:ping><description><![CDATA[<P><FONT size=1>1. c++中类的相互引用<BR>&nbsp; <BR>&nbsp; 原则是:相互引用的class要分别写.h和.cpp文件(分别合用一个.h,.cpp也可)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 在.h文件中只需申明class类型即可，一定不要包含其他类的头文件<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 在.cpp文件中必须要包含其他要引用的头件<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 不要将函数申明跟寒暑提在同一文件中实现,否则会出意想不到的错误！！！<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a.h b.h 合成一个.h文件<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a.cpp b.cpp 合成一个.cpp文件也可<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp; a.h&nbsp; <BR>&nbsp;&nbsp;#ifndef _A_<BR>&nbsp;&nbsp;#define _A_<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;class b;<BR>&nbsp;&nbsp;class a;<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;class a {<BR>&nbsp;&nbsp;&nbsp;friend class&nbsp; b;<BR>&nbsp;&nbsp;private:<BR>&nbsp;&nbsp;&nbsp;int aa;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;void a1( b m );<BR>&nbsp;&nbsp;};<BR>&nbsp;&nbsp;#endif<BR>&nbsp;&nbsp; a.cpp<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #include "stdafx.h"<BR>&nbsp;&nbsp;#include "a.h"<BR>&nbsp;&nbsp;#include "b.h"<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;void a::a1(b m )<BR>&nbsp;&nbsp;{&nbsp;<BR>&nbsp;&nbsp;&nbsp;m.bb = 0 ;<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp; b.h<BR>&nbsp;&nbsp;#ifndef _B_<BR>&nbsp;&nbsp;#define _B_<BR>&nbsp;&nbsp;class&nbsp; b;<BR>&nbsp;&nbsp;class a;<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;class&nbsp; b <BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;friend class a;<BR>&nbsp;&nbsp;private:<BR>&nbsp;&nbsp;&nbsp;int bb;<BR>&nbsp;&nbsp;&nbsp;void zzz(a n);<BR>&nbsp;&nbsp;};&nbsp;<BR>&nbsp;&nbsp;#endif<BR>&nbsp;b.cpp<BR>&nbsp;&nbsp;&nbsp;&nbsp; #include "stdafx.h"<BR>&nbsp;&nbsp;#include "b.h"<BR>&nbsp;&nbsp;#include "a.h"<BR>&nbsp;&nbsp;void b::zzz(a m )<BR>&nbsp;&nbsp;{&nbsp;<BR>&nbsp;&nbsp;&nbsp;m.aa = 0 ;<BR>&nbsp;&nbsp;}&nbsp;<BR>&nbsp;<BR>&nbsp;&nbsp; main.cpp<BR>&nbsp;&nbsp;#include "stdafx.h"<BR>&nbsp;&nbsp;#include "a.h"<BR>&nbsp;&nbsp;#include "b.h"<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;int main(int argc, char* argv[])<BR>&nbsp;&nbsp;{ <BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a aa;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b bb;<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;<BR>&nbsp;&nbsp;}</FONT></P>
<P><FONT size=1>2. 链表的好用法<BR>&nbsp;&nbsp; struct a {<BR>&nbsp;&nbsp;&nbsp;&nbsp; static a *mLinkedList; // 申明为一个静态变量<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp; &nbsp;a *mNext;<BR>&nbsp;&nbsp;&nbsp;&nbsp; bool mCanRemoteCreate;</FONT></P>
<P><FONT size=1>&nbsp;&nbsp;&nbsp; a(bool canRemoteCreate)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mNext = mLinkedList;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mLinkedList = this;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mCanRemoteCreate = canRemoteCreate;<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; static int *create(const char *name);<BR>&nbsp; };<BR>&nbsp; <BR>&nbsp; a *a::mLinkedList = NULL; // 初始化<BR>&nbsp; <BR>3. 灵活的应用# ##<BR>Token-Pasting Operator (##)</FONT></P>
<P><FONT size=1>#define paster( n ) printf( "token" #n " = %d", token##n )<BR>int token9 = 9;<BR>If a macro is called with a numeric argument like<BR>paster( 9 );the macro yields<BR>printf( "token" "9" " = %d", token9 );which becomes<BR>printf( "token9 = %d", token9 );</FONT></P>
<P><FONT size=1>Stringizing Operator (#)<BR>#define stringer( x ) printf( #x "\n" )<BR>void main()<BR>{<BR>&nbsp;&nbsp;&nbsp; stringer( In quotes in the printf function call\n ); <BR>&nbsp;&nbsp;&nbsp; stringer( "In quotes when printed to the screen"\n );&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; stringer( "This: \"&nbsp; prints an escaped double quote" );<BR>}<BR>Such invocations would be expanded during preprocessing, producing the following code:<BR>void main()<BR>{<BR>&nbsp;&nbsp; printf( "In quotes in the printf function call\n" "\n" );<BR>&nbsp;&nbsp; printf( "\"In quotes when printed to the screen\"\n" "\n" );<BR>&nbsp;&nbsp; printf( "\"This: </FONT><A><FONT size=1>\\\</FONT></A><FONT size=1>" prints an escaped double quote\"" "\n" );<BR>}<BR>When the program is run, screen output for each line is as follows:In quotes in the printf function call<BR>"In quotes when printed to the screen"<BR>"This: \" prints an escaped double quotation mark"<BR>#define IMPLEMENT_NETCONNECTION(className, classGroup, canRemoteCreate) \<BR>&nbsp;&nbsp; NetClassRep* className::getClassRep() const { return &amp;className::dynClassRep; } \<BR>&nbsp;&nbsp; NetClassRepInstance&lt;className&gt; className::dynClassRep(#className, 0, NetClassTypeNone, 0); \<BR>&nbsp;&nbsp; NetClassGroup className::getNetClassGroup() const { return classGroup; } \<BR>&nbsp;&nbsp; static NetConnectionRep g##className##Rep(&amp;className::dynClassRep, canRemoteCreate)</FONT></P>
<P><FONT size=1>4. 枚举:初始化为0值开始,后者比前者大1,除非显式指定.<BR>&nbsp;&nbsp; By default, the first enumerator has a value of 0, and each successive enumerator is one larger <BR>&nbsp;&nbsp; than the value of the previous one, unless you explicitly specify a value for a particular <BR>&nbsp;&nbsp; enumerator. Enumerators needn’t have unique values. The name of each enumerator is treated <BR>&nbsp;&nbsp; as a constant and must be unique within the scope where the enum is defined. An enumerator <BR>&nbsp;&nbsp; can be promoted to an integer value. However, converting an integer to an enumerator requires <BR>&nbsp;&nbsp; an explicit cast, and the results are not defined.</FONT></P>
<P><FONT size=1>=========================<BR>一些优秀的数学算法<BR>5.1 /// Determines if number is a power of two.<BR>&nbsp;inline bool isPow2(const U32 number)<BR>&nbsp;{<BR>&nbsp;&nbsp;&nbsp; return (number &amp; (number - 1)) == 0;<BR>&nbsp;}<BR>5.2 浮点数的计算机中的储存方法</FONT></P>
<P><FONT size=1>&nbsp;&nbsp;&nbsp; 单精度&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1|&nbsp;&nbsp; 8&nbsp;&nbsp; |&nbsp;&nbsp; 23&nbsp;&nbsp;&nbsp; | <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 符号&nbsp; 指数&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 尾数 <BR>&nbsp;&nbsp;&nbsp; 双精度&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1|&nbsp;&nbsp; 11&nbsp; |&nbsp;&nbsp; 52&nbsp;&nbsp;&nbsp; | <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 符号&nbsp; 指数&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 尾数&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; 10110.100011 -&gt; 1.0110100011* 2(4) 2的4之方<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; 符号位 0 <BR>&nbsp;&nbsp;&nbsp; 尾数&nbsp;&nbsp; 0110100011<BR>&nbsp;&nbsp;&nbsp; 指数&nbsp;&nbsp; 4 以过剩127储存 +127= 131&nbsp; -&gt; 10000011<BR>&nbsp;&nbsp;&nbsp; 所以&nbsp; IEEE 754 : 0100000110110100011<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; -0.0010011&nbsp; -&gt; -1.0011 * 2(-3) 2的-3之方<BR>&nbsp;&nbsp;&nbsp; 符号位：-1<BR>&nbsp;&nbsp;&nbsp; 尾数&nbsp; : 0011<BR>&nbsp;&nbsp;&nbsp; 指数为：-3&nbsp; +127&nbsp; 的124 -〉01111100<BR>&nbsp;&nbsp;&nbsp; 所以： 1 01111100 0011000000000000000000<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; /// Determines the binary logarithm of the input value rounded down to the nearest power of 2.<BR>&nbsp;inline U32 getBinLog2(U32 value)<BR>&nbsp;{<BR>&nbsp;&nbsp;&nbsp; F32 floatValue = F32(value);<BR>&nbsp;&nbsp;&nbsp; return (*((U32 *) &amp;floatValue) &gt;&gt; 23) - 127;<BR>&nbsp;}</FONT></P>
<P><FONT size=1>=========================<BR>模式编程<BR>模版<BR>引用计数<BR>对象指针<BR>构成功能强大</FONT></P><img src ="http://www.cnitblog.com/zfly/aggbug/3224.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zfly/" target="_blank">zfly</a> 2005-10-11 11:05 <a href="http://www.cnitblog.com/zfly/archive/2005/10/11/3224.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>上传以前做的小工具（非常适合工控行业的调试）</title><link>http://www.cnitblog.com/zfly/archive/2005/09/07/2551.html</link><dc:creator>zfly</dc:creator><author>zfly</author><pubDate>Wed, 07 Sep 2005 04:54:00 GMT</pubDate><guid>http://www.cnitblog.com/zfly/archive/2005/09/07/2551.html</guid><wfw:comment>http://www.cnitblog.com/zfly/comments/2551.html</wfw:comment><comments>http://www.cnitblog.com/zfly/archive/2005/09/07/2551.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cnitblog.com/zfly/comments/commentRss/2551.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zfly/services/trackbacks/2551.html</trackback:ping><description><![CDATA[自己很早做的串口工具(串口精灵ComX 1.62 )，收发线程分开。<BR>同时支持10进制，16进制显示,不同颜色显示<BR>支持DNP CRC , Modbus CRC ,u4f CRC , CDT CRC 等校验！<BR><A HREF="/zfly/zfly/Files/zfly/ComX.rar"><BR>http://www.cnitblog.com/Files/zfly/ComX.rar</A><img src ="http://www.cnitblog.com/zfly/aggbug/2551.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zfly/" target="_blank">zfly</a> 2005-09-07 12:54 <a href="http://www.cnitblog.com/zfly/archive/2005/09/07/2551.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>看opentnl（from http://opentnl.sourceforge.net/doxytree/introprogramming.html)</title><link>http://www.cnitblog.com/zfly/archive/2005/09/07/2546.html</link><dc:creator>zfly</dc:creator><author>zfly</author><pubDate>Wed, 07 Sep 2005 02:45:00 GMT</pubDate><guid>http://www.cnitblog.com/zfly/archive/2005/09/07/2546.html</guid><wfw:comment>http://www.cnitblog.com/zfly/comments/2546.html</wfw:comment><comments>http://www.cnitblog.com/zfly/archive/2005/09/07/2546.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/zfly/comments/commentRss/2546.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zfly/services/trackbacks/2546.html</trackback:ping><description><![CDATA[<H2><A class=anchor name=fundlimits>Fundamental Limitations of Computer Networks</A></H2>Computer networks of any size share some common limitations to varying degrees that must be accounted for in network simulations, with the internet being the most limited in all three regards. These three fundamental problems in network simulation are: 
<P><B>Limited Bandwidth</B> - There is a limit to the rate at which hosts on the network can send data to one another. If a computer is connected to the network with a 56 kbps modem, this might be 5 Kbytes per second, while computers on a local area network might be able to communicate at 128 megabytes per second. For service providers, additional bandwidth capacity can be costly, so even if there is no physical bandwidth limitation, bandwidth conservation is important for many projects. 
<P><B>Packet Loss</B> - Computer networks are inherently unreliable. Information transmitted over a network may become corrupted in transit, or may be dropped at a router where traffic has become congested. Even when (especially when) using a guaranteed message delivery protocol such as TCP, the unreliable nature of the underlying network still must be taken into account for network applications. 
<P><B>Latency</B> - Messages sent from one host to another on the network take time to arrive at the destination. The time can be influenced by many factors, including the medium over which the messages travel, how many intermediate hosts must route the message, an the level of traffic congestion at each of those network nodes. Latency becomes particularly problematic in network simulations that attempt to present a real-time interface to the client, when the latency of the connection may be perceptible in time.<BR><BR></P>
<H2><A class=anchor name=stdprotos>Standard Network Protocols</A></H2>
<P>When computers communicate over networks, they send and receive data using specific network protocols. These protocols ensure that the computers are using the same specifications to address, forward and process data on the network. The internet, certainly the most widely used computer network today, uses a stack of three primary protocols that facilitate communication over the network. They are: </P>
<P><B>IP - Internet Protocol</B>: The Internet Protocol is the basic building block for internet communications. IP is a routing protocol, which means that it is used to route information packets from a source host to a destination host, specified by an IP address. IP packets are not guaranteed to arrive at the destination specified by the sender, and those packets that do arrive are not guaranteed to arrive in the order they were sent. IP packet payloads may also be corrupted when they are delivered. IP is not useful as an application protocol - it is used mainly as a foundation for the higher level TCP and UDP protocols. 
<P><B>UDP - User Datagram Protocol</B>: The User Datagram Protocol supplies a thin layer on top of IP that performs error detection and application level routing on a single host. UDP packets are addressed using both an IP address to specify the physical host, and a port number, to specify which process on the machine the packet should be delivered to. UDP packets also contain a checksum, so that corrupted packets can be discarded. UDP packets that are corrupted or dropped by an intermediate host are not retransmitted by the sender, because the sender is never notified whether a given packet was delivered or not. 
<P><B>TCP/IP - Transmission Control Protocol</B>: TCP was designed to make internet programming easier by building a reliable, connection-based protocol on top of the unreliable IP. TCP does this by sending acknowledgements when data packets arrive, and resending data that was dropped. TCP is a stream protocol, so the network connection can be treated like any other file stream in the system. TCP is not suitable for simulation data, because any dropped packets will stall the data pipeline until the dropped data can be retransmitted.<BR><BR></P>
<H2><A class=anchor name=topologies>Application Network Topologies</A></H2>
<P>Networked applications can be designed to communicate with each other using different topological organization strategies. Some common communcations organization paradigms are discussed below. </P>
<P><B>Peer-to-Peer</B>: In a peer-to-peer network application, the client processes involved in the network communicate directly with one another. Though there may be one or more hosts with authoritative control over the network of peers, peer-to-peer applications largely distribute the responsibility for the simulation or application amongst the peers. 
<P><B>Client-Server</B>: In the client-server model, one host on the network, the server, acts as a central communications hub for all the other hosts (the clients). Typically the server is authoritative, and is responsible for routing communication between the several clients. 
<P><B>Client-Tiered Server Cluster</B>: In network applications where more clients want to subscribe to a service than can be accomodated by one server, the server's role will be handled by a cluster of servers peered together. The servers in the network communicate using the peer-to-peer model, and communicate with the clients using the client-server model. The servers may also communicate with an authoritative "super-server" to handle logins or resolve conflicts<BR><BR>...............................<BR></P>
<P>There are many Symmetric Encryption algorithms of varying levels of security, but all of them when used alone have several drawbacks. First, both parties to the communication must have a copy of the shared secret key. If a client is attempting to communicate with a service it has never contacted before, and doesn't share a key with, it won't be able to communicate securely with it. Also, although an intermediate eavesdropper cannot read the data sent between the hosts, it can alter the messages, potentially causing one or more of the systems to fail. <BR><BR><A class=anchor name=symmetric>Symmetric Encryption</A>加密算法并不适应游戏中，因为游戏者可以任意加入，而且偷窥者虽然不能读懂数据含义，但很有可能更改消息！<BR><BR></P>
<H3><A class=anchor name=pubkey>Public Key Cryptography and Key Exchange</A></H3>
<P>Public Key Cryptography algorithms were invented to solve the symmetric key distribution problem. In public key algorithms, each participant in the communication has a key pair composed of a public key and a private key. The theory of public keys suggests that a message encrypted with the public key can only be decrypted with the private key and vice-versa. </P>
<P>Key exchange algorithms (Diffie-Helman, ECDH) have certain properties such that two users, A and B can share their public keys with each other in plain text, and then, using each other's public key and their own private keys they can generate the same shared secret key. Eavesdroppers can see the public keys, but, because the private keys are never transmitted, cannot know the shared secret. Because public key algorithms are computationally much more expensive than symmetric cryptography, network applications generally use public key cryptography to share a secret key that is then used as a symmetric cipher key. <BR><BR></P>
<H3><A class=anchor name=digsigca>Digital Signatures/Certificate Authorization</A></H3>
<P>Public key algorithms still have one vulnerability, known as the Man-in-the-Middle attack. Basically, an eavesdropper in the communication between A and B can intercept the public keys in transit and substitute its own public key, thereby establishing a secure connection with A and B - decrypting incoming data and reencrypting it with its shared key to the opposite party. </P>
<P>To combat this attack, the concept of certificates was introduced. In this model, the public key of one or both of the participants in the communication is digitally signed with the private key of some known, trusted <A class=el href="http://opentnl.sourceforge.net/doxytree/classTNL_1_1Certificate.html"><FONT color=#002c99>Certificate</FONT></A> Authority (CA). Then, using the <A class=el href="http://opentnl.sourceforge.net/doxytree/classTNL_1_1Certificate.html"><FONT color=#002c99>Certificate</FONT></A> Authority's public key, the parties to the communication can validate the public key of the opposite parties. <BR><BR></P>
<H3><A class=anchor name=malicioususers>Malicious Attackers and Denial of Service</A></H3>
<P>A problem facing developers of internet applications and web sites are Denial-of-Service attacks. Malicious users employing custom tools often attempt to shut down publicly available internet servers. There are a variety of well-known categories of DoS attacks. </P>
<P><B>Traffic flooding</B>: This attack sends a barrage of data to the public address of the server, in an attempt to overwhelm that server's connection to the internet. This attack often employs many machines, hijacked by the attacker and acting in concert. These attacks are often the most difficult to mount since they require a large number of available machines with high-speed internet access in order to attack a remote host effectively. 
<P><B>Connection depletion</B>: The connection depletion attack works by exploting a weakness of some connection based communications protocols. Connection depletion attacks work by initiating a constant flow of spurious connection attempts. When a legitimate user attempts to connect to the server, all available pending connection slots are already taken up by the spoofed connection attempts, thereby denying service to valid clients. <BR><BR><STRONG>Server CPU depletion</STRONG>: If the server performs public key cryptography as part of the connection sequence, a malicious client could be constructed to initiate bogus connection attempts in an effort to initiate many CPU intesive cryptographic operations on the server. </P>
<P>The TNL uses a two-phase connection protocol to protect against connection depletion attacks, and implements a client-puzzle algorithm to prevent CPU depletion attacks. Also, TNL is built so that bogus packets are discarded as quickly as possible, preventing flooding attacks from impacting the server CPU. </P><img src ="http://www.cnitblog.com/zfly/aggbug/2546.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zfly/" target="_blank">zfly</a> 2005-09-07 10:45 <a href="http://www.cnitblog.com/zfly/archive/2005/09/07/2546.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Digi connect me 固件升级失败后的处理！</title><link>http://www.cnitblog.com/zfly/archive/2005/09/06/2534.html</link><dc:creator>zfly</dc:creator><author>zfly</author><pubDate>Tue, 06 Sep 2005 04:28:00 GMT</pubDate><guid>http://www.cnitblog.com/zfly/archive/2005/09/06/2534.html</guid><wfw:comment>http://www.cnitblog.com/zfly/comments/2534.html</wfw:comment><comments>http://www.cnitblog.com/zfly/archive/2005/09/06/2534.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/zfly/comments/commentRss/2534.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zfly/services/trackbacks/2534.html</trackback:ping><description><![CDATA[前几天升级digi connect me 的固件失败后，抓狂了好几天，幸好现解决<BR>通过短接几个pins即可！<BR><BR>接着看游戏的网络编程的相关知识！<BR><BR>網路遊戲目前的瓶頸在網路 I/O 的部份，因為網路遊戲的連線型態和許多<BR>其他網路應用服務（如 FTP, Web Applications...等）不同，它是屬於高<BR>連線數（動輒數千上萬）、高頻率、低流量（每秒每個連線平均溝通 4~6<BR>KBytes）。所以實作上往往和作業系統綁在一起，造成開發的困難。（例如<BR>在 Windows 上最適合開發網路遊戲的 I/O 模型是 I/O Completion Port<BR>模型，在 Unix 系列，則是 Asynchronous I/O 模型）<BR><img src ="http://www.cnitblog.com/zfly/aggbug/2534.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zfly/" target="_blank">zfly</a> 2005-09-06 12:28 <a href="http://www.cnitblog.com/zfly/archive/2005/09/06/2534.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>eNet Library 调试成功！</title><link>http://www.cnitblog.com/zfly/archive/2005/09/05/2519.html</link><dc:creator>zfly</dc:creator><author>zfly</author><pubDate>Mon, 05 Sep 2005 05:37:00 GMT</pubDate><guid>http://www.cnitblog.com/zfly/archive/2005/09/05/2519.html</guid><wfw:comment>http://www.cnitblog.com/zfly/comments/2519.html</wfw:comment><comments>http://www.cnitblog.com/zfly/archive/2005/09/05/2519.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/zfly/comments/commentRss/2519.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zfly/services/trackbacks/2519.html</trackback:ping><description><![CDATA[花了一个星期时间，断断续续的，总于调试一个简单服务器端，一个客户端程序，成功对接！<BR><BR>&nbsp;原来怀疑源代码有bug，结果是自己没有理解原作者的设计意图，没有看懂源程序所致!<img src ="http://www.cnitblog.com/zfly/aggbug/2519.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zfly/" target="_blank">zfly</a> 2005-09-05 13:37 <a href="http://www.cnitblog.com/zfly/archive/2005/09/05/2519.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>wincvs 登陆不了 enet的cvs服务器</title><link>http://www.cnitblog.com/zfly/archive/2005/09/02/2467.html</link><dc:creator>zfly</dc:creator><author>zfly</author><pubDate>Fri, 02 Sep 2005 05:49:00 GMT</pubDate><guid>http://www.cnitblog.com/zfly/archive/2005/09/02/2467.html</guid><wfw:comment>http://www.cnitblog.com/zfly/comments/2467.html</wfw:comment><comments>http://www.cnitblog.com/zfly/archive/2005/09/02/2467.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/zfly/comments/commentRss/2467.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zfly/services/trackbacks/2467.html</trackback:ping><description><![CDATA[<P>用wincvs登陆不了.... ... 郁闷中！！！！！<BR><BR>cvs -d ":pserver:anonymous@bespin.org:/var/lib/cvs/enet " login <BR>Logging in to :pserver:anonymous@bespin.org:2401:/var/lib/cvs/enet <BR>cvs [login aborted]: Connection to server failed<BR>Error connecting to host bespin.org: 不知道这样的主机。 </P>
<P>***** CVS exited normally with code 1 *****</P>
<P>&nbsp;</P><img src ="http://www.cnitblog.com/zfly/aggbug/2467.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zfly/" target="_blank">zfly</a> 2005-09-02 13:49 <a href="http://www.cnitblog.com/zfly/archive/2005/09/02/2467.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>