简体   繁体   中英

epoll_wait blocks for longer then timeout

My application waits in epoll_wait much longer then I specified in timeout:

22578 09:33:46.959791 epoll_wait(5,  <unfinished ...>
22578 09:33:50.010794 <... epoll_wait resumed> [], 128, 1498) = 0
...
22034 09:35:07.686896 epoll_wait(5,  <unfinished ...>
22034 09:35:09.482526 <... epoll_wait resumed> [{EPOLLIN, {u32=151458248, u64=151458248}}], 128, 362) = 1
...
22036 09:35:41.433241 epoll_wait(5,  <unfinished ...>
22036 09:35:43.176881 <... epoll_wait resumed> [], 128, 97) = 0

I have asked to timeout for one value, but timing shows that it waits for much longer interval.

Time from logs is reliable - I got it from strace output. What can I do to make timeout in epoll more fine grained? And why epoll_wait is SO MUCH inaccurate?

The documentation says:

Note that the timeout interval will be rounded up to the system clock granularity, and kernel scheduling delays mean that the blocking interval may overrun by a small amount.

In other words, the timeout is a minimum value.

But such large delays do not happen when the machine is idle. If you have real-time constraints, ensure that your code can actually run, ie, set the appropriate scheduling policy, prevent it from being swapped out, etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM