select/poll原理(阻塞挂起) 正常(阻塞轮询)
来源:互联网 发布:淘宝优惠券领取app 编辑:程序博客网 时间:2024/06/07 18:24
遍历所有的fd, 如果没好(不就绪),加入(对应fd)等待队列,如果所有fd都没好(不就绪),挂起线程(schedule_timeout) 直到就绪唤醒或超时,再次遍历并退出
static int do_poll(unsigned int nfds, struct poll_list *list, struct poll_wqueues *wait, long timeout)
{int count = 0;
poll_table* pt = &wait->pt;
if (!timeout)
pt = NULL;
for (;;) {
struct poll_list *walk;
set_current_state(TASK_INTERRUPTIBLE);
walk = list;
while(walk != NULL) {
do_pollfd( walk->len, walk->entries, &pt, &count);
walk = walk->next;
}
pt = NULL;
if (count || !timeout || signal_pending(current))
break;
count = wait->error;
if (count)
break;
timeout = schedule_timeout(timeout); /* 让current挂起,不占CPU,timeout到了以后再回来运行current*/
}
__set_current_state(TASK_RUNNING);
return count;
}
- select/poll原理(阻塞挂起) 正常(阻塞轮询)
- select/poll/epoll在非阻塞IO中应用原理
- 非阻塞访问原理——poll(select)
- LINUX非阻塞访问机制POLL SELECT EPOLL原理分析
- 同步,阻塞,select/poll/epoll
- 阻塞、非阻塞、异步、同步以及select/poll和epoll
- 阻塞、非阻塞、异步、同步、I/O、select、poll、epoll
- 阻塞、非阻塞、异步、同步以及select/poll和epoll
- 阻塞、非阻塞、异步、同步以及select/poll和epoll
- 阻塞、非阻塞、异步、同步以及select/poll和epoll
- 阻塞、非阻塞、异步、同步以及select/poll和epoll
- 阻塞、非阻塞、异步、同步以及select/poll和epoll
- IO-同步异步,阻塞非阻塞,select, poll , epoll
- 阻塞、非阻塞、异步、同步以及select/poll和epoll
- 阻塞、非阻塞、异步、同步以及select/poll和epoll
- 阻塞、非阻塞、异步、同步以及select/poll和epoll
- 阻塞、非阻塞、异步、同步以及select/poll和epoll
- 阻塞、非阻塞、异步、同步以及select/poll和epoll
- ibatis传入list对象
- 重新编译视图
- 如果互联网从今天开始创建
- 常用连接操作数据库的DB类
- 多文件中定义函数:重编译问题
- select/poll原理(阻塞挂起) 正常(阻塞轮询)
- 数据科学(大数据处理)领域的大神和研究机构
- 运算符 2012-12-08 07:38pm
- c#中点击最小化时 最小化到托盘 后台运行
- Spring in Action 3 - Spring’s bean scopes
- 广播接收者(BroadcastReceiver的应用)
- ArcGIS Server配置异常及处理
- MFC中使用CUDA5.0的方法(VS2010环境)
- window 服务编写