There are "two models for readiness notification for a file descriptor.
- Level-triggered notification: A file descriptor is considered to be ready if it is possible to perform an I/O system call without blocking.
- Edge-triggered notification: Notification is provided if there is an I/O activity (e.g., new input) on a file descriptor since it was last monitored." [1]
(As a mnemonic, think of the 'E' in edge-triggered also standing for Event).
It's interesting to note that the two are isomorphic. If you were to have edge-triggered notifications and then kept a collection of them until used, you'd have level-triggered notification. Similarly, if you observed changes in the collection of level-triggered notifications, you'd have edge-triggered notifications. [2]
Anyway, in Java, "the Selector API requires a level-triggered polling mechanism. Edge-triggered interfaces require a much tighter coupling with the I/O methods." [3]
This edge-triggering can be seen in the standard read methods of Java I/O classes that tell you if data was received if the return value is greater than zero.
[1] The Linux Programming Interface, Michael Kerrisk
[2] http://spectral.mscs.mu.edu/netbook/chapter18.html
[3] http://mail.openjdk.java.net/pipermail/nio-dev/2008-December/000329.html
No comments:
Post a Comment