Skip to main content

Concurrency vs Parallelism – Difference between Concurrency and Parallelism Vijay Sinha The Crazy Programmer

In this article, we dive deep into the core concepts of multithreading. We will have a look at the profound understandings of the terms Concurrency and Parallelism with their description. Then, we compare the major differences between the two terms. Concurrency and Parallelism are often misunderstood to be somewhat similar but it is not the case when we consider it with aspects of Multithreading.

Concurrency

By Concurrency, we mean executing multiple tasks on the same core. In simpler terms, it relates to processing more than one task at the same time. It is a state in which multiple tasks start, run, and complete in overlapping time periods. An application capable of executing multiple tasks virtually at the same time is called a Concurrent application.

In case the computer only has one CPU or one Core the application may not make progress on more than one task at the exact same timeInstead, divide the time and the Core/CPU among various tasks. Concurrency is useful in decreasing the response time of the system.

Let us see this example and figure out the working of concurrent processes within a single core.

Concurrency

Here, we have two tasks T1 and T2 running on a single core. The task T1 is given a time slice for which it executes afterward the control of execution is given to T2 by the core this is called Context Switching, where a single core is shared among different processes or tasks effectively for small time slice to execute part of a process.

Parallelism

Parallelism is the ability of an application to split up its processes or tasks into smaller subtasks that are processed simultaneously or in parallel. It is the mechanism in which multiple processes execute independently of each other where each process acquires a separate core. This utilizes all the cores of the CPU or processor to run multiple tasks simultaneously.

Hence, to achieve parallelism the application must have more than one thread running on separate cores. In a single core CPU parallelism is not possible due to lack of hardware (Multi-Core Infrastructure). Parallelism is effective in improving the overall throughput resulting in faster execution. Let us look at an example:

Parallelism

As you can see in the above figure, the two tasks T1 and T2 execute in parallel to each other. The two tasks run on separate cores and are independent of each other. This leads to faster execution because there is no time slice for the process. They do not have to wait for a process to finish and allocate CPU to other processes which were evident in the case of Concurrency.

Concurrency vs Parallelism

Now, we have a look at some key differences between Concurrency and Parallelism:

                       Concurrency
                           Parallelism
1. It is the mechanism to run multiple processes at the same time not necessary to be simultaneous. 1. It is the ability to split a heavyweight process into smaller independent subtasks and run those simultaneously.
2. Context Switching plays an important role in implementing concurrency. 2. In Parallelism, the sub-processes run separately so there is no overhead of Context Switching.
3. It is achieved using Single processing units or through a single core. 3. It requires Multiple Processing Units as processes run separately on different cores.
4. It runs on a single core so hardware is less required. 4. The implementation requires multiple cores for each of the processes so hardware cost is comparatively more here.
5. It increases the amount of work finished at a time and helps in decreasing response time considerably. 5. It is responsible for increasing the throughput of the system and in faster execution.
6. Concurrency is about dealing with a lot of things at once. 6. However, parallelism is about doing a lot of things at the same instant.

That’s it for the article, these core concepts are helpful in solving large scale problems. We looked into the description of each topic with their examples.

Feel free to leave your queries in the comment section below.

The post Concurrency vs Parallelism – Difference between Concurrency and Parallelism appeared first on The Crazy Programmer.



from The Crazy Programmer https://ift.tt/2Nzh6I4

Comments

Popular posts from this blog

Difference between Web Designer and Web Developer Neeraj Mishra The Crazy Programmer

Have you ever wondered about the distinctions between web developers’ and web designers’ duties and obligations? You’re not alone! Many people have trouble distinguishing between these two. Although they collaborate to publish new websites on the internet, web developers and web designers play very different roles. To put these job possibilities into perspective, consider the construction of a house. To create a vision for the house, including the visual components, the space planning and layout, the materials, and the overall appearance and sense of the space, you need an architect. That said, to translate an idea into a building, you need construction professionals to take those architectural drawings and put them into practice. Image Source In a similar vein, web development and design work together to create websites. Let’s examine the major responsibilities and distinctions between web developers and web designers. Let’s get going, shall we? What Does a Web Designer Do?

A guide to data integration tools

CData Software is a leader in data access and connectivity solutions. It specializes in the development of data drivers and data access technologies for real-time access to online or on-premise applications, databases and web APIs. The company is focused on bringing data connectivity capabilities natively into tools organizations already use. It also features ETL/ELT solutions, enterprise connectors, and data visualization. Matillion ’s data transformation software empowers customers to extract data from a wide number of sources, load it into their chosen cloud data warehouse (CDW) and transform that data from its siloed source state, into analytics-ready insights – prepared for advanced analytics, machine learning, and artificial intelligence use cases. Only Matillion is purpose-built for Snowflake, Amazon Redshift, Google BigQuery, and Microsoft Azure, enabling businesses to achieve new levels of simplicity, speed, scale, and savings. Trusted by companies of all sizes to meet

2022: The year of hybrid work

Remote work was once considered a luxury to many, but in 2020, it became a necessity for a large portion of the workforce, as the scary and unknown COVID-19 virus sickened and even took the lives of so many people around the world.  Some workers were able to thrive in a remote setting, while others felt isolated and struggled to keep up a balance between their work and home lives. Last year saw the availability of life-saving vaccines, so companies were able to start having the conversation about what to do next. Should they keep everyone remote? Should they go back to working in the office full time? Or should they do something in between? Enter hybrid work, which offers a mix of the two. A Fall 2021 study conducted by Google revealed that over 75% of survey respondents expect hybrid work to become a standard practice within their organization within the next three years.  Thus, two years after the world abruptly shifted to widespread adoption of remote work, we are declaring 20