Linux中的延時函數

應用層:
   #include <unistd.h>

 

1、unsigned int sleep(unsigned int seconds); 秒級


   2、int usleep(useconds_t usec);              微秒級:1/10^-6


 
   #define _POSIX_C_SOURCE 199309


   #include <time.h>


   3、int nanosleep(const struct timespec *req, struct timespec *rem);
       struct timespec {
                  time_t tv_sec;        /* seconds */
                  long   tv_nsec;       /* nanoseconds */
              };
       // The value of the nanoseconds field must be in the range 0 to 999999999.


 
 內核層:
   include <linux/delay.h>
   1、void ndelay(unsigned long nsecs);         納秒級:1/10^-10
   2、void udelay(unsigned long usecs);         微秒級: 1/10^-6
   3、void mdelay(unsigned long msecs);         毫秒級:1/10^-3

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章