Linux中,需要准确的项目进度。调度唤醒程序 [英] Linux, need accurate program timing. Scheduler wake up program
问题描述
我有一个Linux系统,我需要在精确的时间间隔为possbile执行上运行的线程。例如。执行每毫秒。
I have a thread running on a Linux system which i need to execute in as accurate intervals as possbile. E.g. execute once every ms.
目前,这是通过与创建一个计时器完成
Currently this is done by creating a timer with
timerfd_create(CLOCK_MONOTONIC, 0)
,然后通过所需的睡眠时间在结构与
, and then passing the desired sleep time in a struct with
timerfd_settime (fd, 0, &itval, NULL);
一个阻塞读取调用这个定时器,停止线程执行和报告失去了唤醒调用执行。
A blocking read call is performed on this timer which halts thread execution and reports lost wakeup calls.
的问题是,在更高的频率,在系统启动松动期限,即使CPU使用率在10%以下。我认为,这是由于调度无法唤醒线程往往不够检查阻塞调用。是否有一个命令,我可以用它来告诉调度为只要是possble醒来以一定的间隔线程?
忙等待是一个糟糕的选择,因为该系统处理很多其他任务。
The problem is that at higher frequencies, the system starts loosing deadlines, even though CPU usage is below 10%. I think this is due to the scheduler not waking the thread often enough to check the blocking call. Is there a command i can use to tell the scheduler to wake the thread at certain intervals as far as it is possble? Busy-waiting is a bad option since the system handles many other tasks.
感谢您。
推荐答案
您需要得到RT的Linux *,然后增加你想要定期唤醒进程的RT优先级。
You need to get RT linux*, and then increase the RT priority of the process that you want to wake up at regular intervals.
其他然后,我没有看到你的code的问题,如果你的过程中不被阻塞,它应该很好地工作。
Other then that, I do not see problems in your code, and if your process is not getting blocked, it should work fine.
(*)RT Linux的 - 与一些应用实时调度补丁的操作系统
(*) RT linux - an os with some real time scheduling patches applied.
这篇关于Linux中,需要准确的项目进度。调度唤醒程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!