With a single file descriptor, Is there any performance difference between select, poll and epoll and …?

后端 未结 3 1906
花落未央
花落未央 2021-02-01 08:28

The title really says it all.

The and ... means also include pselect and ppoll..

The server project I\'m working on basically structured with multiple threads.

3条回答
  •  生来不讨喜
    2021-02-01 08:44

    If you have only a single socket, what's the point of polling in the first place? Wouldn't the best performance then be by just using blocking read/write?

    Wrt. the performance, with only a single file descriptor I don't think there is much, if any, difference between the various approaches. If you really care, I suppose you could measure, but I find it difficult that this would particularly matter for the overall performance of your program.

    Level/edge triggering. Consider you're monitoring a signal, for simplicity say some voltage in a line. Edge triggering means that something triggers when the voltage goes over or under some specific limit. Level triggering means that something is considered to be in a triggered state as long as the voltage is over/under the limit. That is, edge triggering triggers when some event happens (crossing some threshold), level triggering reflects the state of some "thing" (in this case, voltage).

    To get back to network programming, and edge triggered system might be one where you get some kind of signal when a packet is received. If you don't handle the event then the signal is lost. A level triggered system, OTOH, is something like asking "is there data waiting in the buffer for me?"; if you don't handle the event and ask again, the data will still be there waiting for you.

提交回复
热议问题