Using Taskset for Priority Tasks
December 6, 2010
Unless you're using a really old machine or cheap netbook, almost any system you touch with Linux these days is going to be a multiprocessor system. Any server machine deployed within the past five years should have at least two CPUs, and most desktops released in the past three years have at least two cores. For a number of reasons, you might want to "pin" some tasks so they run exclusively on a single CPU or set of CPUs.
Whether you want to ensure resources for a process, ensure that a process doesn't hog all system resources or improve a process that doesn't scale well to multiple CPUs, you can use
Now Chrome will be limited to CPU 0 (0x00000001 is the "mask" for CPU 0). If you wanted to assign it to two CPUs, you would use
To see what processors a task is assigned to, try running
Is this going to speed up your system or be worth doing with all tasks? Nope. It is, however, something you can try to experiment with when you're having performance problems or having issues with a process/application causing problems with the rest of the system. I'd recommend testing it out on your desktop or test systems before attempting it in a production environment -- but with the right combination, you might be able to solve some system problems in short order.
Joe 'Zonker' Brockmeier is a freelance writer and editor with more than 10 years covering IT. Formerly the openSUSE Community Manager for Novell, Brockmeier has written for Linux Magazine, Sys Admin, Linux Pro Magazine, IBM developerWorks, Linux.com, CIO.com, Linux Weekly News, ZDNet, and many other publications. You can reach Zonker at email@example.com and follow him on Twitter.