Ask Your Question
0

How to bind a node to a specific cpu core?

asked 2015-02-09 00:25:39 -0600

ZiyangLI gravatar image

Dear all,

I am tyring to run a node with a specific cpu core but have no idea how to do that.

What's more, I also want to specify the cpu core of callback functions. I know I can use asynchronous spinner to control the number of threads, but it seems there is no way to manually set which core the thread uses.

Look forward to any help!

Ziyang

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2015-02-09 01:37:48 -0600

gvdhoorn gravatar image

updated 2015-02-09 01:46:19 -0600

Without being able to get access to the underlying threads, I think it will be difficult (impossible) to do for individual threads, but for entire processes this should be doable using taskset and a launch-prefix (taskset is from the util-linux package on Debian/Ubuntu).

Something like launch-prefix="taskset -c 1" added to a node element in a launch file should work (I haven't tested it though). That binds the node to cpu 2.

Note that according to man/1/taskset, your user needs to have CAP_SYS_NICE.

Note also that the taskset approach is not ROS specific. The launch-prefix is ROS specific (see roslaunch/XML/node - Attributes).

Final note: the fact that you've bound task X to cpu Y does not mean that other tasks cannot be run on cpu Y, obviously.

edit flag offensive delete link more
2

answered 2015-02-09 02:22:50 -0600

See also the RT-PREEMPT Wiki on the Cpuset management utility which would be helpful if you're really serious about explicitly specifying what runs on which core. It should be noted that a plain Linux Kernel and plain ROS are probably not the right toosl for the job if you're looking for short deadlines and hard real-time guarantees, however.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-02-09 00:25:39 -0600

Seen: 2,158 times

Last updated: Feb 09 '15