免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3107 | 回复: 0
打印 上一主题 下一主题

usb设备描述符的POLL问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-06-28 18:55 |只看该作者 |倒序浏览
我poll几个usb fd的POLLOUT事件,结果这个事件无间隔的产生,导致死循环没有了阻塞点,CPU占用率狂飆。
到底是什么时候会产生POLLOUT事件?原来为了增大接收缓冲区,我提交了好多个接收URB,当我减少提交的URB数量的时候,CPU占用率有降低。
POLLOUT事件应该是有URB可以获取,即URB请求被应答完才产生的吧,怎么会像死循环一样不停产生?搞不懂了
  1. for(;;)
  2.     {
  3.         //libusb_get_next_timeout(NULL,&timeout);
  4.         S32 i;
  5.         if(poll(ufds,nfds,10) < 0)/*600 ms*/
  6.         {
  7.             if(errno != EINTR)
  8.             {
  9.                 MSG_ERR("poll error");
  10.             }
  11.             //continue;
  12.         }
  13.         for(i = 0;i < nfds; ++i)
  14.         {
  15.                 if (ufds[i].revents & POLLOUT) {
  16.                 /* Data may be written on device number i. */
  17.                 }
  18.                 if (ufds[i].revents & POLLHUP) {
  19.                 /* A hangup has occurred on device number i. */

  20.                 }
  21.             if (ufds[i].revents & POLLIN) {
  22.                 /* A hangup has occurred on device number i. */
  23.                 //libusb_handle_events_timeout(NULL,&timeout);
  24.                 }
  25.             libusb_handle_events_timeout(NULL,&timeout);
  26.             ufds[i].revents = 0;
  27.         }
  28.     }
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP