zoukankan      html  css  js  c++  java
  • epoll ET & LT

    COPY FROM : Stackoverflow

    When an FD becomes read or write ready, you might not want necessarily want to read (or write) all the data immediately.

    Level-triggered epoll will keep nagging you as long as the FD remains ready, whereas edge-triggered won't bother you again until the next time you get an EAGAIN (so it's more complicated to code around, but can be more efficient depending on what you need to do).

    Say you're writing from a resource to an FD. If you register your interest for that FD becoming write ready as level-triggered, you'll get constant notification that the FD is still ready for writing. If the resource isn't yet available, that's a waste of a wake-up, because you can't write any more anyway.

    If you were to add it as edge-triggered instead, you'd get notification that the FD was write ready once, then when the other resource becomes ready you write as much as you can. Then if write(2) returns EAGAIN, you stop writing and wait for the next notification.

    The same applies for reading, because you might not want to pull all the data into user-space before you're ready to do whatever you want to do with it (thus having to buffer it, etc etc). With edge-triggered epoll you get told when it's ready to read, and then can remember that and do the actual reading "as and when".

  • 相关阅读:
    eclipse安装Aptana 插件,支持Javascript
    C++字符串转换成uint64类型
    C语言字节对齐
    Windows版本Traceroute
    ubuntu下使用FireBug调试Javascript脚本
    TCP拥塞控制图
    nodejs点滴
    你应该知道的16个Linux服务器监控命令
    C语言运算符(转载)
    常用正则表达式
  • 原文地址:https://www.cnblogs.com/dpsincs/p/3629275.html
Copyright © 2011-2022 走看看