Re: epoll_wait() - Honor Order of Specification of fds to epoll_ctl()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Network Nut <sillystack@xxxxxxxxx> wrote:
> I believe that epoll_wait should guarantee that it will yield the triggered
> fd's in the order in which they were specified to epoll_ctl. 

That would require reworking/redesigning the internal data structures of
epoll to preserve order.  It would very likely penalize the performance
for existing users who do not care about ordering (outside of order in
which events fire).

> Just yesterday, I had a situation where I needed this guarantee. I had four
> queues that are annotated with semaphores. I intended to use epoll_wait to
> wait on the semaphores, in addition to several other fd's. When my thread
> unblocks, I need two of the semaphores to take priority over the other two.
> Normally, I would specify those two fd's first in my array to epoll_ctl.

Use poll on the high prio FD(s) and epoll_fd instead, then only use
epoll_wait with a timeout of zero seconds.  Something like this
(in pseudocode, my C brain isn't working well)

	pollset = { high_prio_fd => POLLIN, epoll_fd => POLLIN }
	poll(pollset, pollset.size, timeout=-1)
	if pollset.include?(high_prio_fd)
		<< high priority stuff >>
	elsif pollset.include?(epoll_fd)
		epoll_wait(epoll_fd, ..., timeout=0)
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux