• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

MarkGrid

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

关于select/poll/epoll的特点和区别

select 每次都是轮询,而且每次都要重新加入到fd_set中,即会清空fd_set
  int select(int nfds, fd_set* readfds, fd_set* writefds, fd_set* errorfds, struct timeval* timeout);
poll    每次都是轮询,但不需要再加入到fd_set中,即不会清空fd_set
  int poll(struct pollfd fds[], nfds_t nfds, int timeout);
epoll  不是轮询,分为电平触发和边缘触发
          电平触发(缺省):当通知过某个fd,就算不做了任何操作,下次还会继续通知,传统的select/poll都是这种模型的代表
          边缘触发(高速工作方式):当通知过某个fd时,下次不会通知了,直到做了某些操作导致那个文件描述符不再为就绪状态了
  int epoll_create(int size);
  int epoll_ctl(int epfd,int op,int fd,struct epoll_event *event);
  int epoll_wait(int epfd,struct epoll_event *events,int maxevents,int timeout);
 
更具体的描述请阅读:http://www.cnblogs.com/aga-j/archive/2011/08/26/2153943.html
 
参考:
  http://zh.wikipedia.org/wiki/Select_(Unix)
  http://zh.wikipedia.org/wiki/Epoll
 
  http://baike.baidu.com/view/569212.htm
  http://baike.baidu.com/view/2997591.htm
  http://baike.baidu.com/view/1385104.htm

posted on 2013-06-16 22:16  MarkGrid  阅读(350)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3