锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久精品国产免费观看,欧美日韩亚洲另类,国产日韩欧美精品在线http://www.shnenglu.com/newplan/category/5224.html闃垮熀綾沖痙鍦ㄦ礂婢℃檪鐧肩従嫻姏鍘熺悊錛岄珮鑸堝緱渚嗕笉鍙婄┛銌栬げ瀛愶紝璺戝埌琛椼問澶у枈錛欵ureka錛堟垜鎵懼埌浜嗭級銆?/description>zh-cnMon, 19 May 2008 13:40:49 GMTMon, 19 May 2008 13:40:49 GMT60浜斾釜鍝插瀹剁嚎紼嬪疄鐜?/title><link>http://www.shnenglu.com/newplan/archive/2008/01/04/40374.html</link><dc:creator>灞辨硥寮歡</dc:creator><author>灞辨硥寮歡</author><pubDate>Thu, 03 Jan 2008 16:14:00 GMT</pubDate><guid>http://www.shnenglu.com/newplan/archive/2008/01/04/40374.html</guid><wfw:comment>http://www.shnenglu.com/newplan/comments/40374.html</wfw:comment><comments>http://www.shnenglu.com/newplan/archive/2008/01/04/40374.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/newplan/comments/commentRss/40374.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/newplan/services/trackbacks/40374.html</trackback:ping><description><![CDATA[<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">#include </span><span style="color: #000000;">"</span><span style="color: #000000;">apue.h</span><span style="color: #000000;">"</span><span style="color: #000000;"><br>#include </span><span style="color: #000000;">"</span><span style="color: #000000;">semaphore.h</span><span style="color: #000000;">"</span><span style="color: #000000;"><br>#include </span><span style="color: #000000;">"</span><span style="color: #000000;">pthread.h</span><span style="color: #000000;">"</span><span style="color: #000000;"><br><br>#define N </span><span style="color: #000000;">5</span><span style="color: #000000;"><br>static </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> necs;<br>static sem_t  </span><span style="color: #000000;">*</span><span style="color: #000000;">forks;<br><br>void </span><span style="color: #000000;">*</span><span style="color: #000000;"><br>takeFork(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> i)<br>{<br></span><span style="color: #0000ff;">if</span><span style="color: #000000;">(i</span><span style="color: #000000;">==</span><span style="color: #000000;">N</span><span style="color: #000000;">-</span><span style="color: #000000;">1</span><span style="color: #000000;">)<br>    {<br>     sem_wait(</span><span style="color: #000000;">&</span><span style="color: #000000;">forks[</span><span style="color: #000000;">0</span><span style="color: #000000;">]);<br>     sem_wait(</span><span style="color: #000000;">&</span><span style="color: #000000;">forks[i]);<br>    }<br>   </span><span style="color: #0000ff;">else</span><span style="color: #000000;"><br>     {<br>     sem_wait(</span><span style="color: #000000;">&</span><span style="color: #000000;">forks[i]);<br>     sem_wait(</span><span style="color: #000000;">&</span><span style="color: #000000;">forks[i</span><span style="color: #000000;">+</span><span style="color: #000000;">1</span><span style="color: #000000;">]);<br>     }<br>}<br>void </span><span style="color: #000000;">*</span><span style="color: #000000;"><br>putFork(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> i)<br>{<br></span><span style="color: #0000ff;">if</span><span style="color: #000000;">(i</span><span style="color: #000000;">==</span><span style="color: #000000;">N</span><span style="color: #000000;">-</span><span style="color: #000000;">1</span><span style="color: #000000;">)<br>    {<br>     sem_post(</span><span style="color: #000000;">&</span><span style="color: #000000;">forks[</span><span style="color: #000000;">0</span><span style="color: #000000;">]);<br>     sem_post(</span><span style="color: #000000;">&</span><span style="color: #000000;">forks[i]);<br>    }<br></span><span style="color: #0000ff;">else</span><span style="color: #000000;"><br>    {<br>    sem_post(</span><span style="color: #000000;">&</span><span style="color: #000000;">forks[i]);<br>    sem_post(</span><span style="color: #000000;">&</span><span style="color: #000000;">forks[i</span><span style="color: #000000;">+</span><span style="color: #000000;">1</span><span style="color: #000000;">]);<br>   }<br>}<br>void <br>thinking(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> i,</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> necs)<br>{<br>    printf(</span><span style="color: #000000;">"</span><span style="color: #000000;">pholosopher %d  is thinking\n</span><span style="color: #000000;">"</span><span style="color: #000000;">,i);<br>    sleep(necs);<br><br>}<br>void<br>eating(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> i,</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> necs)<br>{<br>    printf(</span><span style="color: #000000;">"</span><span style="color: #000000;">pholosopher %d  is eating\n</span><span style="color: #000000;">"</span><span style="color: #000000;">,i);<br>    sleep(necs);<br>}<br>void </span><span style="color: #000000;">*</span><span style="color: #000000;"><br>philosopher(void </span><span style="color: #000000;">*</span><span style="color: #000000;">n)<br>{<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> i</span><span style="color: #000000;">=</span><span style="color: #000000;">(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> )n;<br>    </span><span style="color: #0000ff;">while</span><span style="color: #000000;">(</span><span style="color: #000000;">1</span><span style="color: #000000;">)<br>    {<br>     thinking(i,necs);<br>     takeFork(i);<br>     eating(i,necs);<br>     putFork(i);<br>    }<br>}<br></span><span style="color: #000000;">//============================</span><span style="color: #000000;">main </span><span style="color: #0000ff;">function</span><span style="color: #000000;"><br></span><span style="color: #0000ff;">int</span><span style="color: #000000;"><br>main(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> argc,char </span><span style="color: #000000;">*</span><span style="color: #000000;">argv[])<br>{<br>   pthread_t tid;<br>  <br>   </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(argc</span><span style="color: #000000;">==</span><span style="color: #000000;">1</span><span style="color: #000000;">)<br>          necs</span><span style="color: #000000;">=</span><span style="color: #000000;">2</span><span style="color: #000000;">;<br>   </span><span style="color: #0000ff;">else</span><span style="color: #000000;"> </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(argc </span><span style="color: #000000;">==</span><span style="color: #000000;">2</span><span style="color: #000000;">)<br>          necs</span><span style="color: #000000;">=</span><span style="color: #000000;">atoi(argv[</span><span style="color: #000000;">1</span><span style="color: #000000;">]);<br>   </span><span style="color: #0000ff;">else</span><span style="color: #000000;"> return </span><span style="color: #000000;">1</span><span style="color: #000000;">;<br>  <br>   forks</span><span style="color: #000000;">=</span><span style="color: #000000;">(sem_t</span><span style="color: #000000;">*</span><span style="color: #000000;">)malloc(N</span><span style="color: #000000;">*</span><span style="color: #000000;">sizeof(sem_t));<br>   <br>   </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> i;<br>   </span><span style="color: #0000ff;">for</span><span style="color: #000000;">(i</span><span style="color: #000000;">=</span><span style="color: #000000;">0</span><span style="color: #000000;">;  i</span><span style="color: #000000;"><</span><span style="color: #000000;">N;  i</span><span style="color: #000000;">++</span><span style="color: #000000;">)<br>   sem_init(forks</span><span style="color: #000000;">+</span><span style="color: #000000;">i,</span><span style="color: #000000;">0</span><span style="color: #000000;">,</span><span style="color: #000000;">1</span><span style="color: #000000;">);<br><br>   </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> status;<br>   </span><span style="color: #0000ff;">for</span><span style="color: #000000;">(i</span><span style="color: #000000;">=</span><span style="color: #000000;">0</span><span style="color: #000000;">;i</span><span style="color: #000000;"><</span><span style="color: #000000;">N;i</span><span style="color: #000000;">++</span><span style="color: #000000;">)<br>    {<br>      status</span><span style="color: #000000;">=</span><span style="color: #000000;">pthread_create(</span><span style="color: #000000;">&</span><span style="color: #000000;">tid,</span><span style="color: #0000ff;">NULL</span><span style="color: #000000;">,philosopher,(void</span><span style="color: #000000;">*</span><span style="color: #000000;">)i);<br><br>      </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(status</span><span style="color: #000000;"><</span><span style="color: #000000;">0</span><span style="color: #000000;">)<br>      err_sys(</span><span style="color: #000000;">"</span><span style="color: #000000;">create error!</span><span style="color: #000000;">"</span><span style="color: #000000;">);  <br>    } <br>    pthread_join(tid ,</span><span style="color: #0000ff;">NULL</span><span style="color: #000000;">);<br>    return </span><span style="color: #000000;">0</span><span style="color: #000000;">;  <br>}<br></span></div> <br><img src ="http://www.shnenglu.com/newplan/aggbug/40374.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/newplan/" target="_blank">灞辨硥寮歡</a> 2008-01-04 00:14 <a href="http://www.shnenglu.com/newplan/archive/2008/01/04/40374.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>浜斾釜鍝插瀹惰繘紼嬪疄鐜?/title><link>http://www.shnenglu.com/newplan/archive/2008/01/04/40373.html</link><dc:creator>灞辨硥寮歡</dc:creator><author>灞辨硥寮歡</author><pubDate>Thu, 03 Jan 2008 16:13:00 GMT</pubDate><guid>http://www.shnenglu.com/newplan/archive/2008/01/04/40373.html</guid><wfw:comment>http://www.shnenglu.com/newplan/comments/40373.html</wfw:comment><comments>http://www.shnenglu.com/newplan/archive/2008/01/04/40373.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/newplan/comments/commentRss/40373.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/newplan/services/trackbacks/40373.html</trackback:ping><description><![CDATA[<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">#include </span><span style="color: #000000;">"</span><span style="color: #000000;">apue.h</span><span style="color: #000000;">"</span><span style="color: #000000;"><br>#include </span><span style="color: #000000;">"</span><span style="color: #000000;">lock.h</span><span style="color: #000000;">"</span><span style="color: #000000;"><br>#include </span><span style="color: #000000;">"</span><span style="color: #000000;">lock.c</span><span style="color: #000000;">"</span><span style="color: #000000;"><br><br></span><span style="color: #000000;">/*</span><span style="color: #000000;">define some important variable</span><span style="color: #000000;">*/</span><span style="color: #000000;"><br></span><span style="color: #000000;">/*=======================================*/</span><span style="color: #000000;"><br>pid_t  pid;<br><br>static char </span><span style="color: #000000;">*</span><span style="color: #000000;">forks[</span><span style="color: #000000;">5</span><span style="color: #000000;">]</span><span style="color: #000000;">=</span><span style="color: #000000;">{<br></span><span style="color: #000000;">"</span><span style="color: #000000;">fork0</span><span style="color: #000000;">"</span><span style="color: #000000;">, </span><span style="color: #000000;">"</span><span style="color: #000000;">fork1</span><span style="color: #000000;">"</span><span style="color: #000000;">, </span><span style="color: #000000;">"</span><span style="color: #000000;">fork2</span><span style="color: #000000;">"</span><span style="color: #000000;"> ,</span><span style="color: #000000;">"</span><span style="color: #000000;">fork3</span><span style="color: #000000;">"</span><span style="color: #000000;"> ,</span><span style="color: #000000;">"</span><span style="color: #000000;">fork4</span><span style="color: #000000;">"</span><span style="color: #000000;"><br>};<br><br>static </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> necs;<br><br>#define N </span><span style="color: #000000;">5</span><span style="color: #000000;"><br><br></span><span style="color: #000000;">/*======================================*/</span><span style="color: #000000;"><br>void takeFork(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> i)<br>{<br></span><span style="color: #0000ff;">if</span><span style="color: #000000;">(i</span><span style="color: #000000;">==</span><span style="color: #000000;">N</span><span style="color: #000000;">-</span><span style="color: #000000;">1</span><span style="color: #000000;">)<br>  {<br>     lock(forks[</span><span style="color: #000000;">0</span><span style="color: #000000;">]);<br>     lock(forks[i]);<br>  }<br></span><span style="color: #0000ff;">else</span><span style="color: #000000;"><br>{<br>lock(forks[i]);<br>lock(forks[i</span><span style="color: #000000;">+</span><span style="color: #000000;">1</span><span style="color: #000000;">]);<br>}<br>}<br><br><br>void putFork(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> i)<br>{<br>   </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(i</span><span style="color: #000000;">==</span><span style="color: #000000;">N</span><span style="color: #000000;">-</span><span style="color: #000000;">1</span><span style="color: #000000;">)<br>    {<br>    unlock(forks[</span><span style="color: #000000;">0</span><span style="color: #000000;">]);<br>    unlock(forks[i]);<br>    }<br>  </span><span style="color: #0000ff;">else</span><span style="color: #000000;"><br>   {<br>   unlock(forks[i]);<br>   unlock(forks[i</span><span style="color: #000000;">+</span><span style="color: #000000;">1</span><span style="color: #000000;">]);<br><br>   }<br>}<br></span><span style="color: #0000ff;">int</span><span style="color: #000000;"><br>thinking(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> i,</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> necs){<br>printf(</span><span style="color: #000000;">"</span><span style="color: #000000;">pholosopher %d is thinking\n</span><span style="color: #000000;">"</span><span style="color: #000000;">,i);<br>return sleep(necs);<br>}<br></span><span style="color: #0000ff;">int</span><span style="color: #000000;"> <br>eating(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> i,</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> necs)<br>{printf(</span><span style="color: #000000;">"</span><span style="color: #000000;">pholosopher %d is eating\n</span><span style="color: #000000;">"</span><span style="color: #000000;">,i);<br>return sleep(necs);<br>}<br>void philosopher(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> i)<br>{<br></span><span style="color: #0000ff;">while</span><span style="color: #000000;">(</span><span style="color: #000000;">1</span><span style="color: #000000;">)<br>{<br>thinking(i,necs);<br>takeFork(i);<br>eating(i,necs);<br>putFork(i);<br><br>}<br>}<br></span><span style="color: #0000ff;">int</span><span style="color: #000000;"><br> main(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> argc ,char </span><span style="color: #000000;">*</span><span style="color: #000000;">argv[])<br>{<br> </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(argc</span><span style="color: #000000;">=</span><span style="color: #000000;">1</span><span style="color: #000000;">)<br>      necs</span><span style="color: #000000;">=</span><span style="color: #000000;">2</span><span style="color: #000000;">;<br></span><span style="color: #0000ff;">else</span><span style="color: #000000;"> </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(argc</span><span style="color: #000000;">==</span><span style="color: #000000;">2</span><span style="color: #000000;">)<br>     necs</span><span style="color: #000000;">=</span><span style="color: #000000;">atoi(argv[</span><span style="color: #000000;">1</span><span style="color: #000000;">]);<br></span><span style="color: #0000ff;">else</span><span style="color: #000000;">  return </span><span style="color: #000000;">0</span><span style="color: #000000;">;<br> <br></span><span style="color: #0000ff;">int</span><span style="color: #000000;"> i;   <br></span><span style="color: #0000ff;">for</span><span style="color: #000000;">(i</span><span style="color: #000000;">=</span><span style="color: #000000;">0</span><span style="color: #000000;">;i</span><span style="color: #000000;"><</span><span style="color: #000000;">N;i</span><span style="color: #000000;">++</span><span style="color: #000000;">)<br>{<br> pid</span><span style="color: #000000;">=</span><span style="color: #000000;">fork();<br> </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(pid </span><span style="color: #000000;">==</span><span style="color: #000000;">0</span><span style="color: #000000;">)<br>     philosopher(i);<br>}<br>return </span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>}<br></span></div> <br><img src ="http://www.shnenglu.com/newplan/aggbug/40373.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/newplan/" target="_blank">灞辨硥寮歡</a> 2008-01-04 00:13 <a href="http://www.shnenglu.com/newplan/archive/2008/01/04/40373.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鍚屾鍐欎笌寮傛鍐欐枃浠跺疄鐜?/title><link>http://www.shnenglu.com/newplan/archive/2007/11/21/37099.html</link><dc:creator>灞辨硥寮歡</dc:creator><author>灞辨硥寮歡</author><pubDate>Wed, 21 Nov 2007 10:45:00 GMT</pubDate><guid>http://www.shnenglu.com/newplan/archive/2007/11/21/37099.html</guid><wfw:comment>http://www.shnenglu.com/newplan/comments/37099.html</wfw:comment><comments>http://www.shnenglu.com/newplan/archive/2007/11/21/37099.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/newplan/comments/commentRss/37099.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/newplan/services/trackbacks/37099.html</trackback:ping><description><![CDATA[<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><span style="color: #008000;">/*<br> 07.11.20 浜庢搗闊?br>*/<br>#</span><span style="color: #008000;">include  "sys/times.h"<br>#include "apue.h"<br>#include "fcntl.h"</span><span style="color: #008000;"><br></span><span style="color: #000000;">clock_t </span><span style="color: #0000ff;">times</span><span style="color: #000000;">(struct tms </span><span style="color: #000000;">*</span><span style="color: #000000;">buf);<br><br>static void pr_times(clock_t real </span><span style="color: #000000;">,</span><span style="color: #000000;">struct tms </span><span style="color: #000000;">*</span><span style="color: #000000;">tmsstart</span><span style="color: #000000;">,</span><span style="color: #000000;"> struct tms </span><span style="color: #000000;">*</span><span style="color: #000000;">tmsend);<br><br></span><span style="color: #0000ff;">int</span><span style="color: #000000;"> main(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> argc</span><span style="color: #000000;">,</span><span style="color: #000000;"> char </span><span style="color: #000000;">*</span><span style="color: #000000;">argv[])<br>{<br>  struct tms tmsstart</span><span style="color: #000000;">,</span><span style="color: #000000;">tmsend;<br> <br>  clock_t  start</span><span style="color: #000000;">,</span><span style="color: #000000;">end;<br> <br>  off_t excursion;<br> <br>  </span><span style="color: #0000ff;">if</span><span style="color: #000000;">((excursion</span><span style="color: #000000;">=</span><span style="color: #000000;">lseek(</span><span style="color: #800000;">0</span><span style="color: #000000;">,</span><span style="color: #800000;">0</span><span style="color: #000000;">,</span><span style="color: #000000;">SEEK_END))</span><span style="color: #000000;">==-</span><span style="color: #800000;">1</span><span style="color: #000000;">)</span><span style="color: #0000ff;">printf</span><span style="color: #000000;">(</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">can not seek!\n</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">);<br> <br>  char buf[excursion];<br> <br>  </span><span style="color: #000000;">/*</span><span style="color: #0000ff;">printf</span><span style="color: #000000;">(</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">excutsion ==#%d\n</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">,</span><span style="color: #000000;">excursion);</span><span style="color: #000000;">*/</span><span style="color: #000000;"><br>  </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> outfile_fd;</span><span style="color: #000000;">/*</span><span style="color: #000000;">out file descrite tag </span><span style="color: #000000;">*/</span><span style="color: #000000;"><br> <br>  lseek(</span><span style="color: #800000;">0</span><span style="color: #000000;">,</span><span style="color: #800000;">0</span><span style="color: #000000;">,</span><span style="color: #000000;">SEEK_SET);</span><span style="color: #000000;">/*</span><span style="color: #000000;">it is very importent  to go back  to the beginning of input file</span><span style="color: #000000;">!*/</span><span style="color: #000000;"><br> <br>  </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(</span><span style="color: #0000ff;">read</span><span style="color: #000000;">(</span><span style="color: #800000;">0</span><span style="color: #000000;">,</span><span style="color: #000000;">buf</span><span style="color: #000000;">,</span><span style="color: #000000;">excursion)</span><span style="color: #000000;">==</span><span style="color: #800000;">0</span><span style="color: #000000;">)</span><span style="color: #0000ff;">printf</span><span style="color: #000000;">(</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">read OK!\n</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">);<br>  </span><span style="color: #000000;">/*</span><span style="color: #000000;"> buf[excursion]</span><span style="color: #000000;">=</span><span style="color: #000000; font-weight: bold;">'</span><span style="color: #000000; font-weight: bold;">\0</span><span style="color: #000000; font-weight: bold;">'</span><span style="color: #000000;">;</span><span style="color: #000000;">*/</span><span style="color: #000000;"><br>  </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(argc</span><span style="color: #000000;">==</span><span style="color: #800000;">3</span><span style="color: #000000;">  </span><span style="color: #000000;">&&</span><span style="color: #000000;">  strcmp(argv[</span><span style="color: #800000;">2</span><span style="color: #000000;">]</span><span style="color: #000000;">,</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">sync</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">)</span><span style="color: #000000;">==</span><span style="color: #800000;">0</span><span style="color: #000000;">)<br>      { </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(( outfile_fd</span><span style="color: #000000;">=</span><span style="color: #0000ff;">open</span><span style="color: #000000;">(argv[</span><span style="color: #800000;">1</span><span style="color: #000000;">]</span><span style="color: #000000;">,</span><span style="color: #000000;">O_RDWR</span><span style="color: #000000;">|</span><span style="color: #000000;">O_CREAT</span><span style="color: #000000;">|</span><span style="color: #000000;">O_SYNC</span><span style="color: #000000;">,</span><span style="color: #800000;">0666</span><span style="color: #000000;">))</span><span style="color: #000000;"><</span><span style="color: #800000;">0</span><span style="color: #000000;">)err_sys(</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">creat error</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">);}<br>    </span><span style="color: #0000ff;">else</span><span style="color: #000000;"> </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(argc</span><span style="color: #000000;">==</span><span style="color: #800000;">2</span><span style="color: #000000;">)<br>       {</span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (( outfile_fd</span><span style="color: #000000;">=</span><span style="color: #0000ff;">open</span><span style="color: #000000;">(argv[</span><span style="color: #800000;">1</span><span style="color: #000000;">]</span><span style="color: #000000;">,</span><span style="color: #000000;">O_RDWR</span><span style="color: #000000;">|</span><span style="color: #000000;">O_CREAT</span><span style="color: #000000;">,</span><span style="color: #800000;">0666</span><span style="color: #000000;">))</span><span style="color: #000000;"><</span><span style="color: #800000;">0</span><span style="color: #000000;">)err_sys(</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">creat error</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">);}<br>    </span><span style="color: #0000ff;">else</span><span style="color: #000000;">{</span><span style="color: #0000ff;">printf</span><span style="color: #000000;">(</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">para error!\n</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">);</span><span style="color: #0000ff;">exit</span><span style="color: #000000;">(</span><span style="color: #800000;">1</span><span style="color: #000000;">);}<br>    long size</span><span style="color: #000000;">=</span><span style="color: #800000;">1024</span><span style="color: #000000;">; <br>    fflush(stdin);<br>    </span><span style="color: #0000ff;">printf</span><span style="color: #000000;">(</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">BUFFSIZE  USER CPU  SYSTEM CPU  REAL TIMES  CIRCLE TIMES\n</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">);<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;">  n;<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> t;<br>    char </span><span style="color: #000000;">*</span><span style="color: #000000;">p</span><span style="color: #000000;">=</span><span style="color: #000000;">buf;<br>    long  redo_count;</span><span style="color: #000000;">/*</span><span style="color: #000000;">re </span><span style="color: #0000ff;">do</span><span style="color: #000000;"> copy </span><span style="color: #0000ff;">times</span><span style="color: #000000;">*/</span><span style="color: #000000;"> <br><br>  </span><span style="color: #0000ff;">do</span><span style="color: #000000;">{ <br>      </span><span style="color: #0000ff;">if</span><span style="color: #000000;">((start</span><span style="color: #000000;">=</span><span style="color: #0000ff;">times</span><span style="color: #000000;">(</span><span style="color: #000000;">&</span><span style="color: #000000;">tmsstart))</span><span style="color: #000000;">==-</span><span style="color: #800000;">1</span><span style="color: #000000;">)err_sys(</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">times error</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">);<br>      redo_count</span><span style="color: #000000;">=</span><span style="color: #800000;">0</span><span style="color: #000000;">;</span><span style="color: #000000;">/*</span><span style="color: #000000;">it is very </span><span style="color: #0000ff;">import</span><span style="color: #000000;"> to set the counter zero at every circle </span><span style="color: #000000;">*/</span><span style="color: #000000;"><br>      t</span><span style="color: #000000;">=</span><span style="color: #800000;">1</span><span style="color: #000000;">;</span><span style="color: #000000;">/*</span><span style="color: #000000;">it is </span><span style="color: #0000ff;">use</span><span style="color: #000000;"> in the inside </span><span style="color: #0000ff;">while</span><span style="color: #000000;"> </span><span style="color: #000000;">*/</span><span style="color: #000000;"><br>      </span><span style="color: #0000ff;">while</span><span style="color: #000000;">((n</span><span style="color: #000000;">=</span><span style="color: #0000ff;">write</span><span style="color: #000000;">(outfile_fd</span><span style="color: #000000;">,</span><span style="color: #000000;">p</span><span style="color: #000000;">,</span><span style="color: #000000;">size))</span><span style="color: #000000;">==</span><span style="color: #000000;">size)<br>              {   p</span><span style="color: #000000;">+=</span><span style="color: #000000;">size;</span><span style="color: #000000;">/*</span><span style="color: #000000;">the begin buf must increase every </span><span style="color: #0000ff;">time</span><span style="color: #000000;">*/</span><span style="color: #000000;"><br>                  redo_count</span><span style="color: #000000;">++</span><span style="color: #000000;">;</span><span style="color: #000000;">/*</span><span style="color: #000000;">count how many </span><span style="color: #0000ff;">times</span><span style="color: #000000;"> circle </span><span style="color: #0000ff;">do</span><span style="color: #000000;">*/</span><span style="color: #000000;"><br>                  t</span><span style="color: #000000;">=</span><span style="color: #000000;">size</span><span style="color: #000000;">*</span><span style="color: #000000;">redo_count;</span><span style="color: #000000;">/*</span><span style="color: #000000;">one tag to count how many charaters we have travered</span><span style="color: #000000;">*/</span><span style="color: #000000;"><br>                  </span><span style="color: #000000;">/*</span><span style="color: #000000;"> </span><span style="color: #0000ff;">printf</span><span style="color: #000000;">(</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">excursion==%d  t==%d   excursion-t==%d  size==%d\n</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">,</span><span style="color: #000000;">excursion</span><span style="color: #000000;">,</span><span style="color: #000000;">t</span><span style="color: #000000;">,</span><span style="color: #000000;">excursion</span><span style="color: #000000;">-</span><span style="color: #000000;">t</span><span style="color: #000000;">,</span><span style="color: #000000;">size);</span><span style="color: #000000;">*/</span><span style="color: #000000;"><br>                  </span><span style="color: #0000ff;">if</span><span style="color: #000000;">((excursion</span><span style="color: #000000;">-</span><span style="color: #000000;">t)</span><span style="color: #000000;"><</span><span style="color: #000000;">size)break;<br>              }<br>      </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(excursion</span><span style="color: #000000;">-</span><span style="color: #000000;">t</span><span style="color: #000000;">></span><span style="color: #800000;">0</span><span style="color: #000000;">)<br>         </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(</span><span style="color: #0000ff;">write</span><span style="color: #000000;">(outfile_fd</span><span style="color: #000000;">,</span><span style="color: #000000;">p</span><span style="color: #000000;">,</span><span style="color: #000000;">excursion</span><span style="color: #000000;">-</span><span style="color: #000000;">t)</span><span style="color: #000000;">!=</span><span style="color: #000000;">(excursion</span><span style="color: #000000;">-</span><span style="color: #000000;">t))err_sys(</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">read error</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">);<br>      </span><span style="color: #0000ff;">if</span><span style="color: #000000;">((end</span><span style="color: #000000;">=</span><span style="color: #0000ff;">times</span><span style="color: #000000;">(</span><span style="color: #000000;">&</span><span style="color: #000000;">tmsend))</span><span style="color: #000000;">==-</span><span style="color: #800000;">1</span><span style="color: #000000;">)err_sys(</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">times error</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">);<br>      </span><span style="color: #0000ff;">printf</span><span style="color: #000000;">(</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">%7ld</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">,</span><span style="color: #000000;">size);<br>      pr_times(end</span><span style="color: #000000;">-</span><span style="color: #000000;">start</span><span style="color: #000000;">,&</span><span style="color: #000000;">tmsstart</span><span style="color: #000000;">,&</span><span style="color: #000000;">tmsend);<br>      </span><span style="color: #0000ff;">printf</span><span style="color: #000000;">(</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">%7ld\n</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">,</span><span style="color: #000000;">redo_count);<br>      lseek(outfile_fd</span><span style="color: #000000;">,</span><span style="color: #800000;">0</span><span style="color: #000000;">,</span><span style="color: #000000;">SEEK_SET);</span><span style="color: #000000;">/*</span><span style="color: #000000;">let the outfile pointer go back to the beginning of outfile</span><span style="color: #000000;">!*/</span><span style="color: #000000;"><br>      p</span><span style="color: #000000;">=</span><span style="color: #000000;">buf;</span><span style="color: #000000;">/*</span><span style="color: #000000;">let p </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> to the beginning of buf;</span><span style="color: #000000;">*/</span><span style="color: #000000;"><br>     </span><span style="color: #000000;">/*</span><span style="color: #000000;"> </span><span style="color: #0000ff;">printf</span><span style="color: #000000;">(</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">size=%d  excursion=%d\n</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">,</span><span style="color: #000000;">size</span><span style="color: #000000;">,</span><span style="color: #000000;">excursion);</span><span style="color: #000000;">*/</span><span style="color: #000000;"><br>     } </span><span style="color: #0000ff;">while</span><span style="color: #000000;">((size</span><span style="color: #000000;">*=</span><span style="color: #800000;">2</span><span style="color: #000000;">)</span><span style="color: #000000;"><=</span><span style="color: #000000;">excursion);<br>  <br></span><span style="color: #0000ff;">return</span><span style="color: #000000;"> </span><span style="color: #800000;">0</span><span style="color: #000000;">;<br>}<br>static void<br>pr_times(clock_t real </span><span style="color: #000000;">,</span><span style="color: #000000;">struct tms </span><span style="color: #000000;">*</span><span style="color: #000000;">tmsstart</span><span style="color: #000000;">,</span><span style="color: #000000;">struct tms </span><span style="color: #000000;">*</span><span style="color: #000000;">tmsend)<br>{static long clktck</span><span style="color: #000000;">=</span><span style="color: #800000;">0</span><span style="color: #000000;">;<br></span><span style="color: #0000ff;">if</span><span style="color: #000000;">(clktck</span><span style="color: #000000;">==</span><span style="color: #800000;">0</span><span style="color: #000000;">)<br> </span><span style="color: #0000ff;">if</span><span style="color: #000000;">((clktck</span><span style="color: #000000;">=</span><span style="color: #000000;">sysconf(_SC_CLK_TCK))</span><span style="color: #000000;"><</span><span style="color: #800000;">0</span><span style="color: #000000;">)<br>    </span><span style="color: #0000ff;">printf</span><span style="color: #000000;">(</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">sysconf error</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">);<br><br></span><span style="color: #0000ff;">printf</span><span style="color: #000000;">(</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">   %2.5f</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">,</span><span style="color: #000000;">(tmsend</span><span style="color: #000000;">-></span><span style="color: #000000;">tms_utime</span><span style="color: #000000;">-</span><span style="color: #000000;">tmsstart</span><span style="color: #000000;">-></span><span style="color: #000000;">tms_utime)</span><span style="color: #000000;">/</span><span style="color: #000000;">(double)clktck);<br></span><span style="color: #0000ff;">printf</span><span style="color: #000000;">(</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">   %2.5f</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">,</span><span style="color: #000000;">(tmsend</span><span style="color: #000000;">-></span><span style="color: #000000;">tms_stime</span><span style="color: #000000;">-</span><span style="color: #000000;">tmsstart</span><span style="color: #000000;">-></span><span style="color: #000000;">tms_stime)</span><span style="color: #000000;">/</span><span style="color: #000000;">(double)clktck);<br></span><span style="color: #0000ff;">printf</span><span style="color: #000000;">(</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">     %2.5f    </span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">,</span><span style="color: #000000;">real</span><span style="color: #000000;">/</span><span style="color: #000000;">(double)clktck);<br>} <br> </span></div> <br><img src ="http://www.shnenglu.com/newplan/aggbug/37099.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/newplan/" target="_blank">灞辨硥寮歡</a> 2007-11-21 18:45 <a href="http://www.shnenglu.com/newplan/archive/2007/11/21/37099.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>unix_綆鍗晄hell瀹炵幇http://www.shnenglu.com/newplan/archive/2007/11/06/35991.html灞辨硥寮歡灞辨硥寮歡Tue, 06 Nov 2007 15:18:00 GMThttp://www.shnenglu.com/newplan/archive/2007/11/06/35991.htmlhttp://www.shnenglu.com/newplan/comments/35991.htmlhttp://www.shnenglu.com/newplan/archive/2007/11/06/35991.html#Feedback0http://www.shnenglu.com/newplan/comments/commentRss/35991.htmlhttp://www.shnenglu.com/newplan/services/trackbacks/35991.html#include "apue.h"
#include 
<sys/wait.h>
extern  char 
**environ;
static void sign_Int(
int signnal)
{printf(
"Be interrupted\n%%");}
static void sign_Quit(
int signnal)
{printf(
"quit\n%%");
}

int 
main(void)
{
   
    char 
*argv[20];
    pid_t pid;
    
int status;
    
if(signal(SIGINT,sign_Int)==SIG_ERR)
       err_sys(
"signal error\n");
    
if(signal(SIGQUIT,sign_Quit)==SIG_ERR)
         err_sys(
"signal error\n");
    printf(
"%%");
    
while (1)
    {        char buf[MAXLINE];
             
int index=0,i=0;
           
if(fgets(buf,MAXLINE,stdin)==NULL)
             break;  
        
while( buf[i] != '\0'&&buf[i]!='\n' )
        {
           
if(buf[i] != ' ' )
           {  
               argv[index]
= buf+i;
               index
++;
               
for(;buf[i]!= ' '&&buf[i]!='\n';i++);
               if(buf[i]=='\n')
               break;               
               buf[i]
='\0';
                i++;
                
while(buf[i]==' ') 
                       i++
           }  
        } 
        buf[i]
='\0';
        argv[index] = NULL;
        
if((pid = fork() ) < 0 ) 
           err_sys(
"fork error\n");
        
else if( pid == 0 )
        {
           execve(argv[
0],argv,environ);
           err_ret(
"coundn't execute:%s",argv[0]);           
           
exit(127);
          }
        
if(( pid = waitpid(pid,&status,0)) < 0)
           err_sys(
"waitpid error\n");
          printf(
"%%"); 
     }
     
exit(0);
}


]]>
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            欧美福利视频在线| 欧美激情国产日韩| 亚洲永久网站| 国产精品免费在线| 亚洲欧美日韩在线不卡| 一区二区91| 欧美午夜精品电影| 久久av最新网址| 久久激情一区| 亚洲精品一区二区三区樱花| 欧美成人tv| 欧美日韩高清在线观看| 亚洲一区精品视频| 欧美在线亚洲综合一区| 亚洲高清视频一区二区| 亚洲欧洲日本国产| 国产精品极品美女粉嫩高清在线| 亚洲中字在线| 久久精品视频一| 亚洲看片网站| 亚洲欧美国产精品桃花| 伊甸园精品99久久久久久| 亚洲国产精品国自产拍av秋霞| 欧美精品成人一区二区在线观看 | 国产精品福利在线| 久久精品123| 欧美激情久久久| 欧美一区二区三区在线看| 久久久噜噜噜久久中文字免| 亚洲美洲欧洲综合国产一区| 亚洲欧美国产精品专区久久| 亚洲国产成人久久| 9国产精品视频| 极品av少妇一区二区| 99热在这里有精品免费| 伊人久久噜噜噜躁狠狠躁| 亚洲另类自拍| 在线播放中文一区| 亚洲一区二区三区在线播放| 亚洲福利电影| 亚洲综合首页| 亚洲免费观看高清完整版在线观看熊 | 一区二区三区视频在线观看 | 欧美日韩中字| 欧美福利精品| 国产偷国产偷精品高清尤物| 亚洲六月丁香色婷婷综合久久| 精久久久久久久久久久| 亚洲视频www| 夜夜嗨av一区二区三区中文字幕| 久久se精品一区精品二区| 亚洲视频在线播放| 欧美精品aa| 欧美激情一区二区三区在线视频观看| 国产精品午夜久久| 亚洲视频福利| 亚洲午夜精品福利| 欧美激情精品久久久| 老司机亚洲精品| 狠狠狠色丁香婷婷综合激情| 亚洲欧美日韩国产成人| 亚洲少妇诱惑| 欧美天天影院| 99精品视频网| 中文精品99久久国产香蕉| 欧美国产三级| 亚洲激情女人| 夜色激情一区二区| 欧美日韩国产黄| 亚洲日本电影| 国产精品99久久久久久宅男| 欧美精品七区| av72成人在线| 午夜视频一区| 国产午夜精品久久久| 久久超碰97中文字幕| 另类亚洲自拍| 亚洲国产美女久久久久| 免费在线观看一区二区| 亚洲黄色精品| 亚洲天堂成人在线观看| 国产精品国内视频| 亚洲综合电影一区二区三区| 久久久91精品国产一区二区精品| 国产亚洲精品久久久| 快播亚洲色图| 亚洲精品影视| 欧美一区二区三区成人| 国语精品中文字幕| 欧美wwwwww| 在线一区二区视频| 久久久青草婷婷精品综合日韩| 在线观看日韩av电影| 欧美精彩视频一区二区三区| 99视频一区二区三区| 欧美在线观看视频一区二区| 在线观看亚洲专区| 欧美日韩天堂| 欧美一区二区三区视频| 欧美国产日本在线| 亚洲欧美日韩久久精品| 极品日韩av| 欧美性猛交一区二区三区精品| 午夜精品美女自拍福到在线 | 一本色道久久综合亚洲二区三区| 国产精品成人在线| 久久久久久穴| 亚洲深夜福利在线| 欧美激情精品久久久久久蜜臀 | 亚洲尤物精选| 精品二区视频| 国产精品国产三级国产专播精品人| 欧美一级午夜免费电影| 亚洲欧洲一二三| 久久精品视频在线| 99亚洲精品| 一区二区三区中文在线观看| 欧美日韩免费一区二区三区视频| 欧美一区二区三区免费在线看| 91久久久国产精品| 久久综合色播五月| 亚洲一区二区三区视频| 亚洲东热激情| 国产欧美精品久久| 欧美日韩在线视频观看| 久久资源在线| 欧美一区二区精品| 99天天综合性| 亚洲国产日韩欧美在线99| 久久免费精品视频| 欧美影院在线| 亚洲综合社区| 中文日韩在线视频| 最新高清无码专区| 亚洲国产精品一区二区第一页| 国产精品萝li| 国产精品免费网站在线观看| 欧美日韩一区二区三区在线| 欧美激情一区三区| 免费观看久久久4p| 久久综合伊人77777尤物| 久久精品国产精品亚洲综合| 亚洲欧美国产日韩中文字幕| 亚洲性av在线| 亚洲午夜精品久久久久久app| 999在线观看精品免费不卡网站| 欧美激情一级片一区二区| 免费观看成人www动漫视频| 久久久久久**毛片大全| 久久九九有精品国产23| 久久国产一区二区三区| 欧美一区在线直播| 久久婷婷av| 国产精品午夜国产小视频| 欧美日本精品在线| 欧美精品色一区二区三区| 免费观看一级特黄欧美大片| 免费观看在线综合色| 欧美国产精品日韩| 欧美日韩免费高清| 欧美日韩一区二区三区在线观看免| 欧美日韩精品一区二区在线播放| 欧美紧缚bdsm在线视频| 欧美日韩亚洲91| 欧美成人综合网站| 欧美日韩亚洲一区三区| 国产精品毛片高清在线完整版| 国产精品永久免费在线| 激情综合色丁香一区二区| 91久久黄色| 亚洲深夜福利网站| 久久成人18免费观看| 六月婷婷久久| 99视频在线精品国自产拍免费观看| 在线视频亚洲欧美| 欧美一区视频在线| 免费成人av| 国产精品啊v在线| 免费观看不卡av| 欧美电影电视剧在线观看| 亚洲国产日韩欧美一区二区三区| 亚洲精选中文字幕| 性欧美大战久久久久久久免费观看| 久久久久国产成人精品亚洲午夜| 欧美激情中文字幕一区二区| 欧美图区在线视频| 亚洲成人在线视频播放| 亚洲一区二区三区涩| 久久综合亚洲社区| 99精品热视频| 久久在线播放| 欧美激情精品久久久六区热门| 欧美大片免费观看| 国产精品影院在线观看| 亚洲激情图片小说视频| 翔田千里一区二区| 亚洲国产免费| 欧美呦呦网站| 欧美视频一区二区在线观看| 一区二区三区在线免费播放|