select timeout or -1
来源:互联网 发布:金蝶软件系统参数 编辑:程序博客网 时间:2024/05/01 21:31
位置1:
/* Polling for new connections is done every connect_int milliseconds */
COOLAPsig_parms.connect_int = 5000; /* 5 seconds */
/* Default process entry interval "select()" system call */
COOLAPsig_parms.interval.tv_usec = 500000;
@COOLAPsig_parms.interval.tv_sec = 2;
while (1) {
位置2:
/* Polling for new connections is done every connect_int milliseconds */
COOLAPsig_parms.connect_int = 5000; /* 5 seconds */
/* Default process entry interval "select()" system call */
COOLAPsig_parms.interval.tv_usec = 500000;
@COOLAPsig_parms.interval.tv_sec = 2;
/*
* Use "select" to indicate when messages have been
* received and for higher resolution timing.
*/
fdvar = COOLAPsig_parms.socketset;
retval = select(COOLAPsig_parms.numsockets,
&fdvar,
(fd_set *)0,
(fd_set *)0,
&COOLAPsig_parms.interval);
...
}
在位置设置时间,第二次timeout 变成了0
等于while(1){}
线程空转无限循环的cpu占用率是100%
空转就在拼命运行啊,process始终处于run状态,所以CPU到100%,
加了sleep(),process基本进入sleep状态,就不消耗CPU了
select()进程进入select状态,和sleep是一样的。
在位置2:几秒钟足够了,一秒钟可以进行几千万次运算了
相比其他的code,cpu微微妙就执行完了,到socket用几秒
2 if select 返回值是-1
说明fd已经关闭。
select仍在check 这个fd
- select timeout or -1
- socket 的select函数block住了不返回timeout or error!原因在这里
- 错误 V4L2CameraDevice: select timeout
- 用户登出Logout or Timeout
- CASSANDRA READ or write timeout
- java.io.IOException: read failed, socket might closed or timeout, read ret: -1
- java.io.IOException: read failed, socket might closed or timeout, read ret: -1
- android蓝牙开发read failed, socket might closed or timeout, read ret: -1
- run: read failed, socket might closed or timeout, read ret: -1
- imap_timeout Set or fetch imap timeout
- AngularJs服务-$timeout or $interval(定时器)
- select or and
- select in or jion
- timeout
- timeout
- timeout
- Timeout
- timeout
- dhcp软件安装脚本
- debian7(wheezy)之virtualbox安装与配置
- ZOJ3716 Ribbon Gymnastics(贪心)
- GridView动态添加一编辑行
- 内核编译错误提示
- select timeout or -1
- 小米2S MI2S eclipse adb连接不上手机,解决办法
- ReentrantReadWriteLock读写锁的使用
- 简单的文件系列函数,包装成类,学习文件处理中。。。。
- ResultSet需要注意的问题
- ScroolView卷轴视图
- 生产者消费者问题理解与Java实现
- 内存模型
- python 给urllib.quote的字符串格式化出现ValueError: unsupported format character