[英]How to set affinity for a timer in C/C++ under Linux?
I have timer created with a function timer_create(CLOCK_REALTIME, &events, &timer)
, where timer is a unique per process timer ID (according to man). 我已经使用功能timer_create(CLOCK_REALTIME, &events, &timer)
创建了timer_create(CLOCK_REALTIME, &events, &timer)
,其中timer是每个进程的唯一计时器ID(根据man)。
Now there is sched_setaffinity
function to set affinity for a given PID. 现在有sched_setaffinity
函数来设置给定PID的亲和力。
How can I set affinity for my timer? 如何设置计时器的亲和力? Not the whole program, but only the timer thread. 不是整个程序,而是定时器线程。 I am not sure that timer ID is the same thing as PID. 我不确定计时器ID是否与PID相同。
Ok, I got the answer. 好,我知道了。
One way to do this is like that: 一种方法是这样的:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.