linux 应用程序实现毫秒级延时的实现
include <stdio.h>#include <sys/select.h>static void sleep_ms(unsigned int secs){struct timeval tval;tval.tv_sec=secs/1000;tval.tv_usec=(secs*1000)%1000000;select(0,NULL,NULL,NULL...
·
include <stdio.h>
#include <sys/select.h>
static void sleep_ms(unsigned int secs)
{
struct timeval tval;
tval.tv_sec=secs/1000;
tval.tv_usec=(secs*1000)%1000000;
select(0,NULL,NULL,NULL,&tval);
}
比如说延时0.2s
sleep_ms(200)
更多推荐
已为社区贡献5条内容
所有评论(0)