Home arrow BrainDump arrow Page 4 - Linux Files and the Event Poll Interface

Edge- Versus Level-Triggered Events - BrainDump

In this second part of a seven-part series on Linux I/O file system calls, you will learn about the event poll interface. This article is excerpted from chapter four of the book Linux System Programming: Talking Directly to the Kernel and C Library, written by Robert Love (O'Reilly, 2007; ISBN: 0596009585). Copyright 2007 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.

TABLE OF CONTENTS:
  1. Linux Files and the Event Poll Interface
  2. Controlling Epoll
  3. Waiting for Events with Epoll
  4. Edge- Versus Level-Triggered Events
By: O'Reilly Media
Rating: starstarstarstarstar / 7
December 04, 2008

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

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:

  1. The producer writes 1 KB of data onto a pipe.
  2. The consumer performs anepoll_wait()on the pipe, waiting for the pipe to contain data, and thus be readable.

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.

The terminology comes from electrical engineering. A level-triggered interrupt is issued whenever a line is asserted. An edge-triggered interrupt is caused only during the rising or falling edge of the change in assertion. Level-triggered interrupts are useful when the state of the event (the asserted line) is of interest. Edge-triggered interrupts are useful when the event itself (the line being asserted) is of interest.

Please check back next week for the continuation of this article



 
 
>>> More BrainDump Articles          >>> More By O'Reilly Media
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

BRAINDUMP ARTICLES

- Apple Founder Steve Jobs Dies
- Steve Jobs` Era at Apple Ends
- Google's Chrome Developer Tool Updated
- Google's Chrome 6 Browser Brings Speed to th...
- New Open Source Update Fedora 13 is Released...
- Install Linux with Knoppix
- iPad Developers Flock To SDK 3.2
- Managing a Linux Wireless Access Point
- Maintaining a Linux Wireless Access Point
- Securing a Linux Wireless Access Point
- Configuring a Linux Wireless Access Point
- Building a Linux Wireless Access Point
- Migrating Oracle to PostgreSQL with Enterpri...
- Demystifying SELinux on Kernel 2.6
- Yahoo and Microsoft Create Ad Partnership

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: