Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Level vs Edge Trigger Network Event Mechanisms

Tags:

c

networking

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

like image 767
Jade Avatar asked Dec 27 '09 20:12

Jade


2 Answers

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.

like image 137
Aidan Cully Avatar answered Nov 19 '22 02:11

Aidan Cully


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

like image 13
Jonathan Leffler Avatar answered Nov 19 '22 01:11

Jonathan Leffler