2012-03-06 53 views
1

我在想epoll的两个API的参数。epoll_create和epoll_wait

  1. epoll_create(int size) - 在此API中,size被定义为事件池的大小。但是,似乎有更多的事件比尺寸仍然有效。 (我把尺寸设置为2,并强制事件池有3个事件...但它仍然有效!?)因此,我想知道这个参数实际上意味着什么,并且对这个参数的最大值感到好奇。

  2. epoll_wait(int maxevents) - 对于此API,maxevents定义非常简单。但是,我可以看到缺乏关于如何确定此参数的信息或建议。我希望这个参数可以根据epoll事件池的大小来改变。任何建议或意见将是伟大的。谢谢!

回答

0

“人epoll_create”

 
DESCRIPTION 
     ... 
     The size is not the maximum size of the backing store but just a hint 
     to the kernel about how to dimension internal structures. (Nowadays, 
     size is unused; see NOTES below.) 

NOTES 
     Since Linux 2.6.8, the size argument is unused, but must be greater 
     than zero. (The kernel dynamically sizes the required data struc‐ 
     tures without needing this initial hint.) 

2.

自己只是确定一个准确的数字,但是要注意, 给它一个少数可能会下降稍微提高效率。

因为分配给“maxevent”的数字越小,您可能就越需要调用epoll_wait()来消耗所有已在epoll上排队的事件。

相关问题