(I wouldn't call it realtime priority, but ..)
I haven't done it myself, but you can probably use roslaunch
's launch-prefix
together with the Linux nice
utility to start a node at a higher nice value.
Something like launch-prefix="nice -n N"
(where N
is the nice value).
See How to bind a node to a specific cpu core? for a related Q&A.
See roslaunch/XML/node - Attributes for more info on launch-prefix
.
Edit: as mentioned in the comments, using nice
to increase priority of a process (ie: use negative values) requires sudo
. But roslaunch
doesn't play nice with sudo
as a launch-prefix
due to the password prompt.
Configuring passwordless sudo
just for nice
and a specific user could be an option here.
An alternative could be to configure the ulimit
s for nice
for a specific user, as explained in How can I allow a user to prioritize a process to negative niceness? on SE.
To avoid a link-only answer, here is a quote:
The pam_limits.so module can help you there.
It allows you to set certain limits on specific individual users and groups or wildcards or ranges of users and groups.
The limits you can set are typically ulimit settings but also on the number of concurrent login sessions, processes, CPU time, default priority and maximum priority (renice). Check the limits.conf man page for more.
For example you can configure your mindcraft group to have all their processes started with an increased default priority and you can allow them to use the nice and renice commands to increase the priority of their important jobs manually as well instead of only reducing priority.
# /etc/security/limits.conf
# increase default and max prio for members of the mindcraft group
@mindcraft hard priority -10
@mindcraft hard nice -18
Relevant comment from that answer:
I've worked it out! It was using hard
that caused the problems. I changed it to -
instead and all works fine now. This answer helped me get to the bottom of it. I think the problem was that I had a soft limit that was getting in the way, perhaps overriding the hard limit somehow. Anyway, -
instead of hard
fixed it