Header Ads Widget

Concurrency

Concurrency is the computation of processes within a time frame to give an impression of simultaneous execution. Here, it's important to note that this is not the same thing as actually running simultaneously.

Concurrency can actually be looked at as the competition of multiple processes for the same resource. Although it's a competition between the processes, the loser of the race is the one that actually has the final value.

True parallelism would allow for the simultaneous execution of the processes, but concurrent processes do not exhibit parallelism. Concurrency results in the following issues:

  • Problems with the sharing of global resources
  • Problems in allocating resources and
  • Programming issues because multiple processes update the same resource, which is difficult to reproduce.

Concurrency means that multiple processes or threads are making progress concurrently. While only one thread is executed at a time by the CPU, these threads can be switched in and out as required. This means that no thread is actually completed totally before another is scheduled. So, all the threads are executing concurrently.

An image that demonstrates concurrency is as follows:

In the above diagram, all the four threads are running concurrently. However, only one of them can be scheduled on a processor at a time.

Parallelism- Parallelism means that multiple processes or threads are making progress in parallel. This means that the threads are executing at the same time. This can happen if all the threads are scheduled on parallel processors.

An image that demonstrates parallelism is as follows:

In the above diagram, all the four threads are running in parallel i.e. they are executing at the same time.

Post a Comment

0 Comments