您的位置:首页 > 运维架构 > Linux

Linux中的延时函数

2008-06-02 17:36 211 查看
应用层:
#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


--
个人主页:www.frequenter.com.cn ,欢迎访问!谢谢!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: