Run a program on one CPU core in Linux

Modern computers use CPUs with multiple cores for performance reasons. Software can take advantage of that and use both cores to run separate threads but sometimes it’s useful if you can force a process to use one core rather than both.

In Linux that’s easy to do. If you’re using Ubuntu or Debian grab the schedutils package:

sudo apititude install schedutils

That will install a program called “taskset” which is a tool to “retrieve or set a process’s CPU affinity”. It’s really easy to use too.

I wanted to force Bibblelabs on to one core while importing photos.

# ps auxw|grep bibble
donncha 19482 78.7 33.1 1090388 681220 ? RNl 09:56 77:28 ./bibblepro
# taskset -p 19482
pid 19482’s current affinity mask: 3
# taskset -p 01 19482
pid 19482’s current affinity mask: 3
pid 19482’s new affinity mask: 1

The app is still heavy on the system, and “System Monitor” doesn’t suddenly show 0% usage on one CPU because I’m also running Firefox, Xchat, X, Gnome Terminal but I’d almost swear the browser window refreshes faster.

PS. Thanks to whoever told me about this on Twitter a while back. It had slipped my mind and I had to search for it again. Blogging it to remember it!

4 thoughts on “Run a program on one CPU core in Linux

  1. I reniced it too but Bibble is just too hungry for resources. Actually I gave up on it and started using the Macbook while it’s importing. I do have rather a lot of images for some reason.. *snap* *snap*

Leave a Reply

%d bloggers like this:

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close