1
$\begingroup$

I am so confused between concurrency vs parallelism in multi-core processors.

If a concurrent process has many threads and if the processor is multi-core then can each thread run on multiple cores? If the answer is YES then multiple threads are running in parallel but the process is concurrent. How is it possible and where is the concept of concurrency applied?

but if your answer is no then why do we even need concurrency concept. Why cant all processes be based on parallelism concept?

If I assume that multiple threads of the concurrent process run in parallel.

Then which is better performance-wise concurrency in multi-core vs parallelism in multi-core and why?

$\endgroup$

3 Answers 3

1
$\begingroup$

A simple re-look at the terms used in question will provide the answer.

A process is a program in execution.

Often a process consist of multiple software threads. The work of the process is divided among the threads. If the work done by threads is relatively independent, they can execute concurrently on available processor cores.

Most modern processor consist of multiple core, where each core is capable of executing, at-least one software thread. So if the processor consist of n cores, n different software threads can execute concurrently on n cores. It is not necessary that all n threads belong to same process. The number of software threads can be higher than n (the number of cores), if the threads perform a lot of relatively slower memory access and/or I/O operations. So more than one thread can share a core, running alternately, giving a user the impression that they are running concurrently. They are actually executing in time-sliced manner. One thread run for few cycles then it is removed from the processor and another thread execute for few cycles and so no.

No parallel execution of a multi-threaded process is possible unless threads of the process execute concurrently.

$\endgroup$
1
$\begingroup$

I agree the usage of the terms concurrent and parallel in computing is confusing. Part of the confusion is because the English word concurrent means: "at the same time", but the usage in computing is slightly different.

In computing we say two threads have the potential to run concurrently if there are no dependencies between them. When we say two threads are running concurrently, we might mean that they are running in parallel on two different physical cpu cores. But we also might mean this in the virtual sense of multitasking. For example a single cpu core might be running both threads using preemptive multitasking to switch back and forth between them every 1/100th of a second. So over a timespan of an entire second it appears the two threads are running simultaneously, while in fact only one of them is running at a time and we're just switching back and forth between them very quickly.

I try to use the word concurrency to refer only to potential concurrency. I try to use the word parallel when I want to indicate that two (potentially) concurrent threads are actually running simultaneously on different cpu cores. And I try to use the term multitasked or interleaved when I want to indicate that two (potentially) concurrent threads are sharing the same cpu core over a long period of time, with the cpu core switching back and forth between the two threads.

$\endgroup$
-1
$\begingroup$

The exact use of such terms depends on context and author, but generally speaking, I would say that concurrency is a much broader term than parallelism; parallelism is a form of concurrency.

The term concurrency is generally used to describe a situation in which processing doesn't necessarily happen in strict sequential order. The things in question can be events, or processes, or actions performed by humans, by computers, by nature, or whatever else ... it really is a very broad term. Examples of concurrent processes:

  • a chemical reaction
  • shopping at Amazon (including the customer placing an order)
  • cars driving around
  • you watching a YouTube video

The antonym of concurrency is sequentiality. In a sequential process, everything happens in a strict sequential order: no step starts before the previous step has finished.

The term parallelism is generally used to describe a very specific kind of concurrent process, in which all processing in question is executed by processors within one computer, and multiple processors or threads run at the same time, using shared resources.

The antonym of parallelism is distributed computing; in distributed computing, we still describe processes executed entirely on computer processors, but in contrast to parallel computing, the processors have their own resources, and they need to communicate, usually by means of some form of message passing over dedicated message passing channels, in order to cooperate.

So both parallelism and distributed computing are two specific forms of concurrency, in which all processing is executed on computer processors.

Your question assumes a context in which we're talking about parallelism, and then asks why we use the term concurrency at all, when parallelism will do. Yes, it will, when referring to parallelism; it won't do in general.

$\endgroup$
2
  • $\begingroup$ Parallelism is not a form of concurrency; it's orthogonal. You can have parallelism without concurrency (e.g. SIMD stuff, AVX), and concurrency without parallelism (e.g. single-core operating system). And I'm really not sure what you mean by "the antonym of parallelism is distributed computing". There is typically lots of parallelism in distributed computing... $\endgroup$ Jun 21, 2021 at 19:12
  • $\begingroup$ OK, I suppose I've only seen the term in a very specific context. $\endgroup$ Jun 21, 2021 at 21:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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