tags:

views:

164

answers:

2

What does it mean for some network event mechanism (i.e. epoll/poll/select) to be edge or level triggered?

+5  A: 

The short answer is, edge-triggered means that you get notified only when the event is detected (which takes place, conceptually, in an instant), while level-triggered means you get notified whenever the event is present (which will be true over a period of time). For example, in an edge-triggered system, if you want a notification to signal you when data is available to read, you'll only get that notification when data was not available to read before, but now it is. If you read some of the available data (so that remaining data is still available to read) you would not get another notification, and if you read all of the available data, then you would get another notification when data became available to read again. In a level-triggered system, you'd get that notification whenever data is available to read.

Aidan Cully
A: 

In electronics, it is the difference between spotting that voltage is changing and that the voltage has reached a specific level. In ASCII art:

                ------------     ---     ----
               / <---(2)    \   /   \   /    \
              /              \-/     \-/      \
             /                                 \
            /   <---(1)                         \
           /                                     \     /\
          /                                       \   /  \
----------                                         ---    ----

An edge-triggered event means that the event is triggered when the voltage (or whatever) is spotted rising, which might be at the time marked (1). A level-triggered event means that when the voltage reaches a particular level, the event is triggered - for example, at the time marked (2). However, in a noisy environment, level-triggered events mean that there would be two more (rising) level-triggered events in the trace, though no more (rising) edge-triggered events. Thus, edge-triggered events tend to be more stable than level-triggered events. (And an edge-triggered event is not simply a lower voltage level - there are limits to ASCII art.)

Jonathan Leffler