Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parallel coding Vs Multithreading (on single cpu)

can we use interchangeably "Parallel coding" and "Multithreading coding " on single cpu?

i am not much experience in both, but i want to shift my coding style to any one of the above.

As i found now a days many single thred application are obsolete, which would be better for future software industy as a career prospect?

like image 826
K. Santosh Avatar asked Jul 02 '09 08:07

K. Santosh


People also ask

Is there a benefit of multithreading on 1 CPU?

All you can do with Multithreading on a Single Core machine is simulate Multitasking. Mulitasking is enough to prevent the GUI thread from locking up because of a longrunning operation. However it is generally complicated to implement, unless you have some help from the Compiler or Langauge (like C# async...

Is parallel computing possible in single processors?

On a modern high-speed single processor, the tasks might appear to run at the same time, but in reality they cannot be executed simultaneously on a single processor. Parallel programming, or multithreaded programming, is the software methodology used to implement parallel processing.

Is multithreading faster on a single core?

In fact, you should expect the program to run significantly slower than the single-threaded version. Multithreading generally makes programs run slower, not faster.

Is parallel programming the same as multithreading?

Parallel programming is a broad concept. It can describe many types of processes running on the same machine or on different machines. Multithreading specifically refers to the concurrent execution of more than one sequential set (thread) of instructions.


1 Answers

There is definitely overlap between multithreading and parallel coding/computing, with the main differences in the target processing architecture.

Multithreading has been used to exploit the benefits of concurrency within a single process on a single CPU with shared memory. Running the same programs on a machine with multiple CPUs may result in significant speedup, but is often a bonus rather than intended (until recently). Many OSes have threading models (e.g. pthreads), which benefit from but do not require multiple CPUs.

Multiprocessing is the standard model for parallel programming targeting multiple CPUs, from early SMP machines with many CPUs on a big machine, then to cluster computing across many machines, and now back to many CPUs/cores on a single computer. MPI is a standard that can work across many different architectures.

Of course, one can program a parallel design using threads with language frameworks like OpenMP. I've heard of multicomponent GUIs/applications that rely on separate processing that could theoretically run anywhere. Practically, there's more of the former than the latter.

Probably the main distinction is when the program runs across multiple machines, where it's not practical to use multithreading, and existing applications that share memory will not work.

like image 60
bubaker Avatar answered Sep 21 '22 18:09

bubaker