首页 技术 正文
技术 2022年11月15日
0 收藏 933 点赞 3,121 浏览 618 个字

函数名: sleep
头文件: #include<windows.h> // 在VC中使用带上头文件
              #include<unistd.h>    // 在gcc编译器中,使用的头文件因gcc版本的不同而不同
功  能: 执行挂起指定的秒数
语  法: unsigned sleep(unsigned seconds);

#include<stdio.h>
#include<stdlib.h>
#include<time.h>int main()
{
int a;
a=1;
printf("hello");
sleep(a); /* VC 使用Sleep*/
printf("world");
return 0;
}

  

函数名: usleep
头文件: #include <unistd.h>
功 能: usleep功能把进程挂起一段时间, 单位是微秒(百万分之一秒);
语 法: void usleep(int micro_seconds);
返回值: 无
内容说明:本函数可暂时使程序停止执行。参数 micro_seconds 为要暂停的微秒数(us)。

注 意:
这个函数不能工作在windows 操作系统中。用在Linux的测试环境下面。
参 见:usleep() 与sleep()类似,用于延迟挂起进程。进程被挂起放到reday queue。
在一般情况下,延迟时间数量级是秒的时候,尽可能使用sleep()函数。
如果延迟时间为几十毫秒(1ms = 1000us),或者更小,尽可能使用usleep()函数。这样才能最佳的利用CPU时间

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,944
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,469
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,283
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,099
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,729
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,766