开发者

What exactly is the difference between multi-threaded processing and parallel processing?

  1. Single core CPUs or a machine with a si开发者_如何转开发ngle CPU cannot do parallel processing. True/false?

  2. In a single core single process CPU there can be only one thread's assembly instructions getting executed regardless of however many processes with however many threads are running (sleeping threads excluded) at any given time. True/False?

Sorry about too many questions, they all seem related.


In a single core CPU (without hyperthreading) there will only be one thread actually executing, yes. However, that doesn't totally preclude parallel processing. For instance, you could have three tasks to achieve:

  • One which is doing a lot of network activity
  • One which is doing a lot of disk activity
  • One which is doing a lot of CPU activity

Running these three in parallel using threads could certainly give a performance improvement even on a single core machine. The heavy-CPU activity will have to wait when one of the other activities has some more data to process, but the overall effect is parallel processing. This is basically because "other things" can be happening (the disk head moving, a web service performing some work on a remote machine) without taking CPU.


  1. True.

  2. True. If there's only one CPU then there can only be one sequence of instructions executed at a time.


  1. depends on what you mean by "parallel" processing. You'll need a clear description before you can get a clear answer.

  2. is generally true, but...

Note that some processors support hyperthreading - where one processor with one core presents itself as two "virtual" cores. This allows the processor to execute instructions on one thread while the other is waiting for a memory access and so on.

So even a single-core uniprocessor machine, it can be possible to have multiple threads on the processor simultaneously.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜