timer_create(): -1 EAGAIN(资源暂时不可用)
timer_create() : -1 EAGAIN (Resource temporarily unavailable)
我在运行ARM的嵌入式Linux下创建计时器遇到了麻烦。我使用自制的c++库来管理计时器。我没有自己编写代码,尽管我可以访问源代码,但我对实现并不了解……它工作了一段时间,然后我得到了错误"EAGAIN"。
使用strace我注意到,当它不工作的定时器ID是安静的高!
timer_create(CLOCK_MONOTONIC, {0, SIGRT_3, SIGEV_SIGNAL, {...}}, 0xbed50af4) = -1 EAGAIN (Resource temporarily unavailable)
看到相当低的定时器ID时,它的工作:
timer_create(CLOCK_MONOTONIC, {0x3, SIGRT_3, SIGEV_SIGNAL, {...}}, {0x3d}) = 0
我以为定时器的数量是无限的!真的不是吗?我们应该在完成任务后销毁计时器吗?我还使用了"timer_stats"内核实用程序,但这对我没有多大帮助……内核内是否有其他计时器调试工具或其他工具?
谢谢你的帮助!
您猜对了,您确实有定时器的最大数目:
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() 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)
限制(bash(1)
中的ulimit -i
),但要注意,这会分配真正的内核内存——这是一种极其有限的资源。
我建议修改您的应用程序以删除或重新使用旧的计时器。
相关文章:
- 具有瞬态资源的RAII类
- C++ 雷神库 - 使用资源加载器类时出现问题(不命名类型)
- 允许从 std::map 的密钥窃取资源?
- 参考资源文件VC++中的$(SolutionDir)
- 如何维护资源管理器项目视图中当前可见的项目列表
- 将 std::allocate_shared 与多态资源分配器一起使用
- 使用RAII在给定次数的迭代后重新分配资源
- 资源管理设计模式
- 如何跨平台将二进制资源构建到程序中?
- Using C++ CryptAPI:CNG Create CSR
- SetDlgItemInt 不会更改嵌入资源的编辑框
- Klocwork Inside的资源泄漏
- 从存储为 Windows 资源 (c++) 的 png 中获取 png 文件数据
- 错误:(-210:不支持的格式或格式组合)功能'create'中的硬件视频解码器不支持视频源
- C++链接时间资源"allocation"而不定义
- 使用 Bazel 生成 QT 资源文件
- 编译器资源管理器和 GCC 具有不同的输出
- 使用 Bazel 编译 QT 应用程序时访问资源
- 根据需要声明资源,而不重复它们
- meson-build:wxWidgets 资源文件,用于 Windows 未构建