Parallelism
Parallelism is a concept in computing where multiple tasks are executed simultaneously. This requires the presence of multiple cores or processors, which allows tasks to run at the same time. This is distinct from concurrency, which involves task switching and can occur on a single core by alternating between tasks.
Definition of Parallelism
Parallelism involves the execution of multiple tasks at the same time. This is achieved by utilizing multiple cores or processors, enabling tasks to run in parallel. Unlike concurrency, which can occur on a single core by switching between tasks, parallelism requires the simultaneous execution of tasks.
Difference Between Parallelism and Concurrency
While parallelism implies concurrency, the reverse is not true. Concurrency involves multiple tasks being in progress, but it does not necessarily mean they are executing simultaneously. Parallelism, on the other hand, requires tasks to execute at the same time, necessitating multiple cores. Concurrency can occur on a single core by rapidly switching between tasks, giving the illusion of simultaneous execution.
Illustrative Example
To better understand the difference between concurrency and parallelism, consider the example of baking cakes. With concurrency, you might have multiple tasks happening at the same time, but you are only actively doing one task at any given moment. For instance, you might start making the batter for one cake, then switch to making the batter for another cake. This is akin to task switching.
In contrast, with parallelism, you have multiple tasks happening and are actively doing more than one simultaneously. Imagine having the help of a second baker. In this scenario, you can work on the first cake while the second baker works on the second cake. Two people making batter at once is parallel because there are two distinct tasks running concurrently.
Figure 1.1 With concurrency, we have multiple tasks happening at the same time, but only one we’re actively doing at a given point in time. With parallelism, we have multiple tasks happening and are actively doing more than one simultaneously.
In terms of applications run by an operating system, consider a system with two applications running. In a concurrent system, the operating system switches between these applications, running one for a short while before letting the other run. This switching happens quickly enough to give the appearance of two things happening at once. In a parallel system, however, both applications are running simultaneously, actively executing two tasks concurrently.
FAQ (Frequently asked questions)
What is parallelism in computing?
What is required for parallelism to occur?
How does parallelism differ from concurrency?
How does parallelism work?
What hardware is necessary for parallelism?
Can concurrency occur on a single core?
Does parallelism imply concurrency?
What is the main difference between concurrency and parallelism?
What is needed for parallelism that is not needed for concurrency?