How do I split up processes among different CPU cores?

Linode Staff

I'm currently running a program that is taking up 300% of my 600% processing power, and it seems like all 6 of the CPU cores are working as one. How can I get split this up so that the processors are working individually?

1 Reply

By default, your Linode's processors work together to perform tasks. That means that while your Linode does have 6 virtual processors, they act as one to get things done. Based on the percentages you're describing, while it may look like only one processor is running internally, 3 are actually contributing to the processes at hand.

In terms of what you're looking to do (separating tasks onto different processors), there are a couple different ways to go about it.

Method #1: Using a Multithreaded Application

A multithreaded application is one that is coded to run on multiple processors simultaneously and is designed to take advantage of a multi-core CPU, whereas a single threaded application is designed to run as a single program utilizing multiple processors. A single-threaded program is not designed to use multiple cores concurrently; meaning, your program would need to be coded as a multithreaded application to acheive this.

More on multithreaded applications here:

Multithreading and multicore differences

What is a multithreaded application?

Multithreading (computer architecture)

Method #2: CPU Affinity

This may be the route to go depending on your use case. Adjusting your CPU affinity essentially allows you to limit or assign specific processes to specific processors.

It looks like there are a couple ways to set this up, but based on my research, using the taskset utility seems like the easiest method. This allows you to adjust something called the "affinity mask" of a process and assign it to run on specific CPU cores. Once you've found the PID (process ID) of a running task (the top command will show you the top running tasks on your server), you can use taskset to assign that process to specific cores:

taskset -p <CORELIST> <PID>

This private blog post has a great breakdown of this:

How to set processor affinity on Linux using taskset

And these articles also have some nice decriptions of how CPU Affinity works:

From Linux Journal: CPU Affinity

From HowtoForge: Linux taskset Command Tutorial for Beginners (with Examples)


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct