mirror of
				https://e.coding.net/weidongshan/01_all_series_quickstart.git
				synced 2025-11-04 13:05:59 +08:00 
			
		
		
		
	添加应用基础第8章_网络通信,第9章_多线程编程
This commit is contained in:
		
							
								
								
									
										792
									
								
								04_嵌入式Linux应用开发基础知识/doc_pic/08.网络编程/Linux下Socket编程.htm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										792
									
								
								04_嵌入式Linux应用开发基础知识/doc_pic/08.网络编程/Linux下Socket编程.htm
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										1051
									
								
								04_嵌入式Linux应用开发基础知识/doc_pic/08.网络编程/Linux网络编程入门 (转载).htm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1051
									
								
								04_嵌入式Linux应用开发基础知识/doc_pic/08.网络编程/Linux网络编程入门 (转载).htm
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										273
									
								
								04_嵌入式Linux应用开发基础知识/doc_pic/08.网络编程/僵死进程.htm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										273
									
								
								04_嵌入式Linux应用开发基础知识/doc_pic/08.网络编程/僵死进程.htm
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								04_嵌入式Linux应用开发基础知识/doc_pic/08.网络编程/僵死进程_files/160x81.jpg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								04_嵌入式Linux应用开发基础知识/doc_pic/08.网络编程/僵死进程_files/160x81.jpg
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 9.1 KiB  | 
							
								
								
									
										1
									
								
								04_嵌入式Linux应用开发基础知识/doc_pic/08.网络编程/僵死进程_files/baike.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								04_嵌入式Linux应用开发基础知识/doc_pic/08.网络编程/僵死进程_files/baike.js
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
(function(i){var l={version:"basejs_1.0.4",debug:false};function h(s,r){if(s instanceof Array){for(var q=0,p=s.length;q<p;q++){if(r.call(s[q],s[q],q)===false){return}}}else{for(var q in s){if(s.hasOwnProperty(q)){if(r.call(s[q],s[q],q)===false){return}}}}}function j(p,r){if(Array.prototype.indexOf){return p.indexOf(r)}for(var q=0,o=p.length;q<o;q++){if(p[q]===r){return q}}return -1}function a(o,q){if(Array.prototype.filter){return o.filter(q)}var p=[];h(o,function(t,s,r){if(q(t,s,r)){p.push(t)}});return p}function e(o,p){return a(p,function(q){return !g.loadingPaths[q]||!n(g.cache[q],o)})}function n(p,q){if(!p||p._loaded){return false}var r=p.deps||[];if(r.length){if(j(r,q)>-1){return true}else{for(var o=0;o<r.length;o++){if(n(g.cache[r[o]],q)){return true}}return false}}return false}function g(p,o){this.name=o;this.path=p;this.fn=null;this.exports={};this._loaded=false;this._requiredStack=[];this._readyStack=[];g.cache[this.name]=this}g.loadedPaths={};g.loadingPaths={};g.cache={};g.paths={};g.moduleFileMap={};g.requiredPaths={};g.lazyLoadPaths={};g.prototype={init:function(){if(!this._inited){this._inited=true;if(!this.fn){throw new Error('Module "'+this.name+'" not found!')}var o;if(o=this.fn.call(null,d,this.exports)){this.exports=o}}},load:function(){g.loadingPaths[this.path]=true;var o=l.debug?this.path:(g.moduleFileMap[this.name]||this.path);m.create({src:o})},lazyLoad:function(){var o=this.name,p=this.path;if(g.lazyLoadPaths[o]){this.define();delete g.lazyLoadPaths[o]}else{if(g.loadedPaths[p]){this.triggerStack()}else{if(!g.loadingPaths[p]){g.requiredPaths[this.name]=true;this.load()}}}},ready:function(p,q){var o=q?this._requiredStack:this._readyStack;if(p){if(this._loaded){p()}else{o.push(p)}}else{this._loaded=true;g.loadedPaths[this.path]=true;delete g.loadingPaths[this.path];this.triggerStack()}},triggerStack:function(){if(this._readyStack.length>0){this.init();h(this._readyStack,function(o){if(!o.doing){o.doing=true;o()}});this._readyStack=[]}if(this._requiredStack.length>0){h(this._requiredStack,function(o){if(!o.doing){o.doing=true;o()}});this._requiredStack=[]}},define:function(){var q=this,o=this.deps,p=[];if(!o){o=getDependents(q.fn)}o=e(q.path,o);if(o.length){g.loadingPaths[this.path]=true;h(o,function(s){var r=c(s);p.push(r.path)});h(o,function(s){var r=c(s);r.ready(function(){if(k(p)){q.ready()}},true);r.lazyLoad()})}else{this.ready()}}};function d(o){var p=c(o);p.init();return p.exports}function k(p){var o=true;h(p,function(q){if(!(q in g.loadedPaths)){return o=false}});return o}function f(o){return i?(i+o):o}function c(o){var p=o.indexOf(":")>-1?o:f(o);if(g.cache[o]){return g.cache[o]}return new g(p,o)}if(i&&i.charAt(i.length-1)=="/"){i=i.substr(0,i.length-1)}var m={create:function(q){if(q.src in this._paths){return}this._paths[q.src]=true;h(this._rules,function(r){r.call(null,q)});var p=document.getElementsByTagName("head")[0];var o=document.createElement("script");o.type=q.type||"text/javascript";q.charset&&(o.charset=q.charset);o.src=q.src;o.onload=o.onreadystatechange=function(){if((!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){q.loaded&&q.loaded();o.onload=o.onreadystatechange=null}};p.insertBefore(o,p.firstChild)},_paths:{},_rules:[],addPathRule:function(o){this._rules.push(o)}};l.use=function(r,q){if(typeof r==="string"){r=[r]}var p=[];var o=[];h(r,function(s,t){o[t]=false});h(r,function(s,u){var t=c(s);t.ready(function(){p[u]=t.exports;o[u]=true;var v=true;h(o,function(w){if(w===false){return v=false}});if(q&&v){q.apply(null,p)}});t.lazyLoad()})};l.module=function(o,q,r){var p=c(o);p.fn=q;p.deps=r;if(g.requiredPaths[o]){p.define()}else{g.lazyLoadPaths[o]=true}};l.pathRule=function(o){m.addPathRule(o)};l._fileMap=function(p,o){if(typeof p==="object"){h(p,function(q,r){l._fileMap(r,q)})}else{if(typeof o==="string"){o=[o]}h(o,function(q){g.moduleFileMap[q]=p})}};var b={};l.context=function(p,r){var q=arguments.length;if(q>1){b[p]=r}else{if(q==1){if(typeof p=="object"){for(var o in p){if(p.hasOwnProperty(o)){b[o]=p[o]}}}else{return b[p]}}}};"F" in window||(window.F=l)})("http://baike.bdimg.com/");
 | 
			
		||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										19
									
								
								04_嵌入式Linux应用开发基础知识/doc_pic/08.网络编程/僵死进程_files/bk.css
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								04_嵌入式Linux应用开发基础知识/doc_pic/08.网络编程/僵死进程_files/bk.css
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
			
		||||
.enc-tip{position:absolute;right:82px;top:32px;width:240px;visibility:hidden;z-index:199}.enc-tip .close{position:absolute;width:13px;height:13px;right:10px;top:10px;background:url(http://img.baidu.com/img/baike/encourage/encourage.png) no-repeat 0 -20px;overflow:hidden;text-indent:3000px}.enc-wrap{width:100%;border:1px solid #D1B27B;border-left:none\9;border-right:none\9;-moz-border-radius:2px;-webkit-border-radius:2px;border-radius:2px}.enc-content{background:#FFFFDB;min-height:60px;_height:60px;padding:15px 10px 12px 0;border-radius:2px;margin:0 -1px\9;border-left:1px solid #D1B27B\9;border-right:1px solid #D1B27B\9;position:relative}.enc-content a{color:#00c;text-decoration:none}.enc-content .fl{float:left}.enc-content .fr{float:right;width:204px}.enc-content .fl a{margin:0 10px 15px 15px;display:inline-block}.enc-content h3{font-size:12px;font-weight:bold;color:#000;height:20px;line-height:20px;white-space:nowrap}.enc-content .enc-txt{font-size:12px;line-height:18px;word-wrap:break-word}.enc-tip .ctr{position:absolute;width:16px;height:16px;top:0}
 | 
			
		||||
.enc-tip .tri{border-width:8px;border-style:dashed dashed solid;border-color:transparent transparent #D1B27B;position:absolute;width:0;height:0;font-size:0;overflow:hidden;position:absolute}.enc-tip .ctr .out{border-color:transparent transparent #D1B27B;top:-15px}.enc-tip .ctr .in{border-color:transparent transparent #FFFFDB;top:-14px}.enc-content .xiaohui{width:62px;height:70px;background:url(http://img.baidu.com/img/baike/encourage/encourage.png) no-repeat -18px 0;float:right;margin:0 -26px 0 0;position:relative}.enc-ver-tip{width:180px}.enc-ver-content{padding:10px;font-size:12px}.enc-content .ver_con{padding:0 0 10px 0;border-bottom:1px #f6f0cd dashed;margin:0 0 10px 0;list-style:none;line-height:20px}.enc-content .ver_con li{margin:0}.edit-success img{border:none}.progress-bar,.progress-bar .pl,.progress-bar .pr,.progress-bar .pb{background-image:url('http://baike.bdimg.com/static/usercenter/images/task/progress-bar.png?@=yue4bp');height:13px;line-height:13px;overflow:hidden}.progress-bar .pl{width:3px;background-position:-126px 0}
 | 
			
		||||
.progress-bar .pr{width:3px;background-position:-129px 0}.progress-bar .pb{background-position:0 -13px;max-width:120px}.progress-bar{position:relative;width:126px}.process-inner{position:absolute;left:0;top:0}.process-inner span{display:inline-block}.process-text{text-align:center;color:#fff;line-height:13px;position:relative}.message-board-box{position:fixed;width:150px;min-height:30px;_height:30px;top:150px;right:210px;background:red}.btl-indicator{width:232px;border:1px solid #bbe0f3;border-width:2px 0;position:relative;background-color:white}#btl-indicator-content{margin:0 -1px;border:1px solid #bbe0f3;border-width:0 2px;position:relative;overflow:hidden;zoom:1}#btl-indicator-content ul{padding:10px 16px 6px;margin:0;font-family:\5b8b\4f53;font-size:12px;list-style-type:none}#btl-indicator-content ul li{line-height:14px;padding:0;margin:0;margin-bottom:5px;position:relative}#btl-indicator-content ul li .msg-content{padding-left:7px}#btl-indicator-content a,#btl-indicator-content a:hover{color:#1190d1;text-decoration:underline}
 | 
			
		||||
.dot{width:3px;height:3px;display:inline-block;position:absolute;top:6px;background-color:#bcbcbc;margin:0 5px 5px 0;overflow:hidden}.red{color:red}.btl-indicator a.close{position:absolute;right:5px;top:3px;width:13px;height:13px;overflow:hidden;color:#1190d1;font-family:\5b8b\4f53;font-weight:bold;font-size:12px;text-decoration:none}.btl-indicator a.close:hover{color:red}.float-board{position:fixed;_position:absolute;right:30px;top:30px}.tip-block{padding:0 0 10px}.tip-content{line-height:22px;font-size:14px;padding:9px 12px 3px 12px;background-color:#FFF7F0;border:1px solid #FFD4AD}.tip-content-header{height:25px;display:block;border-bottom:1px dotted #9f9f9f;margin-bottom:6px}.tip-content-header span{padding-left:5px;font-weight:bold;float:left}.tip-content-header a:link,.tip-content-header a:visited,.tip-content-header a:hover{color:#36c}.tip-link-right{float:right;display:inline;padding-left:17px;line-height:18px;overflow:hidden;background:#fff7f0 url('http://img.baidu.com/img/baike/bk-split-icons.png') no-repeat 0 -28px}
 | 
			
		||||
.tip-content-msg{width:auto;display:block}.tip-content-msg .tip-msg-row{width:auto;margin:2px 0;*zoom:1}.tip-content-msg .tip-msg-row:after{content:'clear';clear:both;font-size:0;height:0;overflow:hidden;display:block}.tip-msg-label{float:left;width:80px;font-weight:bold;display:block;padding-left:20px}.tip-msg{margin-left:100px;width:auto;display:block;word-wrap:break-word}.throw-btl-link{padding-left:10px;background:transparent url('http://img.baidu.com/img/baike/bk-split-icons.png') no-repeat;background-position:left -46px;margin-left:5px}.tip-content-footer{border-top:1px dotted #9F9F9F;padding-top:3px}.throwbtl-link-view{padding-left:10px;background:transparent url('http://img.baidu.com/img/baike/bk-split-icons.png') no-repeat;background-position:left -48px;margin-left:5px;float:right;font-weight:normal;font-size:12px;*line-height:15px}.lemma-top-link{float:none;vertical-align:middle;font-weight:normal;font-size:12px;height:16px;line-height:11px;*line-height:15px;width:auto;margin-top:11px;margin-right:8px;text-decoration:underline}
 | 
			
		||||
.dividable-lemma{padding-left:17px;background:transparent url('http://baike.bdimg.com/static/usercenter/images/bottle/dividable-lemma.png?@=x666rv') no-repeat}.throwbtl-link-head{padding-left:10px;background:transparent url('http://baike.bdimg.com/static/usercenter/images/bottle/btl-info-icon.png?@=5rmfgd') no-repeat left -20px;margin-right:18px}.lemma-top-link-divider{float:none;width:0;border-left:1px dotted gray;overflow:hidden;height:13px;display:none}.edit-section-throwbtl-link{float:right;margin-top:6px;margin-right:3px}.bkshopdialog .bk-dialog-accept,.bkshopdialog .bk-dialog-cancel{position:static}#bkshop .bk-dialog-content{font:normal 1.2em/1.8em arial,<EFBFBD><EFBFBD><EFBFBD><EFBFBD>}.bkshopdialog a{color:#136EC2}.bkshopdialog .btns{text-align:center;height:30px;line-height:30px;padding:10px 0 0 0;vertical-align:middle;*line-height:20px;*padding:0;margin:20px auto 10px auto}.bkshopdialog .btns a{font-size:14px;margin-left:10px}.bkshopdialog .btns a.bk-dialog-accept:hover{text-decoration:none}.bkshopdialog .footer{text-align:left;font-size:12px;white-space:normal;color:black;margin-top:10px}
 | 
			
		||||
.bkshopdialog .sinaweibo{display:inline-block;height:32px;vertical-align:middle;margin-right:10px}.bkshopdialog .sinaweibo a{width:142px;height:32px;background:transparent url('http://baike.bdimg.com/static/usercenter/images/snwb_btns.gif?@=70go25') no-repeat -32px 0;display:inline-block}@CHARSET "UTF-8";.doubtdialog{padding-left:10px;word-break:break-all;word-wrap:break-word}.doubtdialog a{text-decoration:none}.doubtdialog a:hover{text-decoration:underline}.doubtdialog .doubtdialog-btns{text-align:left;padding:0;margin:14px auto 20px auto}.doubtdialog .footer{color:#666;border-top:1px dashed #E5E5E5;padding-top:10px;padding-bottom:5px}.doubtdialog i{font-weight:bold;color:black;font-style:normal;font-size:14px}.doubtdialog .color{color:#136ec2}.doubtdialog .gray{color:black}.doubtdialog p.gray{padding-bottom:3px}.doubtdialog #collapse-btn,.doubtdialog #expand-btn,.doubtdialog #collapse-comment-btn{display:inline-block;width:40px;height:20px;border:0 solid red;margin-left:20px;color:#136EC2}.doubtdialog #collapse-comment-btn{margin-left:0.2em}
 | 
			
		||||
.doubtdialog .collapsed,.doubtdialog .expanded{cursor:pointer;background:transparent url('http://baike.bdimg.com/static/usercenter/images/doubt/exp-arrow.png?@=17vfpye') no-repeat 28px -5px}.doubtdialog .expanded{background-position:28px -59px}.bkdialog-doubt .bkdialog-content .dialog-content-inner{padding-bottom:0}.doubtdialog .gray,.doubtdialog .color{line-height:20px}.doubtdialog .content{padding-top:3px}.doubtdialog .accept-hover{background-position:left -40px}.doubtdialog .accept-hover .bkdialog-button-label{background-position:right -40px}.doubtdialog .cancel-hover{background-position:left -160px}.doubtdialog .cancel-hover .bkdialog-button-label{background-position:right -160px}.judgeform{width:495px;border:0 solid red;padding:2px 10px 10px 10px}.judge-form .judgetitle{font-size:14px;font-weight:bold;margin-bottom:10px}.judge-form .errContent{font-size:12px;font-weight:normal}.judge-form .f-row{font-size:12px;font-weight:normal;margin:10px 0}.judge-form .f-row .desc{float:left;width:130px;text-align:right}.judge-form .f-row .input{margin-left:130px;_float:left;_margin-left:0}
 | 
			
		||||
.judge-form .f-row input,.judge-form .f-row textarea{width:355px;border-radius:2px;border:1px solid #e5e5e5;outline:none;padding:3px;resize:none}.judge-form .f-row input{height:24px}.judge-form .f-row textarea{height:85px}.judge-form .more-refer{float:right;cursor:pointer}.judge-form .plus{color:#44a701;font-size:19px;margin-right:3px;line-height:13px;display:inline-block}.judgeTip,.judgeComplete{padding:20px 20px 20px 20px;text-align:center;line-height:30px;font-size:14px}.bkdialog-judge-tip .doubtdialog-btns{margin-top:4px}.judgeComplete{padding-bottom:70px}.judgeComplete h1{margin-bottom:10px}.judgeTip{padding-bttom:0}.judgeTip h1{margin-bottom:10px}.judgeTip p{height:22px}.bkdialog-judge .footer{padding:10px;border-top:1px dashed #E5E5E5;margin-bottom:20px}.bkdialog-judge .footer a{text-decoration:none}.judgeform-error{color:red;text-align:center;margin-top:30px}.bkdialog-judge .doubtdialog .doubtdialog-btns{text-align:center}.judgeform .judgetip{margin-bottom:20px}.judgeform .help{float:right;font-size:12px;font-weight:normal}
 | 
			
		||||
.bkdialog-judge .bkdialog-content{overflow:hidden!important}.tangram-scrollbar{width:100%;height:100%}.tangram-scrollbar-track{overflow:hidden;width:100%;height:100%}.tangram-scrollbar-slider{width:100%;height:100%}.tangram-scrollbar-slider-thumb{width:100%;height:100%;background:#a9b8ce}.tangram-scrollbar-prev,.tangram-scrollbar-next,.tangram-scrollbar-thumb-btn{font-size:0}.scrollbar-y{background:#f2f5f7}.scrollbar-y-prev{line-height:0;width:8px;height:0}.scrollbar-y-prev-hover{background-position:-15px 0}.scrollbar-y-prev-press{background-position:-30px 0}.scrollbar-y-next{width:8px;height:0;line-height:0}.scrollbar-y-next-hover{background-position:-15px -15px}.scrollbar-y-next-press{background-position:-30px -15px}.scrollbar-y-thumb-btn{position:relative;width:100%;height:100%}.scrollbar-y-thumb-prev{position:absolute;top:0;width:100%;height:0;font-size:0}.scrollbar-y-thumb-next{position:absolute;bottom:0!important;bottom:-1px;width:100%;height:0;font-size:0}.scrollbar-y-thumb-btn-hover{background:#95a8c3}
 | 
			
		||||
.scrollbar-y-thumb-btn-hover .scrollbar-y-thumb-prev{background-position:-45px -10px}.scrollbar-y-thumb-btn-hover .scrollbar-y-thumb-next{background-position:-45px -15px}.scrollbar-y-thumb-btn-press{background-position:-90px 0}.scrollbar-y-thumb-btn-press .scrollbar-y-thumb-prev{background-position:-45px -20px}.scrollbar-y-thumb-btn-press .scrollbar-y-thumb-next{background-position:-45px -25px}.scrollbar-x{display:hidden}.scrollbar-x-track{float:left}.scrollbar-x-prev{float:left;width:8px;height:8px}.scrollbar-x-prev-hover{background-position:-15px 0}.scrollbar-x-prev-press{background-position:-30px 0}.scrollbar-x-next{float:left;width:8px;height:8px}.scrollbar-x-next-hover{background-position:-15px -15px}.scrollbar-x-next-press{background-position:-30px -15px}.scrollbar-x-thumb-btn{position:relative;width:100%;height:100%}.scrollbar-x-thumb-prev{position:absolute;left:0;width:5px;height:100%;font-size:0}.scrollbar-x-thumb-next{position:absolute;right:0!important;right:-1px;width:5px;height:100%;font-size:0}
 | 
			
		||||
.scrollbar-x-thumb-btn-hover{background-position:0 -45px}.scrollbar-x-thumb-btn-hover .scrollbar-x-thumb-prev{background-position:-45px -15px}.scrollbar-x-thumb-btn-hover .scrollbar-x-thumb-next{background-position:-50px -15px}.scrollbar-x-thumb-btn-press{background-position:0 -60px}.scrollbar-x-thumb-btn-press .scrollbar-x-thumb-prev{background-position:-55px 0}.scrollbar-x-thumb-btn-press .scrollbar-x-thumb-next{background-position:-60px 0}.doubtbox-icon{background-color:white;cursor:pointer;position:fixed;right:10px;bottom:13px;width:27px;height:21px;border:0 solid blue;z-index:2;overflow-x:visible;_position:absolute;_bottom:auto;_top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||10)));background:transparent url('http://baike.bdimg.com/static/usercenter/images/doubt/doubticon.png?@=emxt28') no-repeat top left}.doubtbox{background-color:white;position:fixed;right:-500px;bottom:0;width:253px;border:1px solid #b2bec7;z-index:2;overflow-x:hidden;_position:absolute;_bottom:auto;_top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));*font-size:11px}
 | 
			
		||||
.doubtbox a{text-decoration:none}.doubtbox-wrap{background-color:white;padding:1px;padding-bottom:0}.doubtbox-header{height:20px;background-color:#edf2f5;padding:6px 15px 4px 15px;font-size:14px;line-height:20px;color:#333;font-weight:bold;overflow:hidden}.doubtbox-tab-wrap{padding:5px 15px}.doubtbox-quit{float:right;font-weight:normal;font-size:12px;text-decoration:none}.doubtbox-tab-container{height:270px;border:1px solid #c8d3db;border-top:0;margin:0 -2px;width:255px;overflow:hidden;*position:relative}.doubtbox-tab-switcher{height:30px;background-color:#edf2f5;font-size:14px;font-weight:bold;padding-left:10px;border-top:1px solid white;*position:relative}.doubtbox-tab-switcher li{float:left;padding:5px 10px;cursor:pointer;color:#0163af;height:21px;overflow:hidden}.doubtbox-tab-switcher li.on{background-color:white;padding-top:7px;margin-top:-2px;cursor:default;border-left:1px solid #b2bec7;border-right:1px solid #b2bec7;color:#666;_position:relative}.doubtbox-collapsex .doubtbox-header,.doubtbox-collapse .doubtbox-tab-container{display:none}
 | 
			
		||||
.doubtbox-collapsex .doubtbox-content{height:30px}.doubtbox-collapsex .doubtbox-tab-switcher li.on{background-color:#edf2f5;cursor:pointer;padding-top:5px;margin-top:0}.doubtbox-collapsex .doubtbox-tab-switcher{border:0}.doubtbox-collapsex .doubtbox-tab-switcher li.on,.doubtbox-collapse .doubtbox-tab-switcher li{border:none;color:#0163af}.doubtbox-collapsex .doubtbox-tab-switcher li{padding-bottom:4px}.doubtbox-collapsex .tangram-scrollpanel-main{display:none}.doubtbox .tangram-scrollpanel{line-height:1.5em;zoom:1}.doubtbox .tangram-scrollpanel-main{overflow:hidden;zoom:1}.doubtbox-data{font-size:12px;line-height:18px;word-break:break-all}.doubtbox-data .list-content{margin-bottom:8px}.doubtbox-data li{margin-bottom:8px}.doubtbox-data .slim,.doubtbox-data .fat{word-break:break-all}.doubtbox-data .expand i,.doubtbox-data .collapse i{display:inline-block;height:11px;width:13px;background:transparent url('http://baike.bdimg.com/static/usercenter/images/doubt/exp-arrow.png?@=17vfpye') no-repeat 2px -7px;*background-position:2px -10px;_background-position:2px -7px}
 | 
			
		||||
.doubtbox-data .collapse i{background-position:2px -62px;*background-position:2px -65px;_background-position:2px -62px}.doubtbox-data .expandx,.doubtbox-data .collapsex{float:right}.doubtbox-data .num{color:#fe6000}@-moz-document url-prefix(){.doubtbox-data .num{vertical-align:middle}}.doubtbox-data .btn-container{clear:both;display:block;height:25px}.doubtbox .doubtbox-data .btn-container-boxmode3{display:none}.doubtbox-data .btn,.doubtbox-data .btn:hover,.doubtbox-data .btn:active{text-decoration:none}.doubtbox-data .btn{background:transparent url('http://baike.bdimg.com/static/usercenter/images/doubt/doubt-btn.png?@=1qxn6e') no-repeat;color:#0163AF;cursor:pointer;display:inline-block;float:right;height:19px;padding-top:2px;text-align:center;width:66px;*display:inline;*zoom:1}.doubtbox-data .btn:hover{background-position:0 -21px}.doubtbox-data .btn:active{background-position:0 -42px}.doubtbox-data .showExpand{white-space:nowrap;zoom:1}.doubtbox-data .showExpand-0{display:none}.doubtbox .guide{color:#666;padding-top:4px}
 | 
			
		||||
.doubtbox .guide .expandFlash i,.doubtbox .guide .collapseFlash i{display:inline-block;height:11px;width:13px;background:transparent url('http://baike.bdimg.com/static/usercenter/images/doubt/exp-arrow.png?@=17vfpye') no-repeat 2px -7px}.doubtbox .guide .collapseFlash i{background:transparent url('http://baike.bdimg.com/static/usercenter/images/doubt/exp-arrow.png?@=17vfpye') no-repeat 2px -62px}.doubtbox .guide .expandFlash i{*background-position-y:-10px;_background-position-y:-7px}.doubtbox .guide .collapseFlash i{*background-position-y:-65px;_background-position-y:-62px}.doubtbox .content-footer{border-top:1px dotted #ddd;padding-top:4px;margin-top:0}.doubtbox .btn-container{display:block;height:22px;margin-top:0}.doubtbox .guide .flash{height:150px;width:225px;overflow:hidden;padding:4px 0}.doubtbox .guide .btn-container{height:20px}.doubtbox .guide .btn-container a{float:right}.doubtbox-content .doubt-t1{color:#666;border-bottom:1px dotted #ddd;padding-bottom:7px}.doubtbox-content .doubt-t2{color:#666;padding:9px 0 5px 0}.doubtbox-content .doubt-t3{color:#333;font-weight:bold;font-size:14px;padding:5px 0;margin-bottom:3px}
 | 
			
		||||
.doubtbox-content .doubt-t4{color:#666;border-top:1px dotted #ddd;padding:5px 0}.doubtbox-content .expert-t1{color:#666;border-bottom:1px dotted #ddd;padding:5px 0 7px 0}.doubtbox-content .expert-t2{color:#666;padding-top:5px}.doubtbox-content .expert-t3{color:#333;font-weight:bold;font-size:14px;padding:15px 0 5px 0}.doubtbox-content .expert-t4{color:#666;border-bottom:0 dotted #ddd;padding-bottom:7px}.doubtbox-content .tangram-scrollbar-slider-thumb{background-color:#cad2db;border-radius:4px}.doubtbox-content .scrollbar-y-thumb-btn-hover{border-radius:4px;background:#95A8C3}.doubtbox-content .tangram-scrollbar-slider{background-color:#f2f5f7}.num{display:inline-block;overflow:hidden;position:relative;*display:inline;*zoom:1}.num em{font-style:normal}.animation{position:absolute;left:0;background-color:white}.doubt-box .tangram-scrollpanel-main{*overflow:hidden}.doubtbox-icon .doubtbox-tipbubble-wrap{position:relative}.doubtbox-icon .doubtbox-tipbubble{position:absolute;width:175px;height:37px;top:-38px;cursor:default;background:transparent url('http://baike.bdimg.com/static/usercenter/images/doubt/doubt-tip-bubble.png?@=172nu45?@=null') no-repeat 0 0;left:-75px}
 | 
			
		||||
.doubtbox-icon .doubtbox-tipbubble-close{position:absolute;width:13px;height:13px;top:-34px;left:79px;opacity:0;cursor:pointer}.ipad .doubtIcon,.ipad .doubtbox-icon{display:none}@CHARSET "UTF-8";.expertcard .bkdialog-title{display:none}.expert-card-wrap{border:1px solid #E5E5E5;filter:progid:DXImageTransform.Microsoft.Gradient(enabled=1,startColorstr=#FBFCFD,endColorstr=#F0F5FA);background-image:-webkit-gradient(linear,left top,left bottom,from(#fbfcfd),to(#f0f5fa));background-image:-moz-linear-gradient(top,#fbfcfd,#f0f5fa);background-image:-ms-linear-gradient(top,#fbfcfd,#f0f5fa);background-image:-o-linear-gradient(top,#fbfcfd,#f0f5fa);background-image:linear-gradient(top,#fbfcfd,#f0f5fa);padding:10px 10px 0 10px;width:330px;*height:120px;min-height:120px}.expert-card .expert-img{float:left;display:block;border:1px solid #ddd;margin-top:6px}.expert-card .expert-img img{width:85px;height:85px;display:block}.expert-card .expert-info{margin-left:90px;padding-left:10px}.expert-info a:link{text-decoration:none}
 | 
			
		||||
.expert-info .expert-name{font-weight:bold;color:#136ec2;margin-bottom:20px}.expert-info .num{color:#f70}.expert-info .i{display:inline-block;height:20px;width:16px;background:url('http://baike.bdimg.com/static/usercenter/images/doubt/experticon.png?@=gdomap') no-repeat 0 4px;_background:none;_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="http://baike.bdimg.com/static/usercenter/images/doubt/experticon.png",sizingMethod="image");position:relative;top:3px;_top:0;margin-left:3px}#bkshopViewPropsTips{line-height:24px;padding-top:6px;font-family:\5b8b\4f53}#bkshopViewPropsTips .num{color:#f70;font-family:verdana}#bkshopViewPropsTips a{float:right;margin-right:5px}#bkshopViewPropsTips .propsicon,#bkshopViewPropsTips .nopropsicon{float:left;margin:2px 6px 0 0;width:18px;height:16px;background:url('http://baike.bdimg.com/static/usercenter/images/shop/shopbg.png?@=x1hauz') no-repeat}#bkshopViewPropsTips .propsicon{background-position:-20px -452px}#bkshopViewPropsTips .nopropsicon{background-position:-62px -452px}
 | 
			
		||||
@@ -0,0 +1,3 @@
 | 
			
		||||
.usercardtitle{width:60px;height:16px;background:url(http://img.baidu.com/img/baike/titles.gif) no-repeat}.uc-l .level2{background-position:0 -23px}.uc-l .level3{background-position:0 -46px}.uc-l .level4{background-position:0 -68px}.uc-l .level5{background-position:0 -89px}.uc-l .level6{background-position:0 -121px}.uc-l .level7{background-position:0 -144px}.uc-l .level8{background-position:0 -167px}.uc-l .level9{background-position:0 -190px}.uc-l .level10{background-position:0 -214px}.uc-l .level11{background-position:0 -248px}.uc-l .level12{background-position:0 -271px}.uc-l .level13{background-position:0 -294px}.uc-l .level14{background-position:0 -317px}.uc-l .level15{background-position:0 -340px;width:75px}.pillar{display:inline-block;width:0;height:100%;vertical-align:middle}.fix{*zoom:1}.fix:after{content:'clear';clear:both;height:0;overflow:hidden;display:block}.user-card{font:12px/1.5 arial,\5b8b\4f53,sans-serif}.user-card ul,.user-card li{margin:0;padding:0;list-style:none}.user-card img{border:0}
 | 
			
		||||
.user-card a,.user-card a:hover{text-decoration:none;color:#116EC2}.user-card{width:350px;border:1px solid #b3daff;background:#f7fcff url('http://baike.bdimg.com/static/usercenter/images/usercard/usercard-bg.png?@=2u51po') no-repeat 5px 7px}.user-card .top-bg{height:2px;margin-top:1px;background-color:#e6f8ff;overflow:hidden}.user-card .uc-l{float:left;width:100px;padding:8px 3px;text-align:center;line-height:30px;color:#116EC2}.user-card .uc-r{float:left;width:244px;height:148px;overflow:hidden;font-family:\5b8b\4f53}.uc-l .uc-id{font-weight:bold}.uc-l .uc-name{width:100%;white-space:nowrap}.uc-l .uc-pic{width:84px;height:84px;margin:0 auto;border:1px solid #ddd;-moz-box-shadow:1px 1px 3px #DEEEFF;-webkit-box-shadow:1px 1px 3px #DEEEFF;box-shadow:1px 1px 3px #DEEEFF}.uc-level a{text-indent:3000px;display:block;margin:0 auto;overflow:hidden}.uc-r .uc-items{display:inline-block;*display:inline;zoom:1;vertical-align:middle;width:238px}.uc-items div{font-size:12px}.uc-r a{color:#136ec2}.uc-r li{float:left}.uc-role li{margin-right:4px}
 | 
			
		||||
.uc-role img{margin-right:2px;vertical-align:middle}.uc-role a{vertical-align:middle}.uc-badge{margin-top:4px}.uc-badge li{margin-right:16px}.uc-going-task .fl{float:left}.uc-going-task ul{float:left;width:140px}.uc-going-task li{margin-right:6px}.uc-default{margin-bottom:4px}.uc-default .msg{padding-left:30px}.uc-default span{font-size:14px;line-height:22px;font-weight:bold}.uc-default .indent{text-indent:26px}.uc-default .book{width:110px;height:76px;margin:0 auto;background:url('http://baike.bdimg.com/static/usercenter/images/usercard/usercard-bg.png?@=2u51po') no-repeat 0 -154px}.usercard-wrap{width:352px;position:absolute;z-index:99999;top:-500px;left:-500px;background:#fff url('http://baike.bdimg.com/static/usercenter/images/usercard/loading.gif?@=wyj7lf') no-repeat 50% 50%;border:1px solid #ccc\9;-moz-box-shadow:0 1px 6px #bbb;-webkit-box-shadow:0 1px 6px #bbb;box-shadow:0 1px 6px #bbb;-moz-border-radius:2px;-webkit-border-radius:2px;border-radius:2px}.expertcard{border-top:2px solid #3370af;-moz-box-shadow:2px 2px 0 #EEE;-webkit-box-shadow:2px 2px 0 #EEE;box-shadow:2px 2px 0 #EEE;-moz-border-radius:0;-webkit-border-radius:0;border-radius:0}
 | 
			
		||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										25
									
								
								04_嵌入式Linux应用开发基础知识/doc_pic/08.网络编程/僵死进程_files/h.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								04_嵌入式Linux应用开发基础知识/doc_pic/08.网络编程/僵死进程_files/h.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
			
		||||
(function(){var c={id:"55b574651fcae74b0a9f1cf9c8d7c93a",dm:["baike.baidu.com"],etrk:[],js:"tongji.baidu.com/hm-web/js/",icon:'',br:false,ctrk:true,align:1,nv:-1,vdur:1800000,age:31536000000,se:[[1,'baidu.com','word|wd',1,'news,tieba,zhidao,mp3,image,video,hi,baike,wenku,opendata,jingyan'],[2,'google.com','q',0,'tbm=isch,tbm=vid,tbm=nws|source=newssearch,tbm=blg,tbm=frm'],[4,'sogou.com','query',1,'news,mp3,pic,v,gouwu,zhishi,blogsearch'],[6,'search.yahoo.com','p',1,'news,images,video'],[7,'yahoo.cn','q',1,'news,image,music'],[8,'soso.com','w',1,'image,video,music,sobar,wenwen,news,baike'],[11,'youdao.com','q',1,'image,news,,mp3,video'],[12,'gougou.com','search',1,',movie,,,,,video'],[13,'bing.com','q',2,'images,videos,news'],[14,'so.com','q',1,'video,news'],[15,'jike.com','q',1,'news,image,video'],[16,'qihoo.com','kw',0,''],[17,'etao.com','q',1,'s,8'],[18,'soku.com','keyword',2,'a']]};var g=true,h=null,i=false;function k(a,b,d){var e;d.i&&(e=new Date,e.setTime(e.getTime()+d.i));document.cookie=a+"="+b+(d.domain?"; domain="+d.domain:"")+(d.path?"; path="+d.path:"")+(e?"; expires="+e.toGMTString():"")+(d.N?"; secure":"")};(function(){function a(){if(!a.e){a.e=g;for(var b=0,d=e.length;b<d;b++)e[b]()}}function b(){try{document.documentElement.doScroll("left")}catch(d){setTimeout(b,1);return}a()}var d=i,e=[],f;document.addEventListener?f=function(){document.removeEventListener("DOMContentLoaded",f,i);a()}:document.attachEvent&&(f=function(){document.readyState==="complete"&&(document.detachEvent("onreadystatechange",f),a())});(function(){if(!d)if(d=g,document.readyState==="complete")a.e=g;else if(document.addEventListener)document.addEventListener("DOMContentLoaded",
 | 
			
		||||
f,i),window.addEventListener("load",a,i);else if(document.attachEvent){document.attachEvent("onreadystatechange",f);window.attachEvent("onload",a);var e=i;try{e=window.frameElement==h}catch(l){}document.documentElement.doScroll&&e&&b()}})();return function(b){a.e?b():e.push(b)}})().e=i;function m(a,b){if(window.sessionStorage)try{window.sessionStorage.setItem(a,b)}catch(d){}}function n(a){return window.sessionStorage?window.sessionStorage.getItem(a):h};function o(a,b){var d=a.match(RegExp("(^|&|\\?|#)("+b+")=([^&#]*)(&|$|#)",""));return d?d[3]:h}function p(a){var b;return(b=(a=a.match(/^(https?:\/\/)?([^\/\?#]*)/))?a[2].replace(/.*@/,""):h,a=b)?a.replace(/:\d+$/,""):a};var q=/msie (\d+\.\d+)/i.test(navigator.userAgent),r=navigator.cookieEnabled,s=navigator.javaEnabled(),t=navigator.language||navigator.browserLanguage||navigator.systemLanguage||navigator.userLanguage||"",u=window.screen.width+"x"+window.screen.height,v=window.screen.colorDepth;function w(a,b){var d=new Image,e="mini_tangram_log_"+Math.floor(Math.random()*2147483648).toString(36);window[e]=d;d.onload=d.onerror=d.onabort=function(){d.onload=d.onerror=d.onabort=h;d=window[e]=h;b&&b(a)};d.src=a};function x(a,b,d){a.attachEvent?a.attachEvent("on"+b,function(b){d.call(a,b)}):a.addEventListener&&a.addEventListener(b,d,i)};var y;function z(){if(!y)try{y=document.createElement("input"),y.type="hidden",y.style.display="none",y.addBehavior("#default#userData"),document.getElementsByTagName("head")[0].appendChild(y)}catch(a){return i}return g};c.se.push([14,"so.360.cn","q",1,",news"]);c.se.push([14,"v.360.cn","q",1,"so"]);var A=0,C=(new Date).getTime(),D=window.location.protocol=="https:"?"https:":"http:",E="cc,cf,ci,ck,cl,cm,cp,cw,ds,ep,et,fl,ja,ln,lo,lt,nv,rnd,sb,se,si,st,su,sw,sse,v,cv,lv,u,api".split(",");function F(){if(typeof window["_bdhm_loaded_"+c.id]=="undefined")window["_bdhm_loaded_"+c.id]=g,this.a={},this.b=[],this.j={},this.f=0,this.G()}
 | 
			
		||||
F.prototype={D:function(){var a="";try{external.twGetVersion(external.twGetSecurityID(window))&&external.twGetRunPath.toLowerCase().indexOf("360se")>-1&&(a=17)}catch(b){}return a},k:function(a,b){var a=a.replace(/:\d+/,""),b=b.replace(/:\d+/,""),d=a.indexOf(b);return d>-1&&d+b.length==a.length},q:function(a,b){a=a.replace(/^https?:\/\//,"");return a.indexOf(b)==0},d:function(a){for(var b=0;b<c.dm.length;b++)if(c.dm[b].indexOf("/")>-1){if(this.q(a,c.dm[b]))return g}else{var d=p(a);if(d&&this.k(d,c.dm[b]))return g}return i},
 | 
			
		||||
o:function(){for(var a=window.location.hostname,b=0,d=c.dm.length;b<d;b++)if(this.k(a,c.dm[b]))return c.dm[b].replace(/(:\d+)?[\/\?#].*/,"");return a},p:function(){for(var a=0,b=c.dm.length;a<b;a++){var d=c.dm[a];if(d.indexOf("/")>-1&&this.q(window.location.href,d))return d.replace(/^[^\/]+(\/.*)/,"$2")+"/"}return"/"},F:function(){if(document.referrer)for(var a=0,b=c.se.length;a<b;a++){if(RegExp(c.se[a][1]).test(p(document.referrer))){var d=o(document.referrer,c.se[a][2])||"";if(d||!(c.se[a][0]!=
 | 
			
		||||
2&&c.se[a][0]!=14&&c.se[a][0]!=17)){c.se[a][0]==1&&document.referrer.indexOf("cpro.baidu.com")>-1&&(d="");this.a.se=c.se[a][0];for(var b=this.a,e=c.se[a],a=0,f=e[3]==2?e[1]+"/":"",j=e[3]==1?"."+e[1]:"",e=e[4].split(","),l=0,B=e.length;l<B;l++)if(e[l]!==""&&RegExp(f+e[l]+j).test(document.referrer)){a=l+1;break}b.sse=a;this.a.sw=d;return 2}}}else return C-A>c.vdur?1:4;d=i;return(d=this.d(document.referrer)&&this.d(window.location.href)?g:this.k(p(document.referrer)||"",window.location.hostname))?C-
 | 
			
		||||
A>c.vdur?1:4:3},getData:function(a){try{var b,d=RegExp("(^| )"+a+"=([^;]*)(;|$)").exec(document.cookie);if(!(b=d?d[2]:h)){var e;if(!(e=n(a)))a:{if(window.localStorage){var f=window.localStorage.getItem(a);if(f){var j=f.indexOf("|"),l=f.substring(0,j)-0;if(l&&l>(new Date).getTime()){e=f.substring(j+1);break a}}}else if(z())try{y.load(window.location.hostname);e=y.getAttribute(a);break a}catch(B){}e=h}b=e}return b}catch(M){}},setData:function(a,b,d){try{if(k(a,b,{domain:this.o(),path:this.p(),i:d}),
 | 
			
		||||
d){var e=new Date;e.setTime(e.getTime()+d||31536E6);try{if(window.localStorage)b=e.getTime()+"|"+b,window.localStorage.setItem(a,b);else if(z())y.expires=e.toUTCString(),y.load(window.location.hostname),y.setAttribute(a,b),y.save(window.location.hostname)}catch(f){}}else m(a,b)}catch(j){}},H:function(a){try{if(k(a,"",{domain:this.o(),path:this.p(),i:-1}),window.sessionStorage&&window.sessionStorage.removeItem(a),window.localStorage)window.localStorage.removeItem(a);else if(z())try{y.load(window.location.hostname),
 | 
			
		||||
y.removeAttribute(a),y.save(window.location.hostname)}catch(b){}}catch(d){}},K:function(){var a,b,d,e,f;A=this.getData("Hm_lpvt_"+c.id)||0;b=this.F();a=b!=4?1:0;if(d=this.getData("Hm_lvt_"+c.id)){for(e=d.split(",");C-e[0]>2592E6;)e.shift();f=e.length<4?2:3;for(a===1&&e.push(C);e.length>4;)e.shift();d=e.join(",");e=Math.round((e[e.length-1]-0)/1E3)}else d=C,e="",f=1;this.setData("Hm_lvt_"+c.id,d,c.age);this.setData("Hm_lpvt_"+c.id,C);d=C==this.getData("Hm_lpvt_"+c.id)?"1":"0";if(c.nv==0&&this.d(window.location.href)&&
 | 
			
		||||
(document.referrer==""||this.d(document.referrer)))a=0,b=4;this.a.nv=a;this.a.st=b;this.a.cc=d;this.a.lt=e;this.a.lv=f},w:function(){for(var a=[],b=0,d=E.length;b<d;b++){var e=E[b],f=this.a[e];typeof f!="undefined"&&f!==""&&a.push(e+"="+encodeURIComponent(f))}return a.join("&")},L:function(){this.K();this.a.si=c.id;this.a.su=document.referrer;this.a.ds=u;this.a.cl=v+"-bit";this.a.ln=t;this.a.ja=s?1:0;this.a.ck=r?1:0;this.a.lo=typeof _bdhm_top=="number"?1:0;var a=this.a,b="";if(navigator.plugins&&
 | 
			
		||||
navigator.mimeTypes.length){var d=navigator.plugins["Shockwave Flash"];d&&d.description&&(b=d.description.replace(/^.*\s+(\S+)\s+\S+$/,"$1"))}else if(window.ActiveXObject)try{if(d=new ActiveXObject("ShockwaveFlash.ShockwaveFlash"))(b=d.GetVariable("$version"))&&(b=b.replace(/^.*\s+(\d+),(\d+).*$/,"$1.$2"))}catch(e){}a.fl=b;this.a.sb=this.D();this.a.v="1.0.34";this.a.cv=decodeURIComponent(this.getData("Hm_cv_"+c.id)||"");this.a.api=0;a=window.location.href;this.a.cm=o(a,"hmmd")||"";this.a.cp=o(a,"hmpl")||
 | 
			
		||||
"";this.a.cw=o(a,"hmkw")||"";this.a.ci=o(a,"hmci")||"";this.a.cf=o(a,"hmsr")||""},G:function(){var a=this;try{a.L();a.a.nv==0?a.J():a.l(".*");a.z();a.B();a.n&&a.n();a.m&&a.m();a.h=new G;x(window,"beforeunload",a.I());if(a.C()){var b=window._hmt;if(b&&b.length)for(var d=0;d<b.length;d++)a.j[d]=b[d];a.j.push=function(){a.t.apply(a,arguments)};window._hmt=a.j}if(typeof window._bdhm_autoPageview==="undefined"||window._bdhm_autoPageview===g)a.a.et=0,a.a.ep="",a.c()}catch(e){b=[],b.push("si="+c.id),b.push("n="+
 | 
			
		||||
encodeURIComponent(e.name)),b.push("m="+encodeURIComponent(e.message)),b.push("r="+encodeURIComponent(document.referrer)),w(D+"//hm.baidu.com/hm.gif?"+b.join("&"))}},I:function(){var a=this;return function(){a.a.et=3;a.a.ep=(new Date).getTime()-a.h.r+","+((new Date).getTime()-a.h.g+a.h.s);a.c()}},c:function(){var a=this;a.a.rnd=Math.round(Math.random()*2147483647);a.a.api=a.a.api||a.f?a.a.api+"_"+a.f:"";var b=D+"//hm.baidu.com/hm.gif?"+a.w();a.a.api=0;a.f=0;a.A(b);w(b,function(b){a.l(b)})},z:function(){if(c.icon!=
 | 
			
		||||
""){var a,b=c.icon.split("|"),d="http://tongji.baidu.com/hm-web/welcome/ico?s="+c.id;a=(D=="http:"?"http://eiv":"https://bs")+".baidu.com"+b[0]+"."+b[1];switch(b[1]){case "swf":var e=b[2],b=b[3],d="s="+d,f="HolmesIcon"+C;a='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" id="'+f+'" width="'+e+'" height="'+b+'"><param name="movie" value="'+a+'" /><param name="flashvars" value="'+d+'" /><param name="allowscriptaccess" value="always" /><embed type="application/x-shockwave-flash" name="'+
 | 
			
		||||
f+'" width="'+e+'" height="'+b+'" src="'+a+'" flashvars="'+d+'" allowscriptaccess="always" /></object>';break;case "gif":a='<a href="'+d+'" target="_blank"><img border="0" src="'+a+'" width="'+b[2]+'" height="'+b[3]+'"></a>';break;default:a='<a href="'+d+'" target="_blank">'+b[0]+"</a>"}document.write(a)}},B:function(){var a=window.location.hash.substring(1),b=RegExp(c.id),d=document.referrer.indexOf("baidu.com")>-1?g:i;a&&b.test(a)&&d&&(b=document.createElement("script"),b.setAttribute("type","text/javascript"),
 | 
			
		||||
b.setAttribute("charset","utf-8"),b.setAttribute("src",D+"//"+c.js+o(a,"jn")+"."+o(a,"sx")+"?"+this.a.rnd),a=document.getElementsByTagName("script")[0],a.parentNode.insertBefore(b,a))},t:function(a){if(function(a){if(Object.prototype.toString.call(a)!=="[object Array]")return i;for(var b=a.length-1;b>=0;b--){var d=a[b];if(!("[object Number]"==Object.prototype.toString.call(d)&&isFinite(d))&&"[object String]"!=Object.prototype.toString.call(d)&&d!==g&&d!==i)return i}return g}(a)&&!(typeof window._bdhm_account!==
 | 
			
		||||
"undefined"&&window._bdhm_account!==c.id)){var b=function(a){return a.replace?a.replace(/'/g,"'0").replace(/\*/g,"'1").replace(/!/g,"'2"):a};switch(a[0]){case "_trackPageview":if(a.length>1&&a[1].charAt&&a[1].charAt(0)=="/"){this.a.api|=4;this.a.et=0;this.a.ep="";var b=this.a.u,d=this.a.su;this.a.u=D+"//"+window.location.host+a[1];this.a.su=window.location.href;this.c();this.a.u=b;this.a.su=d}break;case "_trackEvent":if(a.length>2)this.a.api|=8,this.a.et="4",this.a.ep=b(a[1])+"*"+b(a[2])+(a[3]?"*"+
 | 
			
		||||
b(a[3]):"")+(a[4]?"*"+b(a[4]):""),this.c();break;case "_setCustomVar":if(a.length<4)break;var d=a[1],e=a[4]||3;if(d>0&&d<6&&e>0&&e<4){this.f++;for(var f=(this.a.cv||"*").split("!"),j=f.length;j<d-1;j++)f.push("*");f[d-1]=e+"*"+b(a[2])+"*"+b(a[3]);this.a.cv=f.join("!");a=this.a.cv.replace(/[^1](\*[^!]*){2}/g,"*").replace(/((^|!)\*)+$/g,"");a!==""?this.setData("Hm_cv_"+c.id,encodeURIComponent(a),c.age):this.H("Hm_cv_"+c.id)}}}},C:function(){var a=g,b=window._hmt;if(b&&b.length){for(var d=0;d<b.length;d++){var e=
 | 
			
		||||
b[d];switch(e[0]){case "_setAccount":if(e.length>1&&/^[0-9a-z]{32}$/.test(e[1]))this.a.api|=1,window._bdhm_account=e[1],e[1]!==c.id&&(a=i);break;case "_setAutoPageview":if(e.length>1&&(e=e[1],i===e||g===e))this.a.api|=2,window._bdhm_autoPageview=e}}if(a)for(d=0;d<b.length;d++)this.t(b[d])}return a},A:function(a){var b=n("Hm_unsent_"+c.id)||"",d=this.a.u?"":"&u="+encodeURIComponent(window.location.href),b=encodeURIComponent(a.replace(/^https?:\/\//,"")+d)+(b?","+b:"");m("Hm_unsent_"+c.id,b)},l:function(a){var b=
 | 
			
		||||
n("Hm_unsent_"+c.id)||"";b&&((b=b.replace(RegExp(encodeURIComponent(a.replace(/^https?:\/\//,"")).replace(/([\*\(\)])/g,"\\$1")+"(%26u%3D[^,]*)?,?","g"),"").replace(/,$/,""))?m("Hm_unsent_"+c.id,b):window.sessionStorage&&window.sessionStorage.removeItem("Hm_unsent_"+c.id))},J:function(){var a=this,b=n("Hm_unsent_"+c.id);if(b)for(var b=b.split(","),d=0,e=b.length;d<e;d++)w(D+"//"+decodeURIComponent(b[d]).replace(/^https?:\/\//,""),function(b){a.l(b)})}};
 | 
			
		||||
F.prototype.n=function(){x(document,"click",H(this));for(var a=c.etrk.length,b=0;b<a;b++){var d=c.etrk[b],e=document.getElementById(d.id);e&&x(e,d.eventType,I(this))}};function I(a){return function(b){(b.target||b.srcElement).setAttribute("HM_fix",b.clientX+":"+b.clientY);a.a.et=1;a.a.ep="{id:"+this.id+",eventType:"+b.type+"}";a.c()}}
 | 
			
		||||
function H(a){return function(b){var d=b.target||b.srcElement,e=d.getAttribute("HM_fix"),f=b.clientX+":"+b.clientY;if(e&&e==f)d.removeAttribute("HM_fix");else if(e=c.etrk.length,e>0){for(f={};d&&d!=document.body;)d.id&&(f[d.id]=""),d=d.parentNode;for(d=0;d<e;d++){var j=c.etrk[d];if(f.hasOwnProperty(j.id))a.a.et=1,a.a.ep="{id:"+j.id+",eventType:"+b.type+"}",a.c()}}}}
 | 
			
		||||
F.prototype.m=function(){var a=this;c.ctrk&&(x(document,"mouseup",J(this)),x(window,"beforeunload",function(){K(a)}),setInterval(function(){K(a)},6E5))};
 | 
			
		||||
function J(a){return function(b){var d,e;q?(e=Math.max(document.documentElement.scrollTop,document.body.scrollTop),d=Math.max(document.documentElement.scrollLeft,document.body.scrollLeft),d=b.clientX+d,e=b.clientY+e):(d=b.pageX,e=b.pageY);var f=window.innerWidth||document.documentElement.clientWidth||document.body.offsetWidth;switch(c.align){case 1:d-=f/2;break;case 2:d-=f}d="{x:"+d+",y:"+e+",";b=b.target||b.srcElement;if(b.tagName.toLowerCase()!="a")a:{for(e="A";(b=b.parentNode)&&b.nodeType==1;)if(b.tagName==
 | 
			
		||||
e)break a;b=h}d+=b?"t:a,u:"+encodeURIComponent(b.href)+"}":"t:b}";b=d;if(""!=b)d=(D+"//hm.baidu.com/hm.gif?"+a.w().replace(/ep=[^&]*/,"ep="+encodeURIComponent("["+b+"]"))).length,d+10>1024||(d+encodeURIComponent(a.b.join(",")+(a.b.length?",":"")).length+10>1024&&K(a),a.b.push(b),(a.b.length>=10||/t:a/.test(b))&&K(a))}}function K(a){if(a.b.length!=0)a.a.et=2,a.a.ep="["+a.b.join(",")+"]",a.c(),a.b=[]}
 | 
			
		||||
function G(){this.g=this.r=(new Date).getTime();this.s=0;typeof document.M=="object"?(x(document,"focusin",L(this)),x(document,"focusout",L(this))):(x(window,"focus",L(this)),x(window,"blur",L(this)))}function L(a){return function(b){if(!(b.target&&b.target!=window)){if(b.type=="blur"||b.type=="focusout")a.s+=(new Date).getTime()-a.g;a.g=(new Date).getTime()}}}new F;})();
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								04_嵌入式Linux应用开发基础知识/doc_pic/08.网络编程/僵死进程_files/logo-baike.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								04_嵌入式Linux应用开发基础知识/doc_pic/08.网络编程/僵死进程_files/logo-baike.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 1.8 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								04_嵌入式Linux应用开发基础知识/doc_pic/08.网络编程/僵死进程_files/qiuzhi.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								04_嵌入式Linux应用开发基础知识/doc_pic/08.网络编程/僵死进程_files/qiuzhi.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 1.5 KiB  | 
							
								
								
									
										279
									
								
								04_嵌入式Linux应用开发基础知识/doc_pic/08.网络编程/僵死进程_files/tmpact.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										279
									
								
								04_嵌入式Linux应用开发基础知识/doc_pic/08.网络编程/僵死进程_files/tmpact.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,279 @@
 | 
			
		||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD>ճ<EFBFBD><D5B3><EFBFBD><EEB6AF>ǩ*/
 | 
			
		||||
//<2F><><EFBFBD>ӵ<EFBFBD>[id='header']<5D><><EFBFBD><EFBFBD>
 | 
			
		||||
(function(){
 | 
			
		||||
	var show = 1; //<2F>Ƿ<EFBFBD>չʾ<D5B9><CABE>0<EFBFBD>Dz<EFBFBD>չʾ<D5B9><CABE>1<EFBFBD><31>չʾ<D5B9><CABE>2ֻ<32><D6BB><EFBFBD><EFBFBD>ҳչʾ<D5B9><CABE>3ֻ<33>ڴ<EFBFBD><DAB4><EFBFBD>ҳչʾ
 | 
			
		||||
	//<2F><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><32>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3>2<EFBFBD><32><EFBFBD>Ǵ<EFBFBD><C7B4><EFBFBD>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>show=1<><31><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD>1<EFBFBD><31>չʾ
 | 
			
		||||
	var linkSrc1 = 'http://baike.baidu.com/cms/rc/400x100.png';
 | 
			
		||||
	//var linkSrc1 = 'http://baike.baidu.com/cms/rc/400x100.png';//ͼƬ<CDBC>ĵ<EFBFBD>ַ
 | 
			
		||||
	var linkHref1 = 'http://baike.baidu.com/cms/s/ips/index.html';//ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
			
		||||
	var linkText1 = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Բ';//<2F><><EFBFBD>껬<EFBFBD><EABBAC><EFBFBD><EFBFBD>Ϣ
 | 
			
		||||
	var isLink1 = false; //<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD>true<75>Ļ<EFBFBD>linkHref1<66><31>linkText1<74><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
			
		||||
	var isFlash1 = false;
 | 
			
		||||
	var flashSrc1 = 'http://img.baidu.com/img/baike/usercenter/celebration/2012/sleep.swf';
 | 
			
		||||
	var beginDate = '03/21/2012';
 | 
			
		||||
	
 | 
			
		||||
	var linkSrc2 = 'http://img.baidu.com/img/baike/wanshengjie.gif';//ͼƬ<CDBC>ĵ<EFBFBD>ַ 
 | 
			
		||||
	var linkHref2 = 'http://baike.baidu.com/cms/s/halloween/index.html?ref=cty';//ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
			
		||||
	var linkText2 = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˽<EFBFBD><CBBD><EFBFBD><EFBFBD><EFBFBD>ʥ<EFBFBD><CAA5>';//<2F><><EFBFBD>껬<EFBFBD><EABBAC><EFBFBD><EFBFBD>Ϣ
 | 
			
		||||
	var isLink2 = true;
 | 
			
		||||
	var isFlash2 = false;
 | 
			
		||||
	addSheet('#userbar{z-index:100 !important;} #encourage_tip_wrapper{z-index:19}');
 | 
			
		||||
 | 
			
		||||
	var wrap = baidu.dom.query('ul.nav.f14')[0];
 | 
			
		||||
	var viewFlag = (document.body.id == 'view');
 | 
			
		||||
	//Ĭ<>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
			
		||||
	function defaultSet(src, href, text){
 | 
			
		||||
		//<2F><><EFBFBD>ӵĻ<D3B5><C4BB><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1>238*60
 | 
			
		||||
		var link = document.createElement('a');
 | 
			
		||||
		link.href = href;
 | 
			
		||||
		link.target = '_blank';
 | 
			
		||||
		link.hideFocus = true;
 | 
			
		||||
		link.innerHTML = text;
 | 
			
		||||
		link.onclick = function(){
 | 
			
		||||
			nslog(location.href, 3626);
 | 
			
		||||
		}
 | 
			
		||||
		link.title = text;
 | 
			
		||||
		fixZIndex();
 | 
			
		||||
		//link.style.cssText = 'position:absolute;top:-60px;right:0;width:238px;height:60px;outline:0;font-size:0;text-indent:-999em;background:url('+ src +') no-repeat 0 0;';
 | 
			
		||||
		link.style.cssText = 'position:absolute;top:-100px;right:-46px;width:400px;height:100px;outline:0;font-size:0;text-indent:-999em;background:url('+ src +') no-repeat 0 0';
 | 
			
		||||
		wrap.appendChild(link);
 | 
			
		||||
		if (baidu.browser.ie == 6) {
 | 
			
		||||
			link.style.position = 'relative';
 | 
			
		||||
			link.style.position = 'absolute';
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	//flashҳ<68><D2B3>
 | 
			
		||||
	function flashSet(src){
 | 
			
		||||
		var link = document.createElement('div');
 | 
			
		||||
		link.id = 'bk-push';
 | 
			
		||||
		var title = document.title;
 | 
			
		||||
		baidu.swf.create({
 | 
			
		||||
			id:'flash',
 | 
			
		||||
			url:src,
 | 
			
		||||
			width:240,
 | 
			
		||||
			height:60,
 | 
			
		||||
			wmode: 'transparent',
 | 
			
		||||
			allowscriptaccess: 'always'
 | 
			
		||||
		}, link);
 | 
			
		||||
		fixZIndex();
 | 
			
		||||
		link.style.cssText = 'position:absolute;top:-60px;right:0;width:240px;height:60px;';
 | 
			
		||||
		setTimeout(function(){wrap.appendChild(link);},300);
 | 
			
		||||
		if(baidu.browser.ie){
 | 
			
		||||
			try{
 | 
			
		||||
				var timer = null;
 | 
			
		||||
				var count = 0 //<2F><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>ľ<EFBFBD>ı䣬<C4B1><E4A3AC>ֹͣ
 | 
			
		||||
				var totalCount = 600;
 | 
			
		||||
				timer = setInterval(function(){
 | 
			
		||||
					if(count++ > totalCount){
 | 
			
		||||
						clearInterval(timer);
 | 
			
		||||
						return;
 | 
			
		||||
					}
 | 
			
		||||
					var curTitle = document.title;
 | 
			
		||||
					if(curTitle.indexOf('#') != -1 && curTitle != title){
 | 
			
		||||
						clearInterval(timer);
 | 
			
		||||
						document.title = title;
 | 
			
		||||
					}
 | 
			
		||||
				}, 100);	
 | 
			
		||||
			} catch (exp){}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	//<2F><><EFBFBD>ص<EFBFBD><D8B5><EFBFBD>ҳ#_$<24><>ֻ<EFBFBD><D6BB>Ҫһ<D2AA><D2BB>ͼƬ<CDBC><C6AC>ַ<EFBFBD><D6B7>
 | 
			
		||||
	function singleSet(src){
 | 
			
		||||
		//<2F><>ͨ<EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1>400*100<30><30>ע<EFBFBD>Ⱒ<EFBFBD><E2B0A2>6/7<>µ<EFBFBD>margin<69><6E><EFBFBD>۵<EFBFBD><DBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ը߶<D4B8>Ҫ<EFBFBD><D2AA>һЩ
 | 
			
		||||
		var ca = document.createElement('div');
 | 
			
		||||
		fixZIndex();
 | 
			
		||||
		ca.style.cssText = 'position:absolute;top:-100px;right:-46px;width:400px;height:100px;outline:0;font-size:0;text-indent:-999em;background:url('+ src +') no-repeat 0 0;';
 | 
			
		||||
		wrap.appendChild(ca);
 | 
			
		||||
		if (baidu.browser.ie == 6) {
 | 
			
		||||
			ca.style.position = 'relative';
 | 
			
		||||
			ca.style.position = 'absolute';
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function fixZIndex(){
 | 
			
		||||
		//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>head<61><64>z-index<65><78>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD>#userbar<61><72>#header<65><72><EFBFBD><EFBFBD><EFBFBD>棬Ŀǰ#userbar<61><72>z-index<65><78>10
 | 
			
		||||
		if(!viewFlag){//<2F><>ҳ<EFBFBD><D2B3>viewҳ<77><D2B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֲ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳֻ<D2B3><D6BB><EFBFBD>ð<EFBFBD>ť<EFBFBD><C5A5>parentNode<64><65><EFBFBD><EFBFBD>
 | 
			
		||||
			var foreground = baidu.dom.query('input[value=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>]')[0];
 | 
			
		||||
			foreground.style.zIndex = 9;
 | 
			
		||||
			foreground.style.position = 'relative';
 | 
			
		||||
			var helpBtn = baidu.dom.next(foreground);
 | 
			
		||||
			helpBtn.style.zIndex = 9;
 | 
			
		||||
			helpBtn.style.position = 'relative';
 | 
			
		||||
			var setBtn = baidu.dom.next(helpBtn);
 | 
			
		||||
			setBtn.style.zIndex = 9;
 | 
			
		||||
			setBtn.style.position = 'relative';
 | 
			
		||||
		}
 | 
			
		||||
		else{
 | 
			
		||||
			var foreground = baidu.dom.query('input[value=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>],input[value=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>]');
 | 
			
		||||
			foreground[0].style.zIndex = 9;
 | 
			
		||||
			foreground[0].style.position = 'relative';
 | 
			
		||||
			foreground[1].style.zIndex = 9;
 | 
			
		||||
			foreground[1].style.position = 'relative';
 | 
			
		||||
			var help = baidu.g('help');
 | 
			
		||||
			help.style.zIndex = 9;
 | 
			
		||||
			help.style.position = 'relative';
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	 function addSheet(css){
 | 
			
		||||
        if(!-[1,]){
 | 
			
		||||
            css = css.replace(/opacity:\s*(\d?\.\d+)/g,function($,$1){
 | 
			
		||||
                $1 = parseFloat($1) * 100;
 | 
			
		||||
                if($1 < 0 || $1 > 100)
 | 
			
		||||
                    return "";
 | 
			
		||||
                return "filter:alpha(opacity="+ $1 +");"
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        css += "\n";//<2F><><EFBFBD><EFBFBD>ĩβ<C4A9>Ļ<EFBFBD><C4BB>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>firebug<75>µIJ鿴<C4B2><E9BFB4>
 | 
			
		||||
        var doc = document, head = doc.getElementsByTagName("head")[0],
 | 
			
		||||
        styles = head.getElementsByTagName("style"),style,media;
 | 
			
		||||
        if(styles.length == 0){//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>styleԪ<65><D4AA><EFBFBD><EFBFBD>
 | 
			
		||||
            if(doc.createStyleSheet){    //ie
 | 
			
		||||
                doc.createStyleSheet();
 | 
			
		||||
            }else{
 | 
			
		||||
                style = doc.createElement('style');//w3c
 | 
			
		||||
                style.setAttribute("type", "text/css");
 | 
			
		||||
                head.insertBefore(style,null)
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        style = styles[0];
 | 
			
		||||
        media = style.getAttribute("media");
 | 
			
		||||
        if(media === null && !/screen/i.test(media) ){
 | 
			
		||||
            style.setAttribute("media","all");
 | 
			
		||||
        }
 | 
			
		||||
        if(style.styleSheet){    //ie
 | 
			
		||||
            style.styleSheet.cssText += css;//<2F><><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5>ڲ<EFBFBD><DAB2><EFBFBD>ʽ
 | 
			
		||||
        }else{
 | 
			
		||||
            style.appendChild(doc.createTextNode(css))
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
	function generatePage(src, href, text, isLink, isFlash){
 | 
			
		||||
		/*if(isFlash){
 | 
			
		||||
			flashSet(src);
 | 
			
		||||
		}
 | 
			
		||||
		else{
 | 
			
		||||
			isLink ? defaultSet(src, href, text) : singleSet(src);
 | 
			
		||||
		}*/
 | 
			
		||||
		isLink ? defaultSet(src, href, text) : singleSet(src);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	if(wrap){
 | 
			
		||||
		if(1 == show){
 | 
			
		||||
			viewFlag ? generatePage(linkSrc2, linkHref2, linkText2, isLink2, isFlash2) : generatePage(linkSrc1, linkHref1, linkText1, isLink1, isFlash1);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		if(2 == show && !viewFlag){
 | 
			
		||||
			/*if(isFlash1 && new Date - Date.parse(beginDate) > 0){
 | 
			
		||||
				flashSet(flashSrc1);
 | 
			
		||||
				return;
 | 
			
		||||
			}*/
 | 
			
		||||
			generatePage(linkSrc1, linkHref1, linkText1, isLink1, isFlash1);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if(3 == show && viewFlag){
 | 
			
		||||
			generatePage(linkSrc2, linkHref2, linkText2, isLink2, isFlash2);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
})();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 *<2A><><EFBFBD><EFBFBD>ҳ<EFBFBD>Ҳ<EFBFBD>side<64>ƹ<EFBFBD>ͼƬλ
 | 
			
		||||
 *author <20><>tianzixin
 | 
			
		||||
 *Date   : 2012-08-16
 | 
			
		||||
 */
 | 
			
		||||
(function(){
 | 
			
		||||
	//<2F><>һ<EFBFBD><D2BB>ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD>
 | 
			
		||||
	var linkSrc1 = 'http://baike.baidu.com/cms/s/banner/bowuguan400x100.jpg';//ͼƬ<CDBC>ĵ<EFBFBD>ַ
 | 
			
		||||
	var linkHref1 = 'http://baike.baidu.com/museum/museumIndex.html?id=208463';//ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
			
		||||
	var linkText1 = '<27>й<EFBFBD><D0B9><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD>';//<2F><><EFBFBD>껬<EFBFBD><EABBAC><EFBFBD><EFBFBD>Ϣ
 | 
			
		||||
	var width1 = "0px";  //ͼƬ1<C6AC><31><EFBFBD><EFBFBD>,<2C><><EFBFBD>磺"100px;",<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><CFA3>ͼƬ1չʾ<D5B9><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>width1 = "0px"<22><><EFBFBD><EFBFBD><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD><EFBFBD><EFBFBD>Ŷ
 | 
			
		||||
	var height1 = "40px";	//ͼƬ1<C6AC>߶<EFBFBD>
 | 
			
		||||
	
 | 
			
		||||
	//<2F>ڶ<EFBFBD><DAB6><EFBFBD>ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD>
 | 
			
		||||
	var linkSrc2 = 'http://baike.baidu.com/cms/s/banner/bowuguan400x100.jpg';//ͼƬ<CDBC>ĵ<EFBFBD>ַ 
 | 
			
		||||
	var linkHref2 = 'http://baike.baidu.com/museum/museumIndex.html?id=208463';//ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
			
		||||
	var linkText2 = '<27>й<EFBFBD><D0B9><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD>';//<2F><><EFBFBD>껬<EFBFBD><EABBAC><EFBFBD><EFBFBD>Ϣ
 | 
			
		||||
	var width2 = "0px";	//ͼƬ2<C6AC><32><EFBFBD><EFBFBD>,<2C><><EFBFBD>磺"100px;",<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><CFA3>ͼƬ2չʾ<D5B9><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>width2 = "0px"<22><><EFBFBD><EFBFBD><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD><EFBFBD><EFBFBD>Ŷ
 | 
			
		||||
	var height2 = "40px";	//ͼƬ2<C6AC>߶<EFBFBD>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	var beginDate = '03/21/2012';
 | 
			
		||||
	addSheet('#userbar{z-index:100 !important;} #encourage_tip_wrapper{z-index:19}');
 | 
			
		||||
 | 
			
		||||
	var wrap = baidu.dom.g("side");
 | 
			
		||||
	var viewFlag = (document.body.id == 'view');
 | 
			
		||||
	//Ĭ<>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
			
		||||
	function defaultSet(src, href, text, width, height){
 | 
			
		||||
		var link = document.createElement('a');
 | 
			
		||||
		link.href = href;
 | 
			
		||||
		link.target = '_blank';
 | 
			
		||||
		link.hideFocus = true;
 | 
			
		||||
		link.innerHTML = text;
 | 
			
		||||
		link.onclick = function(){
 | 
			
		||||
			nslog(location.href, 3626);
 | 
			
		||||
		}
 | 
			
		||||
		link.title = text;
 | 
			
		||||
		link.style.cssText = 'display:block;width:'+width+';height:'+height+';border: 1px solid #CCC;margin:5px 0 5px 0;outline:0;font-size:0;text-indent:-999em;background:url('+ src +') no-repeat 0 0';
 | 
			
		||||
		
 | 
			
		||||
		wrap.appendChild(link);
 | 
			
		||||
		
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	 function addSheet(css){
 | 
			
		||||
        if(!-[1,]){
 | 
			
		||||
            css = css.replace(/opacity:\s*(\d?\.\d+)/g,function($,$1){
 | 
			
		||||
                $1 = parseFloat($1) * 100;
 | 
			
		||||
                if($1 < 0 || $1 > 100)
 | 
			
		||||
                    return "";
 | 
			
		||||
                return "filter:alpha(opacity="+ $1 +");"
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        css += "\n";//<2F><><EFBFBD><EFBFBD>ĩβ<C4A9>Ļ<EFBFBD><C4BB>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>firebug<75>µIJ鿴<C4B2><E9BFB4>
 | 
			
		||||
        var doc = document, head = doc.getElementsByTagName("head")[0],
 | 
			
		||||
        styles = head.getElementsByTagName("style"),style,media;
 | 
			
		||||
        if(styles.length == 0){//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>styleԪ<65><D4AA><EFBFBD><EFBFBD>
 | 
			
		||||
            if(doc.createStyleSheet){    //ie
 | 
			
		||||
                doc.createStyleSheet();
 | 
			
		||||
            }else{
 | 
			
		||||
                style = doc.createElement('style');//w3c
 | 
			
		||||
                style.setAttribute("type", "text/css");
 | 
			
		||||
                head.insertBefore(style,null)
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        style = styles[0];
 | 
			
		||||
        media = style.getAttribute("media");
 | 
			
		||||
        if(media === null && !/screen/i.test(media) ){
 | 
			
		||||
            style.setAttribute("media","all");
 | 
			
		||||
        }
 | 
			
		||||
        if(style.styleSheet){    //ie
 | 
			
		||||
            style.styleSheet.cssText += css;//<2F><><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5>ڲ<EFBFBD><DAB2><EFBFBD>ʽ
 | 
			
		||||
        }else{
 | 
			
		||||
            style.appendChild(doc.createTextNode(css))
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
	function generatePage(src, href, text, width, height){
 | 
			
		||||
			 defaultSet(src, href, text, width, height);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	if(viewFlag){
 | 
			
		||||
		if(width1 !== "0px"){
 | 
			
		||||
			generatePage(linkSrc1, linkHref1, linkText1, width1, height1);
 | 
			
		||||
		}
 | 
			
		||||
		if(width2 !== "0px"){
 | 
			
		||||
			generatePage(linkSrc2, linkHref2, linkText2, width2, height2);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
})();
 | 
			
		||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								04_嵌入式Linux应用开发基础知识/doc_pic/08.网络编程/网络编程.jpg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								04_嵌入式Linux应用开发基础知识/doc_pic/08.网络编程/网络编程.jpg
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 439 KiB  | 
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								04_嵌入式Linux应用开发基础知识/doc_pic/09.多线程编程/多线程编程.pptx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								04_嵌入式Linux应用开发基础知识/doc_pic/09.多线程编程/多线程编程.pptx
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								04_嵌入式Linux应用开发基础知识/doc_pic/09.多线程编程/多线程编程.tif
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								04_嵌入式Linux应用开发基础知识/doc_pic/09.多线程编程/多线程编程.tif
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										68
									
								
								04_嵌入式Linux应用开发基础知识/source/12_socket/tcp/client.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								04_嵌入式Linux应用开发基础知识/source/12_socket/tcp/client.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,68 @@
 | 
			
		||||
#include <sys/types.h>          /* See NOTES */
 | 
			
		||||
#include <sys/socket.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <sys/socket.h>
 | 
			
		||||
#include <netinet/in.h>
 | 
			
		||||
#include <arpa/inet.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
/* socket
 | 
			
		||||
 * connect
 | 
			
		||||
 * send/recv
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#define SERVER_PORT 8888
 | 
			
		||||
 | 
			
		||||
int main(int argc, char **argv)
 | 
			
		||||
{
 | 
			
		||||
	int iSocketClient;
 | 
			
		||||
	struct sockaddr_in tSocketServerAddr;
 | 
			
		||||
	
 | 
			
		||||
	int iRet;
 | 
			
		||||
	unsigned char ucSendBuf[1000];
 | 
			
		||||
	int iSendLen;
 | 
			
		||||
 | 
			
		||||
	if (argc != 2)
 | 
			
		||||
	{
 | 
			
		||||
		printf("Usage:\n");
 | 
			
		||||
		printf("%s <server_ip>\n", argv[0]);
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	iSocketClient = socket(AF_INET, SOCK_STREAM, 0);
 | 
			
		||||
 | 
			
		||||
	tSocketServerAddr.sin_family      = AF_INET;
 | 
			
		||||
	tSocketServerAddr.sin_port        = htons(SERVER_PORT);  /* host to net, short */
 | 
			
		||||
 	//tSocketServerAddr.sin_addr.s_addr = INADDR_ANY;
 | 
			
		||||
 	if (0 == inet_aton(argv[1], &tSocketServerAddr.sin_addr))
 | 
			
		||||
 	{
 | 
			
		||||
		printf("invalid server_ip\n");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	memset(tSocketServerAddr.sin_zero, 0, 8);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	iRet = connect(iSocketClient, (const struct sockaddr *)&tSocketServerAddr, sizeof(struct sockaddr));	
 | 
			
		||||
	if (-1 == iRet)
 | 
			
		||||
	{
 | 
			
		||||
		printf("connect error!\n");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	while (1)
 | 
			
		||||
	{
 | 
			
		||||
		if (fgets(ucSendBuf, 999, stdin))
 | 
			
		||||
		{
 | 
			
		||||
			iSendLen = send(iSocketClient, ucSendBuf, strlen(ucSendBuf), 0);
 | 
			
		||||
			if (iSendLen <= 0)
 | 
			
		||||
			{
 | 
			
		||||
				close(iSocketClient);
 | 
			
		||||
				return -1;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										98
									
								
								04_嵌入式Linux应用开发基础知识/source/12_socket/tcp/server.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										98
									
								
								04_嵌入式Linux应用开发基础知识/source/12_socket/tcp/server.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,98 @@
 | 
			
		||||
#include <sys/types.h>          /* See NOTES */
 | 
			
		||||
#include <sys/socket.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <sys/socket.h>
 | 
			
		||||
#include <netinet/in.h>
 | 
			
		||||
#include <arpa/inet.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <signal.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* socket
 | 
			
		||||
 * bind
 | 
			
		||||
 * listen
 | 
			
		||||
 * accept
 | 
			
		||||
 * send/recv
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#define SERVER_PORT 8888
 | 
			
		||||
#define BACKLOG     10
 | 
			
		||||
 | 
			
		||||
int main(int argc, char **argv)
 | 
			
		||||
{
 | 
			
		||||
	int iSocketServer;
 | 
			
		||||
	int iSocketClient;
 | 
			
		||||
	struct sockaddr_in tSocketServerAddr;
 | 
			
		||||
	struct sockaddr_in tSocketClientAddr;
 | 
			
		||||
	int iRet;
 | 
			
		||||
	int iAddrLen;
 | 
			
		||||
 | 
			
		||||
	int iRecvLen;
 | 
			
		||||
	unsigned char ucRecvBuf[1000];
 | 
			
		||||
 | 
			
		||||
	int iClientNum = -1;
 | 
			
		||||
 | 
			
		||||
	signal(SIGCHLD,SIG_IGN);
 | 
			
		||||
	
 | 
			
		||||
	iSocketServer = socket(AF_INET, SOCK_STREAM, 0);
 | 
			
		||||
	if (-1 == iSocketServer)
 | 
			
		||||
	{
 | 
			
		||||
		printf("socket error!\n");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	tSocketServerAddr.sin_family      = AF_INET;
 | 
			
		||||
	tSocketServerAddr.sin_port        = htons(SERVER_PORT);  /* host to net, short */
 | 
			
		||||
 	tSocketServerAddr.sin_addr.s_addr = INADDR_ANY;
 | 
			
		||||
	memset(tSocketServerAddr.sin_zero, 0, 8);
 | 
			
		||||
	
 | 
			
		||||
	iRet = bind(iSocketServer, (const struct sockaddr *)&tSocketServerAddr, sizeof(struct sockaddr));
 | 
			
		||||
	if (-1 == iRet)
 | 
			
		||||
	{
 | 
			
		||||
		printf("bind error!\n");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	iRet = listen(iSocketServer, BACKLOG);
 | 
			
		||||
	if (-1 == iRet)
 | 
			
		||||
	{
 | 
			
		||||
		printf("listen error!\n");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	while (1)
 | 
			
		||||
	{
 | 
			
		||||
		iAddrLen = sizeof(struct sockaddr);
 | 
			
		||||
		iSocketClient = accept(iSocketServer, (struct sockaddr *)&tSocketClientAddr, &iAddrLen);
 | 
			
		||||
		if (-1 != iSocketClient)
 | 
			
		||||
		{
 | 
			
		||||
			iClientNum++;
 | 
			
		||||
			printf("Get connect from client %d : %s\n",  iClientNum, inet_ntoa(tSocketClientAddr.sin_addr));
 | 
			
		||||
			if (!fork())
 | 
			
		||||
			{
 | 
			
		||||
				/* <20>ӽ<EFBFBD><D3BD>̵<EFBFBD>Դ<EFBFBD><D4B4> */
 | 
			
		||||
				while (1)
 | 
			
		||||
				{
 | 
			
		||||
					/* <20><><EFBFBD>տͻ<D5BF><CDBB>˷<EFBFBD><CBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD> */
 | 
			
		||||
					iRecvLen = recv(iSocketClient, ucRecvBuf, 999, 0);
 | 
			
		||||
					if (iRecvLen <= 0)
 | 
			
		||||
					{
 | 
			
		||||
						close(iSocketClient);
 | 
			
		||||
						return -1;
 | 
			
		||||
					}
 | 
			
		||||
					else
 | 
			
		||||
					{
 | 
			
		||||
						ucRecvBuf[iRecvLen] = '\0';
 | 
			
		||||
						printf("Get Msg From Client %d: %s\n", iClientNum, ucRecvBuf);
 | 
			
		||||
					}
 | 
			
		||||
				}				
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	close(iSocketServer);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										68
									
								
								04_嵌入式Linux应用开发基础知识/source/12_socket/udp/client.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								04_嵌入式Linux应用开发基础知识/source/12_socket/udp/client.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,68 @@
 | 
			
		||||
#include <sys/types.h>          /* See NOTES */
 | 
			
		||||
#include <sys/socket.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <sys/socket.h>
 | 
			
		||||
#include <netinet/in.h>
 | 
			
		||||
#include <arpa/inet.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
/* socket
 | 
			
		||||
 * connect
 | 
			
		||||
 * send/recv
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#define SERVER_PORT 8888
 | 
			
		||||
 | 
			
		||||
int main(int argc, char **argv)
 | 
			
		||||
{
 | 
			
		||||
	int iSocketClient;
 | 
			
		||||
	struct sockaddr_in tSocketServerAddr;
 | 
			
		||||
	
 | 
			
		||||
	int iRet;
 | 
			
		||||
	unsigned char ucSendBuf[1000];
 | 
			
		||||
	int iSendLen;
 | 
			
		||||
 | 
			
		||||
	if (argc != 2)
 | 
			
		||||
	{
 | 
			
		||||
		printf("Usage:\n");
 | 
			
		||||
		printf("%s <server_ip>\n", argv[0]);
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	iSocketClient = socket(AF_INET, SOCK_DGRAM, 0);
 | 
			
		||||
 | 
			
		||||
	tSocketServerAddr.sin_family      = AF_INET;
 | 
			
		||||
	tSocketServerAddr.sin_port        = htons(SERVER_PORT);  /* host to net, short */
 | 
			
		||||
 	//tSocketServerAddr.sin_addr.s_addr = INADDR_ANY;
 | 
			
		||||
 	if (0 == inet_aton(argv[1], &tSocketServerAddr.sin_addr))
 | 
			
		||||
 	{
 | 
			
		||||
		printf("invalid server_ip\n");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	memset(tSocketServerAddr.sin_zero, 0, 8);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	iRet = connect(iSocketClient, (const struct sockaddr *)&tSocketServerAddr, sizeof(struct sockaddr));	
 | 
			
		||||
	if (-1 == iRet)
 | 
			
		||||
	{
 | 
			
		||||
		printf("connect error!\n");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	while (1)
 | 
			
		||||
	{
 | 
			
		||||
		if (fgets(ucSendBuf, 999, stdin))
 | 
			
		||||
		{
 | 
			
		||||
			iSendLen = send(iSocketClient, ucSendBuf, strlen(ucSendBuf), 0);
 | 
			
		||||
			if (iSendLen <= 0)
 | 
			
		||||
			{
 | 
			
		||||
				close(iSocketClient);
 | 
			
		||||
				return -1;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										68
									
								
								04_嵌入式Linux应用开发基础知识/source/12_socket/udp/server.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								04_嵌入式Linux应用开发基础知识/source/12_socket/udp/server.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,68 @@
 | 
			
		||||
#include <sys/types.h>          /* See NOTES */
 | 
			
		||||
#include <sys/socket.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <sys/socket.h>
 | 
			
		||||
#include <netinet/in.h>
 | 
			
		||||
#include <arpa/inet.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <signal.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* socket
 | 
			
		||||
 * bind
 | 
			
		||||
 * sendto/recvfrom
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#define SERVER_PORT 8888
 | 
			
		||||
 | 
			
		||||
int main(int argc, char **argv)
 | 
			
		||||
{
 | 
			
		||||
	int iSocketServer;
 | 
			
		||||
	int iSocketClient;
 | 
			
		||||
	struct sockaddr_in tSocketServerAddr;
 | 
			
		||||
	struct sockaddr_in tSocketClientAddr;
 | 
			
		||||
	int iRet;
 | 
			
		||||
	int iAddrLen;
 | 
			
		||||
 | 
			
		||||
	int iRecvLen;
 | 
			
		||||
	unsigned char ucRecvBuf[1000];
 | 
			
		||||
 | 
			
		||||
	int iClientNum = -1;
 | 
			
		||||
	
 | 
			
		||||
	iSocketServer = socket(AF_INET, SOCK_DGRAM, 0);
 | 
			
		||||
	if (-1 == iSocketServer)
 | 
			
		||||
	{
 | 
			
		||||
		printf("socket error!\n");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	tSocketServerAddr.sin_family      = AF_INET;
 | 
			
		||||
	tSocketServerAddr.sin_port        = htons(SERVER_PORT);  /* host to net, short */
 | 
			
		||||
 	tSocketServerAddr.sin_addr.s_addr = INADDR_ANY;
 | 
			
		||||
	memset(tSocketServerAddr.sin_zero, 0, 8);
 | 
			
		||||
	
 | 
			
		||||
	iRet = bind(iSocketServer, (const struct sockaddr *)&tSocketServerAddr, sizeof(struct sockaddr));
 | 
			
		||||
	if (-1 == iRet)
 | 
			
		||||
	{
 | 
			
		||||
		printf("bind error!\n");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	while (1)
 | 
			
		||||
	{
 | 
			
		||||
		iAddrLen = sizeof(struct sockaddr);
 | 
			
		||||
		iRecvLen = recvfrom(iSocketServer, ucRecvBuf, 999, 0, (struct sockaddr *)&tSocketClientAddr, &iAddrLen);
 | 
			
		||||
		if (iRecvLen > 0)
 | 
			
		||||
		{
 | 
			
		||||
			ucRecvBuf[iRecvLen] = '\0';
 | 
			
		||||
			printf("Get Msg From %s : %s\n", inet_ntoa(tSocketClientAddr.sin_addr), ucRecvBuf);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	close(iSocketServer);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										77
									
								
								04_嵌入式Linux应用开发基础知识/source/12_socket/udp2/client.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										77
									
								
								04_嵌入式Linux应用开发基础知识/source/12_socket/udp2/client.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,77 @@
 | 
			
		||||
#include <sys/types.h>          /* See NOTES */
 | 
			
		||||
#include <sys/socket.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <sys/socket.h>
 | 
			
		||||
#include <netinet/in.h>
 | 
			
		||||
#include <arpa/inet.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
/* socket
 | 
			
		||||
 * connect
 | 
			
		||||
 * send/recv
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#define SERVER_PORT 8888
 | 
			
		||||
 | 
			
		||||
int main(int argc, char **argv)
 | 
			
		||||
{
 | 
			
		||||
	int iSocketClient;
 | 
			
		||||
	struct sockaddr_in tSocketServerAddr;
 | 
			
		||||
	
 | 
			
		||||
	int iRet;
 | 
			
		||||
	unsigned char ucSendBuf[1000];
 | 
			
		||||
	int iSendLen;
 | 
			
		||||
	int iAddrLen;
 | 
			
		||||
 | 
			
		||||
	if (argc != 2)
 | 
			
		||||
	{
 | 
			
		||||
		printf("Usage:\n");
 | 
			
		||||
		printf("%s <server_ip>\n", argv[0]);
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	iSocketClient = socket(AF_INET, SOCK_DGRAM, 0);
 | 
			
		||||
 | 
			
		||||
	tSocketServerAddr.sin_family      = AF_INET;
 | 
			
		||||
	tSocketServerAddr.sin_port        = htons(SERVER_PORT);  /* host to net, short */
 | 
			
		||||
 	//tSocketServerAddr.sin_addr.s_addr = INADDR_ANY;
 | 
			
		||||
 	if (0 == inet_aton(argv[1], &tSocketServerAddr.sin_addr))
 | 
			
		||||
 	{
 | 
			
		||||
		printf("invalid server_ip\n");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	memset(tSocketServerAddr.sin_zero, 0, 8);
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
	iRet = connect(iSocketClient, (const struct sockaddr *)&tSocketServerAddr, sizeof(struct sockaddr));	
 | 
			
		||||
	if (-1 == iRet)
 | 
			
		||||
	{
 | 
			
		||||
		printf("connect error!\n");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	while (1)
 | 
			
		||||
	{
 | 
			
		||||
		if (fgets(ucSendBuf, 999, stdin))
 | 
			
		||||
		{
 | 
			
		||||
#if 0
 | 
			
		||||
			iSendLen = send(iSocketClient, ucSendBuf, strlen(ucSendBuf), 0);
 | 
			
		||||
#else
 | 
			
		||||
			iAddrLen = sizeof(struct sockaddr);
 | 
			
		||||
			iSendLen = sendto(iSocketClient, ucSendBuf, strlen(ucSendBuf), 0,
 | 
			
		||||
			                      (const struct sockaddr *)&tSocketServerAddr, iAddrLen);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
			if (iSendLen <= 0)
 | 
			
		||||
			{
 | 
			
		||||
				close(iSocketClient);
 | 
			
		||||
				return -1;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										68
									
								
								04_嵌入式Linux应用开发基础知识/source/12_socket/udp2/server.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								04_嵌入式Linux应用开发基础知识/source/12_socket/udp2/server.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,68 @@
 | 
			
		||||
#include <sys/types.h>          /* See NOTES */
 | 
			
		||||
#include <sys/socket.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <sys/socket.h>
 | 
			
		||||
#include <netinet/in.h>
 | 
			
		||||
#include <arpa/inet.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <signal.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* socket
 | 
			
		||||
 * bind
 | 
			
		||||
 * sendto/recvfrom
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#define SERVER_PORT 8888
 | 
			
		||||
 | 
			
		||||
int main(int argc, char **argv)
 | 
			
		||||
{
 | 
			
		||||
	int iSocketServer;
 | 
			
		||||
	int iSocketClient;
 | 
			
		||||
	struct sockaddr_in tSocketServerAddr;
 | 
			
		||||
	struct sockaddr_in tSocketClientAddr;
 | 
			
		||||
	int iRet;
 | 
			
		||||
	int iAddrLen;
 | 
			
		||||
 | 
			
		||||
	int iRecvLen;
 | 
			
		||||
	unsigned char ucRecvBuf[1000];
 | 
			
		||||
 | 
			
		||||
	int iClientNum = -1;
 | 
			
		||||
	
 | 
			
		||||
	iSocketServer = socket(AF_INET, SOCK_DGRAM, 0);
 | 
			
		||||
	if (-1 == iSocketServer)
 | 
			
		||||
	{
 | 
			
		||||
		printf("socket error!\n");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	tSocketServerAddr.sin_family      = AF_INET;
 | 
			
		||||
	tSocketServerAddr.sin_port        = htons(SERVER_PORT);  /* host to net, short */
 | 
			
		||||
 	tSocketServerAddr.sin_addr.s_addr = INADDR_ANY;
 | 
			
		||||
	memset(tSocketServerAddr.sin_zero, 0, 8);
 | 
			
		||||
	
 | 
			
		||||
	iRet = bind(iSocketServer, (const struct sockaddr *)&tSocketServerAddr, sizeof(struct sockaddr));
 | 
			
		||||
	if (-1 == iRet)
 | 
			
		||||
	{
 | 
			
		||||
		printf("bind error!\n");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	while (1)
 | 
			
		||||
	{
 | 
			
		||||
		iAddrLen = sizeof(struct sockaddr);
 | 
			
		||||
		iRecvLen = recvfrom(iSocketServer, ucRecvBuf, 999, 0, (struct sockaddr *)&tSocketClientAddr, &iAddrLen);
 | 
			
		||||
		if (iRecvLen > 0)
 | 
			
		||||
		{
 | 
			
		||||
			ucRecvBuf[iRecvLen] = '\0';
 | 
			
		||||
			printf("Get Msg From %s : %s\n", inet_ntoa(tSocketClientAddr.sin_addr), ucRecvBuf);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	close(iSocketServer);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -0,0 +1,9 @@
 | 
			
		||||
#include <pthread.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
	pthread_t tid = pthread_self();
 | 
			
		||||
	printf("tid = %lu\n",(unsigned long)tid);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,58 @@
 | 
			
		||||
#define _GNU_SOURCE 
 | 
			
		||||
#include <pthread.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
 | 
			
		||||
pthread_mutex_t mutex;
 | 
			
		||||
 | 
			
		||||
int Num = 0;
 | 
			
		||||
 | 
			
		||||
void *fun1(void *arg)
 | 
			
		||||
{
 | 
			
		||||
	pthread_mutex_lock(&mutex);
 | 
			
		||||
	while(Num < 3){
 | 
			
		||||
		Num++;
 | 
			
		||||
		printf("%s:Num = %d\n",__FUNCTION__,Num);
 | 
			
		||||
		sleep(1);
 | 
			
		||||
	}
 | 
			
		||||
	pthread_mutex_unlock(&mutex);
 | 
			
		||||
	pthread_exit(NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void *fun2(void *arg)
 | 
			
		||||
{
 | 
			
		||||
	pthread_mutex_lock(&mutex);
 | 
			
		||||
	while(Num > -3){
 | 
			
		||||
		Num--;
 | 
			
		||||
		printf("%s:Num = %d\n",__FUNCTION__,Num);
 | 
			
		||||
		sleep(1);
 | 
			
		||||
	}
 | 
			
		||||
	pthread_mutex_unlock(&mutex);
 | 
			
		||||
	pthread_exit(NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
	int ret;
 | 
			
		||||
	pthread_t tid1,tid2;
 | 
			
		||||
	ret = pthread_mutex_init(&mutex,NULL);
 | 
			
		||||
	if(ret != 0){
 | 
			
		||||
		perror("pthread_mutex_init");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	ret = pthread_create(&tid1,NULL,fun1,NULL);
 | 
			
		||||
	if(ret != 0){
 | 
			
		||||
		perror("pthread_create");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	ret = pthread_create(&tid2,NULL,fun2,NULL);
 | 
			
		||||
	if(ret != 0){
 | 
			
		||||
		perror("pthread_create");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	pthread_join(tid1,NULL);
 | 
			
		||||
	pthread_join(tid2,NULL);
 | 
			
		||||
	pthread_mutex_destroy(&mutex);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,48 @@
 | 
			
		||||
#define _GNU_SOURCE 
 | 
			
		||||
#include <pthread.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
 | 
			
		||||
void *fun1(void *arg)
 | 
			
		||||
{
 | 
			
		||||
	printf("%s:Pthread Come!\n",__FUNCTION__);
 | 
			
		||||
	pthread_exit(NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void *fun2(void *arg)
 | 
			
		||||
{
 | 
			
		||||
	printf("%s:Pthread Come!\n",__FUNCTION__);
 | 
			
		||||
	pthread_exit(NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void *fun3(void *arg)
 | 
			
		||||
{
 | 
			
		||||
	printf("%s:Pthread Come!\n",__FUNCTION__);
 | 
			
		||||
	pthread_exit(NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
	int ret;
 | 
			
		||||
	pthread_t tid1,tid2,tid3;
 | 
			
		||||
	ret = pthread_create(&tid1,NULL,fun1,NULL);
 | 
			
		||||
	if(ret != 0){
 | 
			
		||||
		perror("pthread_create");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	ret = pthread_create(&tid2,NULL,fun2,NULL);
 | 
			
		||||
	if(ret != 0){
 | 
			
		||||
		perror("pthread_create");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	ret = pthread_create(&tid3,NULL,fun3,NULL);
 | 
			
		||||
	if(ret != 0){
 | 
			
		||||
		perror("pthread_create");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	pthread_join(tid1,NULL);
 | 
			
		||||
	pthread_join(tid2,NULL);
 | 
			
		||||
	pthread_join(tid3,NULL);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,79 @@
 | 
			
		||||
#define _GNU_SOURCE 
 | 
			
		||||
#include <pthread.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <semaphore.h>
 | 
			
		||||
 | 
			
		||||
sem_t sem1,sem2,sem3;//申请的三个信号量变量
 | 
			
		||||
 | 
			
		||||
void *fun1(void *arg)
 | 
			
		||||
{
 | 
			
		||||
	sem_wait(&sem1);//因sem1本身有资源,所以不被阻塞 获取后sem1-1 下次会会阻塞
 | 
			
		||||
	printf("%s:Pthread Come!\n",__FUNCTION__);
 | 
			
		||||
	sem_post(&sem2);// 使得sem2获取到资源
 | 
			
		||||
	pthread_exit(NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void *fun2(void *arg)
 | 
			
		||||
{
 | 
			
		||||
	sem_wait(&sem2);//因sem2在初始化时无资源会被阻塞,直至14行代码执行 不被阻塞 sem2-1 下次会阻塞
 | 
			
		||||
	printf("%s:Pthread Come!\n",__FUNCTION__);
 | 
			
		||||
	sem_post(&sem3);// 使得sem3获取到资源
 | 
			
		||||
	pthread_exit(NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void *fun3(void *arg)
 | 
			
		||||
{
 | 
			
		||||
	sem_wait(&sem3);//因sem3在初始化时无资源会被阻塞,直至22行代码执行 不被阻塞 sem3-1 下次会阻塞
 | 
			
		||||
	printf("%s:Pthread Come!\n",__FUNCTION__);
 | 
			
		||||
	sem_post(&sem1);// 使得sem1获取到资源
 | 
			
		||||
	pthread_exit(NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
	int ret;
 | 
			
		||||
	pthread_t tid1,tid2,tid3;
 | 
			
		||||
	ret = sem_init(&sem1,0,1);  //初始化信号量1 并且赋予其资源
 | 
			
		||||
	if(ret < 0){
 | 
			
		||||
		perror("sem_init");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	ret = sem_init(&sem2,0,0); //初始化信号量2 让其阻塞
 | 
			
		||||
	if(ret < 0){
 | 
			
		||||
		perror("sem_init");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	ret = sem_init(&sem3,0,0); //初始化信号3 让其阻塞
 | 
			
		||||
	if(ret < 0){
 | 
			
		||||
		perror("sem_init");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	ret = pthread_create(&tid1,NULL,fun1,NULL);//创建线程1
 | 
			
		||||
	if(ret != 0){
 | 
			
		||||
		perror("pthread_create");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	ret = pthread_create(&tid2,NULL,fun2,NULL);//创建线程2
 | 
			
		||||
	if(ret != 0){
 | 
			
		||||
		perror("pthread_create");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	ret = pthread_create(&tid3,NULL,fun3,NULL);//创建线程3
 | 
			
		||||
	if(ret != 0){
 | 
			
		||||
		perror("pthread_create");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	/*回收线程资源*/
 | 
			
		||||
	pthread_join(tid1,NULL);
 | 
			
		||||
	pthread_join(tid2,NULL);
 | 
			
		||||
	pthread_join(tid3,NULL);
 | 
			
		||||
 | 
			
		||||
	/*销毁信号量*/
 | 
			
		||||
	sem_destroy(&sem1);
 | 
			
		||||
	sem_destroy(&sem2);
 | 
			
		||||
	sem_destroy(&sem3);
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,28 @@
 | 
			
		||||
#include <pthread.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
 | 
			
		||||
void *fun(void *arg)
 | 
			
		||||
{
 | 
			
		||||
	printf("pthread_New = %lu\n",(unsigned long)pthread_self());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	pthread_t tid1;
 | 
			
		||||
	int ret = pthread_create(&tid1,NULL,fun,NULL);
 | 
			
		||||
	if(ret != 0){
 | 
			
		||||
		perror("pthread_create");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/*tid_main 为通过pthread_self获取的线程ID,tid_new通过执行pthread_create成功后tid指向的空间*/
 | 
			
		||||
	printf("tid_main = %lu tid_new = %lu \n",(unsigned long)pthread_self(),(unsigned long)tid1);
 | 
			
		||||
	
 | 
			
		||||
	/*因线程执行顺序随机,不加sleep可能导致猪线程先执行,导致进程结束,无法执行到子线程*/
 | 
			
		||||
	sleep(1);
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,34 @@
 | 
			
		||||
#include <pthread.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
 | 
			
		||||
void *fun1(void *arg)
 | 
			
		||||
{
 | 
			
		||||
	printf("%s:arg = %d Addr = %p\n",__FUNCTION__,*(int *)arg,arg);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void *fun2(void *arg)
 | 
			
		||||
{
 | 
			
		||||
	printf("%s:arg = %d Addr = %p\n",__FUNCTION__,(int)(long)arg,arg);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	pthread_t tid1,tid2;
 | 
			
		||||
	int a = 50;
 | 
			
		||||
	int ret = pthread_create(&tid1,NULL,fun1,(void *)&a);
 | 
			
		||||
	if(ret != 0){
 | 
			
		||||
		perror("pthread_create");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	ret = pthread_create(&tid2,NULL,fun2,(void *)(long)a);
 | 
			
		||||
	if(ret != 0){
 | 
			
		||||
		perror("pthread_create");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	sleep(1);
 | 
			
		||||
	printf("%s:a = %d Add = %p \n",__FUNCTION__,a,&a);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,46 @@
 | 
			
		||||
#include <pthread.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
 | 
			
		||||
void *fun1(void *arg)
 | 
			
		||||
{
 | 
			
		||||
	while(1){
 | 
			
		||||
	
 | 
			
		||||
		printf("%s:arg = %d Addr = %p\n",__FUNCTION__,*(int *)arg,arg);
 | 
			
		||||
		sleep(1);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void *fun2(void *arg)
 | 
			
		||||
{
 | 
			
		||||
	while(1){
 | 
			
		||||
	
 | 
			
		||||
		printf("%s:arg = %d Addr = %p\n",__FUNCTION__,(int)(long)arg,arg);
 | 
			
		||||
		sleep(1);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	pthread_t tid1,tid2;
 | 
			
		||||
	int a = 50;
 | 
			
		||||
	int ret = pthread_create(&tid1,NULL,fun1,(void *)&a);
 | 
			
		||||
	if(ret != 0){
 | 
			
		||||
		perror("pthread_create");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	sleep(1);
 | 
			
		||||
	ret = pthread_create(&tid2,NULL,fun2,(void *)(long)a);
 | 
			
		||||
	if(ret != 0){
 | 
			
		||||
		perror("pthread_create");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	while(1){
 | 
			
		||||
		a++;
 | 
			
		||||
		sleep(1);
 | 
			
		||||
		printf("%s:a = %d Add = %p \n",__FUNCTION__,a,&a);
 | 
			
		||||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,37 @@
 | 
			
		||||
#include <pthread.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
 | 
			
		||||
struct Stu{
 | 
			
		||||
	int Id;
 | 
			
		||||
	char Name[32];
 | 
			
		||||
	float Mark;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
void *fun1(void *arg)
 | 
			
		||||
{
 | 
			
		||||
	struct Stu *tmp = (struct Stu *)arg;
 | 
			
		||||
	printf("%s:Id = %d Name = %s Mark = %.2f\n",__FUNCTION__,tmp->Id,tmp->Name,tmp->Mark);
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	pthread_t tid1,tid2;
 | 
			
		||||
	struct Stu stu;
 | 
			
		||||
	stu.Id = 10000;
 | 
			
		||||
	strcpy(stu.Name,"ZhangSan");
 | 
			
		||||
	stu.Mark = 94.6;
 | 
			
		||||
 | 
			
		||||
	int ret = pthread_create(&tid1,NULL,fun1,(void *)&stu);
 | 
			
		||||
	if(ret != 0){
 | 
			
		||||
		perror("pthread_create");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	printf("%s:Id = %d Name = %s Mark = %.2f\n",__FUNCTION__,stu.Id,stu.Name,stu.Mark);
 | 
			
		||||
	sleep(1);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,31 @@
 | 
			
		||||
#include <pthread.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
 | 
			
		||||
void *fun1(void *arg)
 | 
			
		||||
{
 | 
			
		||||
	static int tmp = 0;//必须要static修饰,否则pthread_join无法获取到正确值
 | 
			
		||||
	//int tmp = 0;
 | 
			
		||||
	tmp = *(int *)arg;
 | 
			
		||||
	tmp+=100;
 | 
			
		||||
	printf("%s:Addr = %p tmp = %d\n",__FUNCTION__,&tmp,tmp);
 | 
			
		||||
	pthread_exit((void *)&tmp);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	pthread_t tid1;
 | 
			
		||||
	int a = 50;
 | 
			
		||||
	void *Tmp = NULL;
 | 
			
		||||
	int ret = pthread_create(&tid1,NULL,fun1,(void *)&a);
 | 
			
		||||
	if(ret != 0){
 | 
			
		||||
		perror("pthread_create");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	pthread_join(tid1,&Tmp);
 | 
			
		||||
	printf("%s:Addr = %p Val = %d\n",__FUNCTION__,Tmp,*(int *)Tmp);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,36 @@
 | 
			
		||||
#define _GNU_SOURCE 
 | 
			
		||||
#include <pthread.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
 | 
			
		||||
void *fun(void *arg)
 | 
			
		||||
{
 | 
			
		||||
	printf("Pthread:%d Come !\n",(int )(long)arg+1);
 | 
			
		||||
	pthread_exit(arg);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
	int ret,i,flag = 0;
 | 
			
		||||
	void *Tmp = NULL;
 | 
			
		||||
	pthread_t tid[3];
 | 
			
		||||
	for(i = 0;i < 3;i++){
 | 
			
		||||
		ret = pthread_create(&tid[i],NULL,fun,(void *)(long)i);
 | 
			
		||||
		if(ret != 0){
 | 
			
		||||
			perror("pthread_create");
 | 
			
		||||
			return -1;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	while(1){
 | 
			
		||||
		for(i = 0;i <3;i++){
 | 
			
		||||
			if(pthread_tryjoin_np(tid[i],&Tmp) == 0){
 | 
			
		||||
				printf("Pthread : %d exit !\n",(int )(long )Tmp+1);
 | 
			
		||||
				flag++;	
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if(flag >= 3) break;
 | 
			
		||||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,48 @@
 | 
			
		||||
#define _GNU_SOURCE 
 | 
			
		||||
#include <pthread.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
 | 
			
		||||
void *fun1(void *arg)
 | 
			
		||||
{
 | 
			
		||||
	printf("Pthread:1 come!\n");
 | 
			
		||||
	while(1){
 | 
			
		||||
		sleep(1);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void *fun2(void *arg)
 | 
			
		||||
{
 | 
			
		||||
	printf("Pthread:2 come!\n");
 | 
			
		||||
	pthread_cancel((pthread_t )(long)arg);
 | 
			
		||||
	pthread_exit(NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
	int ret,i,flag = 0;
 | 
			
		||||
	void *Tmp = NULL;
 | 
			
		||||
	pthread_t tid[2];
 | 
			
		||||
	ret = pthread_create(&tid[0],NULL,fun1,NULL);
 | 
			
		||||
	if(ret != 0){
 | 
			
		||||
		perror("pthread_create");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	sleep(1);
 | 
			
		||||
	ret = pthread_create(&tid[1],NULL,fun2,(void *)tid[0]);
 | 
			
		||||
	if(ret != 0){
 | 
			
		||||
		perror("pthread_create");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	while(1){
 | 
			
		||||
		for(i = 0;i <2;i++){
 | 
			
		||||
			if(pthread_tryjoin_np(tid[i],NULL) == 0){
 | 
			
		||||
				printf("Pthread : %d exit !\n",i+1);
 | 
			
		||||
				flag++;	
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if(flag >= 2) break;
 | 
			
		||||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,47 @@
 | 
			
		||||
#define _GNU_SOURCE 
 | 
			
		||||
#include <pthread.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int Num = 0;
 | 
			
		||||
 | 
			
		||||
void *fun1(void *arg)
 | 
			
		||||
{
 | 
			
		||||
	while(Num < 3){
 | 
			
		||||
		Num++;
 | 
			
		||||
		printf("%s:Num = %d\n",__FUNCTION__,Num);
 | 
			
		||||
		sleep(1);
 | 
			
		||||
	}
 | 
			
		||||
	pthread_exit(NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void *fun2(void *arg)
 | 
			
		||||
{
 | 
			
		||||
	while(Num > -3){
 | 
			
		||||
		Num--;
 | 
			
		||||
		printf("%s:Num = %d\n",__FUNCTION__,Num);
 | 
			
		||||
		sleep(1);
 | 
			
		||||
	}
 | 
			
		||||
	pthread_exit(NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
	int ret;
 | 
			
		||||
	pthread_t tid1,tid2;
 | 
			
		||||
	ret = pthread_create(&tid1,NULL,fun1,NULL);
 | 
			
		||||
	if(ret != 0){
 | 
			
		||||
		perror("pthread_create");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	ret = pthread_create(&tid2,NULL,fun2,NULL);
 | 
			
		||||
	if(ret != 0){
 | 
			
		||||
		perror("pthread_create");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	pthread_join(tid1,NULL);
 | 
			
		||||
	pthread_join(tid2,NULL);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										36
									
								
								04_嵌入式Linux应用开发基础知识/source/13_thread/02_视频配套源码/pthread1.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								04_嵌入式Linux应用开发基础知识/source/13_thread/02_视频配套源码/pthread1.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
			
		||||
#include <pthread.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void *my_thread_func (void *data)
 | 
			
		||||
{
 | 
			
		||||
	while (1)
 | 
			
		||||
	{
 | 
			
		||||
		sleep(1);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int main(int argc, char **argv)
 | 
			
		||||
{
 | 
			
		||||
	pthread_t tid;
 | 
			
		||||
	int ret;
 | 
			
		||||
	
 | 
			
		||||
	/* 1. 创建"接收线程" */
 | 
			
		||||
	ret = pthread_create(&tid, NULL, my_thread_func, NULL);
 | 
			
		||||
	if (ret)
 | 
			
		||||
	{
 | 
			
		||||
		printf("pthread_create err!\n");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	/* 2. 主线程读取标准输入, 发给"接收线程" */
 | 
			
		||||
	while (1)
 | 
			
		||||
	{
 | 
			
		||||
		sleep(1);
 | 
			
		||||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										48
									
								
								04_嵌入式Linux应用开发基础知识/source/13_thread/02_视频配套源码/pthread2.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								04_嵌入式Linux应用开发基础知识/source/13_thread/02_视频配套源码/pthread2.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,48 @@
 | 
			
		||||
#include <pthread.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
 | 
			
		||||
static char g_buf[1000];
 | 
			
		||||
static int g_hasData = 0;
 | 
			
		||||
static void *my_thread_func (void *data)
 | 
			
		||||
{
 | 
			
		||||
	while (1)
 | 
			
		||||
	{
 | 
			
		||||
		//sleep(1);
 | 
			
		||||
		/* 等待通知 */
 | 
			
		||||
		while (g_hasData == 0);
 | 
			
		||||
 | 
			
		||||
		/* 打印 */
 | 
			
		||||
		printf("recv: %s\n", g_buf);
 | 
			
		||||
		g_hasData = 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int main(int argc, char **argv)
 | 
			
		||||
{
 | 
			
		||||
	pthread_t tid;
 | 
			
		||||
	int ret;
 | 
			
		||||
	
 | 
			
		||||
	/* 1. 创建"接收线程" */
 | 
			
		||||
	ret = pthread_create(&tid, NULL, my_thread_func, NULL);
 | 
			
		||||
	if (ret)
 | 
			
		||||
	{
 | 
			
		||||
		printf("pthread_create err!\n");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	/* 2. 主线程读取标准输入, 发给"接收线程" */
 | 
			
		||||
	while (1)
 | 
			
		||||
	{
 | 
			
		||||
		fgets(g_buf, 1000, stdin);
 | 
			
		||||
 | 
			
		||||
		/* 通知接收线程 */
 | 
			
		||||
		g_hasData = 1;
 | 
			
		||||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										51
									
								
								04_嵌入式Linux应用开发基础知识/source/13_thread/02_视频配套源码/pthread3.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								04_嵌入式Linux应用开发基础知识/source/13_thread/02_视频配套源码/pthread3.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,51 @@
 | 
			
		||||
#include <pthread.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <semaphore.h>
 | 
			
		||||
 | 
			
		||||
static char g_buf[1000];
 | 
			
		||||
static sem_t g_sem;
 | 
			
		||||
static void *my_thread_func (void *data)
 | 
			
		||||
{
 | 
			
		||||
	while (1)
 | 
			
		||||
	{
 | 
			
		||||
		//sleep(1);
 | 
			
		||||
		/* 等待通知 */
 | 
			
		||||
		//while (g_hasData == 0);
 | 
			
		||||
		sem_wait(&g_sem);
 | 
			
		||||
 | 
			
		||||
		/* 打印 */
 | 
			
		||||
		printf("recv: %s\n", g_buf);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int main(int argc, char **argv)
 | 
			
		||||
{
 | 
			
		||||
	pthread_t tid;
 | 
			
		||||
	int ret;
 | 
			
		||||
 | 
			
		||||
	sem_init(&g_sem, 0, 0);
 | 
			
		||||
	
 | 
			
		||||
	/* 1. 创建"接收线程" */
 | 
			
		||||
	ret = pthread_create(&tid, NULL, my_thread_func, NULL);
 | 
			
		||||
	if (ret)
 | 
			
		||||
	{
 | 
			
		||||
		printf("pthread_create err!\n");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	/* 2. 主线程读取标准输入, 发给"接收线程" */
 | 
			
		||||
	while (1)
 | 
			
		||||
	{
 | 
			
		||||
		fgets(g_buf, 1000, stdin);
 | 
			
		||||
 | 
			
		||||
		/* 通知接收线程 */
 | 
			
		||||
		sem_post(&g_sem);
 | 
			
		||||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										60
									
								
								04_嵌入式Linux应用开发基础知识/source/13_thread/02_视频配套源码/pthread4.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								04_嵌入式Linux应用开发基础知识/source/13_thread/02_视频配套源码/pthread4.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,60 @@
 | 
			
		||||
#include <pthread.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <semaphore.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
static char g_buf[1000];
 | 
			
		||||
static sem_t g_sem;
 | 
			
		||||
static pthread_mutex_t g_tMutex  = PTHREAD_MUTEX_INITIALIZER;
 | 
			
		||||
 | 
			
		||||
static void *my_thread_func (void *data)
 | 
			
		||||
{
 | 
			
		||||
	while (1)
 | 
			
		||||
	{
 | 
			
		||||
		//sleep(1);
 | 
			
		||||
		/* 等待通知 */
 | 
			
		||||
		//while (g_hasData == 0);
 | 
			
		||||
		sem_wait(&g_sem);
 | 
			
		||||
 | 
			
		||||
		/* 打印 */
 | 
			
		||||
		pthread_mutex_lock(&g_tMutex);
 | 
			
		||||
		printf("recv: %s\n", g_buf);
 | 
			
		||||
		pthread_mutex_unlock(&g_tMutex);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int main(int argc, char **argv)
 | 
			
		||||
{
 | 
			
		||||
	pthread_t tid;
 | 
			
		||||
	int ret;
 | 
			
		||||
	char buf[1000];
 | 
			
		||||
 | 
			
		||||
	sem_init(&g_sem, 0, 0);
 | 
			
		||||
	
 | 
			
		||||
	/* 1. 创建"接收线程" */
 | 
			
		||||
	ret = pthread_create(&tid, NULL, my_thread_func, NULL);
 | 
			
		||||
	if (ret)
 | 
			
		||||
	{
 | 
			
		||||
		printf("pthread_create err!\n");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	/* 2. 主线程读取标准输入, 发给"接收线程" */
 | 
			
		||||
	while (1)
 | 
			
		||||
	{
 | 
			
		||||
		fgets(buf, 1000, stdin);
 | 
			
		||||
		pthread_mutex_lock(&g_tMutex);
 | 
			
		||||
		memcpy(g_buf, buf, 1000);
 | 
			
		||||
		pthread_mutex_unlock(&g_tMutex);
 | 
			
		||||
 | 
			
		||||
		/* 通知接收线程 */
 | 
			
		||||
		sem_post(&g_sem);
 | 
			
		||||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										56
									
								
								04_嵌入式Linux应用开发基础知识/source/13_thread/02_视频配套源码/pthread5.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								04_嵌入式Linux应用开发基础知识/source/13_thread/02_视频配套源码/pthread5.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,56 @@
 | 
			
		||||
#include <pthread.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <semaphore.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
static char g_buf[1000];
 | 
			
		||||
static pthread_mutex_t g_tMutex  = PTHREAD_MUTEX_INITIALIZER;
 | 
			
		||||
static pthread_cond_t  g_tConVar = PTHREAD_COND_INITIALIZER;
 | 
			
		||||
 | 
			
		||||
static void *my_thread_func (void *data)
 | 
			
		||||
{
 | 
			
		||||
	while (1)
 | 
			
		||||
	{
 | 
			
		||||
		//sleep(1);
 | 
			
		||||
		/* 等待通知 */
 | 
			
		||||
		//while (g_hasData == 0);
 | 
			
		||||
		pthread_mutex_lock(&g_tMutex);
 | 
			
		||||
		pthread_cond_wait(&g_tConVar, &g_tMutex);	
 | 
			
		||||
 | 
			
		||||
		/* 打印 */
 | 
			
		||||
		printf("recv: %s\n", g_buf);
 | 
			
		||||
		pthread_mutex_unlock(&g_tMutex);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int main(int argc, char **argv)
 | 
			
		||||
{
 | 
			
		||||
	pthread_t tid;
 | 
			
		||||
	int ret;
 | 
			
		||||
	char buf[1000];
 | 
			
		||||
	
 | 
			
		||||
	/* 1. 创建"接收线程" */
 | 
			
		||||
	ret = pthread_create(&tid, NULL, my_thread_func, NULL);
 | 
			
		||||
	if (ret)
 | 
			
		||||
	{
 | 
			
		||||
		printf("pthread_create err!\n");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	/* 2. 主线程读取标准输入, 发给"接收线程" */
 | 
			
		||||
	while (1)
 | 
			
		||||
	{
 | 
			
		||||
		fgets(buf, 1000, stdin);
 | 
			
		||||
		pthread_mutex_lock(&g_tMutex);
 | 
			
		||||
		memcpy(g_buf, buf, 1000);
 | 
			
		||||
		pthread_cond_signal(&g_tConVar); /* 通知接收线程 */
 | 
			
		||||
		pthread_mutex_unlock(&g_tMutex);
 | 
			
		||||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							
		Reference in New Issue
	
	Block a user