今日单词 Concurrency and Parallelism

ratify  批准
flawed   有缺陷的
quirky   古怪的
gibberish   乱码
overhead   开销
incurred   产生的
ubiquitous   普及
perplexing   复杂的
conduit   导管



今天下午感觉很轻松,喜欢这种感觉,怀疑了一些东西,但是还是有很多东西是美好的。



要有两个线程正在执行才能算是Parallelism;Concurrency则只要有两个以上线程还在执行过程中即可。简单地说,Parallelism要在多核或者多处理器情况下才能做到,而Concurrency则不需要。

Concurrency and parallelism are NOT the same thing. Two tasks T1 and T2 are concurrent if the order in which the two tasks are executed in time is not predetermined,

T1 may be executed and finished before T2,
T2 may be executed and finished before T1,
T1 and T2 may be executed simultaneously at the same instance of time (parallelism),
T1 and T2 may be executed alternatively,
...
If two concurrent threads are scheduled by the OS to run on one single-core non-SMT non-CMP processor, you may get concurrency but not parallelism. Parallelism is possible on multi-core, multi-processor or distributed systems.

Concurrency is often referred to as a property of a program, and is a concept more general than parallelism.

Interestingly, we cannot say the same thing for concurrent programming and parallel programming. They are overlapped, but neither is the superset of the other. The difference comes from the sets of topics the two areas cover. For example, concurrent programming includes topic like signal handling, while parallel programming includes topic like memory consistency model. The difference reflects the different orignal hardware and software background of the two programming practices.

猜你喜欢

转载自wwwjjq.iteye.com/blog/1667956