一、系统调用select,把原来当前进程的单睡眠等待状态变成了现在的多睡眠等待状态。具体请看代码,select在内核中的实现为sys_select,代码如下:asmlinkage long
sys_select(int n, fd_set *inp, fd_set *outp, fd_set *exp, struct timeval *tvp)//inp,outp,exp是关于已打开文件的位图,t...
分类:
系统相关 时间:
2015-05-08 09:30:16
阅读次数:
149
Linux select 机制深入分析
作为IO复用的实现方式,select是提高了抽象和batch处理的级别,不是传统方式那样阻塞在真正IO读写的系统调用上,而是阻塞在select系统调用上,等待我们关注的描述符就绪。当然现在更好的方式是epoll,比如Java中的NIO底层就是用的epoll。这篇文章只是为了搞懂select机制的原理,不看源码就不能说懂这些IO复用手...
分类:
系统相关 时间:
2015-03-20 14:29:27
阅读次数:
220
头文件:/*AccordingtoPOSIX.1-2001*/
#include<sys/select.h>
/*Accordingtoearlierstandards*/
#include<sys/time.h>
#include<sys/types.h>
#include<unistd.h>接口:intselect(intnfds,fd_set*readfds,fd_set*writefds,
fd_set*exceptfds,structti..
分类:
系统相关 时间:
2015-03-05 17:23:38
阅读次数:
238
1 #!Nonblocking I/O - Chapter 5 -pollclient.py 2 import socket,sys,select 3 port=51423 4 host='localhost' 5 6 spinsize=10 7 spinpos=0 8 spindir=1 9 .....
分类:
编程语言 时间:
2014-11-05 18:50:36
阅读次数:
263
1. Select源码解析
基于2.6.28内核代码,select主要包含4个函数。
sys_select:处理时间参数,然后调用core_sys_select。
core_sys_select:处理三个fd_set参数(in, out, ex),然后调用do_select。
do_select:遍历所有的fd,做select/poll的工作。在合适的时机把...
分类:
其他好文 时间:
2014-09-19 01:12:44
阅读次数:
192