timer_create():-1 EAGAIN(资源暂时不可用) [英] timer_create() : -1 EAGAIN (Resource temporarily unavailable)
问题描述
我有麻烦我的嵌入式Linux上运行ARM下创建计时器。我使用的是国产C ++库来管理计时器。我没code我自己,我不知道深深的实施,尽管我有机会获得源$ C $ C ......它工作了一段时间,然后我得到了错误EAGAIN。
I'm having trouble to create timer under my embedded Linux running ARM. I'm using a home made C++ library to manage timer. I didn't code it myself, I don't know deeply the implementation despite I have access to the source code... It works for a while and then I got the error "EAGAIN".
使用strace的我注意到,当它不工作定时器ID是安静高!
Using strace I noticed that when it doesn't work the timer ID is quiet high!
timer_create(CLOCK_MONOTONIC, {0, SIGRT_3, SIGEV_SIGNAL, {...}}, 0xbed50af4) = -1 EAGAIN (Resource temporarily unavailable)
查看pretty低计时器ID时,它的工作:
See the pretty low timer ID when it's working:
timer_create(CLOCK_MONOTONIC, {0x3, SIGRT_3, SIGEV_SIGNAL, {...}}, {0x3d}) = 0
我觉得定时器的数量无限!其实呢?我们应该销毁计时器一旦我们用它做?我还使用了timer_stats内核程序,但这并没有帮助我太多...是否有内核或任何其他工具的内部定时器等实用的调试?
I thought that the number of timers was unlimited! Actually not? Should we destroy the timer once we are done with it? I also used the "timer_stats" kernel utility but this didn't help me much ... Are there other debug utility for the timers inside the kernel or any other tool?
感谢您的帮助!
推荐答案
您已经猜到了正确,你有计时器的最大数目:
You've guessed correctly, you do have a maximum number of timers:
The kernel preallocates a "queued real-time signal" for each
timer created using timer_create(). Consequently, the number
of timers is limited by the RLIMIT_SIGPENDING resource limit
(see setrlimit(2)).
的 timer_create(3posix)
手册页是有点更加直言不讳一下:
The timer_create(3posix)
manpage is a bit more blunt about it:
The timer_create() function shall fail if:
EAGAIN The system lacks sufficient signal queuing resources
to honor the request.
EAGAIN The calling process has already created all of the
timers it is allowed by this implementation.
虽然可以提高上的setrlimit挂起信号(2)
限制(的ulimit -i
在的bash(1)
),请注意,这实际分配内核内存 - 这是一个非常有限的资源
While you could raise the setrlimit(2)
limit on pending signals (ulimit -i
in bash(1)
), be aware that this allocates real kernel memory -- which is an extremely limited resource.
我建议修改应用程序进行删除或重新使用旧的定时器。
I suggest modifying your application to delete or re-use old timers.
这篇关于timer_create():-1 EAGAIN(资源暂时不可用)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!