Linux C / C ++用户空间中的定时器信号处理程序 [英] Linux C/C++ Timer signal handler in userspace

查看:390
本文介绍了Linux C / C ++用户空间中的定时器信号处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个函数(例如信号处理程序)在C / C ++ linux,每n毫秒激活。如何设置信号等...以毫秒分辨率注册到定时器事件。



准确度不是超级关键,但需要在几百毫秒左右。

解决方案

setitimer(2)是一个好的开始,但你真的想要与信号异步吗?否则,你可以有一个主循环 select(2) poll(2)和适当的超时。 / p>

I need a function(eg signal handler) in C/C++ linux that gets activated every 'n' milliseconds. How do I setup signals etc...to register to timer events at the millisecond resolution.

Accuracy is not super critical, but need within hundred ms or so.

I am new to linux and I really don't know where to start.

解决方案

setitimer(2) is a good start, but do you really want to go asynchronous with signals? Otherwise, you could have a main loop with select(2) or poll(2) and an appropiate timeout.

这篇关于Linux C / C ++用户空间中的定时器信号处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆