Book Image

Mastering Python High Performance

Book Image

Mastering Python High Performance

Overview of this book

Table of Contents (15 chapters)

Parallelism versus concurrency


These two terms are often used together and even interchangeably, but they are technically two different things. On one side, we have parallelism, which happens when two or more processes can run at the exact same time. This can happen, for instance, in multicore systems, where each process runs on a different processor.

On the other hand, concurrency happens when two or more processes try to run at the same time on top of the same processor. This is usually solved by techniques such as time slicing. However, these techniques do not execute in a truly parallel fashion. It just looks parallel to observers because of the speed at which the processor switches between tasks.

The following diagram tries to illustrate this:

Concurrency, for instance, is a technique used by all modern operating systems. This is because irrespective of the number of processors a computer has, the system alone will probably need to have more processes running at the same time, let alone...