46

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

2 Answers 2

66

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.

13

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.)

3
  • 11
    This is wrong: " A level-triggered event means that when the voltage reaches a particular level". "reaching a voltage" is the definition of edge-triggered. A level-triggered event checks whether the voltage is above a threshold, right now, without any regard for history. There's no such thing as "(rising) level-triggered events".
    – Ben Voigt
    Commented Aug 2, 2014 at 18:24
  • I'd like to see these opposing definitions reconciled please
    – Snorex
    Commented Mar 12, 2017 at 2:42
  • I don't think this objectively answers the question. The answer is only about electronics, the question is about OS system calls. The first might (or not) have influenced the naming used in the latter, but the question was not from where the name came from. Commented Aug 28, 2022 at 21:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.