If the EPOLLET value is set in the eventsfield of theeventparameter passed toepoll_ctl(), the watch onfdis edge-triggered, as opposed to level-triggered. Consider the following events between a producer and a consumer communicating over a Unix pipe:
With a level-triggered watch, the call toepoll_wait()in step 2 will return immediately, showing that the pipe is ready to read. With an edge-triggered watch, this call will not return until after step 1 occurs. That is, even if the pipe is readable at the invocation ofepoll_wait(), the call will not return until the data is written onto the pipe. Level-triggered is the default behavior. It is howpoll()andselect()behave, and it is what most developers expect. Edge-triggered behavior requires a different approach to programming, commonly utilizing nonblocking I/O, and careful checking forEAGAIN.
Please check back next week for the continuation of this article
blog comments powered by Disqus |