0

I was wondering whether there is - at least under Linux - a system call that watches a set of file descriptors and first "serves" the first file descriptor that got ready for operation.

I have been working with select and I do not expect that select enforces a kind of FirstComeFirstServed policy on the descriptors that watches, because its implementation should be a slight variation on polling.

Maybe I am asking for an event-driven handler, but I do not know anything about epoll beyond its mere existence.

Thanks

ziu
  • 2,634
  • 2
  • 24
  • 39

1 Answers1

1

All event demultiplexers (select/poll/epoll) signal all the FDs which need attention at that moment (based on the watch sets you provided), there's no difference, except that epoll can also be used in an edge-triggered way.

At any moment the result set can contain multiple FDs (without any additional ordering) as you're running on a multitasking OS, so by the time your process gets scheduled multiple events could have happened. Note: running an RT (Real-Time) kernel with your process set to high or realtime priority might help...

Karoly Horvath
  • 94,607
  • 11
  • 117
  • 176
  • When I have several FDs ready, the "servicing" order is then dependent on the FDs' order in the watch set. Am I right ? – ziu May 10 '12 at 11:44
  • There is no order in the watch set. It's a **set**, in the mathematical sense of the word. In the result there is **no** order either... you decide which FDs to serve first. – Karoly Horvath May 10 '12 at 11:46
  • Thus I assume there is no enforcing of FCFS when multiple descriptors happen to be ready (because of scheduling and etc). – ziu May 10 '12 at 12:36