ºìÁªLinuxÃÅ»§
Linux°ïÖú

¹ØÓÚÈ¡ÄÚºËÖÐij¶Î´úÂëµÄÖ´ÐÐʱ¼ä

·¢²¼Ê±¼ä:2009-10-02 16:05:21À´Ô´:ºìÁª×÷Õß:jipingwt
ÎÒÔÚ2.6.22ÏÂͨ¹ýÐÞ¸Äϵͳµ÷ÓÃread()¡¢write()¶ÔÓ¦µÄ×îÍâ²ãÄں˺¯Êýsys_read()ºÍsys_write()À©Õ¹Á˶Á/дµÄ¹¦ÄÜ£¬ÏÖÔÚÏë²âÒ»ÏÂÒòÀ©Õ¹¹¦Äܶø´øÀ´µÄ¶îÍâʱ¼äËðºÄ¡£
ÎÒµÄÏë·¨ÊÇÔÚ¹¦ÄÜ´úÂëµÄÆðʼʱ¿ÌÈ¡µ±Ç°Ê±¼ä£¬½áÊøʱ¿ÌÔÙÈ¡£¬È»ºóÇó²îÖµ£¬ÀÛ¼Ó¡£²ÉÈ¡µÄ·½·¨ÊÇ£º
unsigned long starttime£¬finishtime;
startime=jiffies/HZ£» //¿ªÊ¼Ê±¿ÌÈ¡µ±Ç°Ê±¼ä
finishtime=jiffies/HZ; //½áÊøʱ¿ÌÈ¡µ±Ç°Ê±¼ä
printk ("syc_seconds = %d\nNow totaluse=%d", finishtime-starttime£¬totalsystime);
£¨totalsystime±äÁ¿·ÅÔÚº¯ÊýÍâÃæ³ÉΪȫ¾Ö±äÁ¿£©
µ«ÊÇ£¬²ÉÓÃÕâÖÖ·½·¨¼Ç¼ÏÂÀ´µÄʱ¼äÒ»Ö±ÊÇ0¡£
ÊDz»ÊÇÎÒµÄÏë·¨ÓÐÎÊÌâ°¡£¿ÔÚÄÚºËÖÐÓ¦¸ÃÔõÑùȡij¸öʱ¿ÌµÄµ±Ç°Ê±¼äºÍ¼Ç¼һ¶Î´úÂëµÄÖ´ÐÐʱ¼äÄØ£¿
Íû¸ßÊÖ½â¾ö£¬²»Éõ¸Ðл£¡
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 3 ÌõÆÀÂÛ

  1. jipingwt ÓÚ 2009-10-03 09:52:58·¢±í:

    2# zha2530

    ÄãºÃ£¡ÎÒ¾ÍÊǾ­¹ý±àÒë¹ýºó½øÐвâÊԵģ¬ºÜÆæ¹Ö£¬Ò»Ö±Îª0¡£

  2. gsm1011 ÓÚ 2009-10-02 22:35:38·¢±í:

    ÎÒÈÏΪӦ¸Ã¿ÉÒÔÓк¯Êýµ÷Óõõ½Ê±¼ä£¬È»ºóÏà¼õ¾Í¿ÉÒÔÁË¡£ ¿ÉÒԲο¼sys/time.hÎļþ¡£

  3. zha2530 ÓÚ 2009-10-02 20:19:59·¢±í:

    ¾­¹ý±àÒëÆ÷±àÒëÖ®ºó£¬¾Í²»ÊÇÄãÏëµÄÄÇô»ØÊÂÁË