My computer has 6 cores. I have to run 12 processes. Each process takes exactly 10 minutes.

I want to consider (for the sake of the argument only) two scenarios:

  1. I run 2 processes successively on each core. It should take 20 minutes to finish.

  2. I open 12 terminal windows and I am running all 12 processes independently. Each core will therefore need to switch back and forth between the different processes to give us a feeling that the 12 processes are parallelized.


Does it matter? Does it make a big difference?

My basic thoughts

I would expect that the second solution would take a bit more time as it would need some time for the cores to jump back and forth to the different processes. However, there are many other small processes going on the computer in the meantime run by root for example. I'd expect the second scenario to take a little bit more time but that would be pretty negligible. I made a try and didn't notice any difference but my processes were maybe too short to notice anything.


The difference is probably going to be negligible. Option 1 could be faster due to less CPU context switching, but other factors will come into play too.

As you observe yourself, the problem is that your OS has hundreds of threads running concurrently already so the CPU will be context-switching anyway. Which probably makes Option 1 no better than Option 2.

HOWEVER if your processes are utilizing some kind of shared resource, such as CPU Cache, RAM, HDD, Network, you might find that concurrent use (or context switching) of those resources makes a massive difference. In which case successive execution might help a lot.

In the end, test both and go with what works best for you :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.