3 ms·
You have four tasks A, B, C and D. B and C both depend on the result of A, D depends on the result of B and C. Now B and C are concurrent because there is no de
by danbruc 14y ago
You have four tasks A, B, C and D. B and C both depend on the result of A, D depends on the result of B and C. Now B and C are concurrent because there is no dependency between them - you can execute these tasks in order ABCD or ACBD. It is only important that A executes before and D after B and C. And there is a third option - you can execute B and C at the same time making the execution parallel. So concurrency is about dependencies between tasks or the lack of them while parallelism is about actually executing independent tasks at the same time.
- jberryman 14y ago> So concurrency is about dependencies between tasks or the lack of them while parallelism is about actually executing independent tasks at the same time. I understand what you're getting at, but I don't think that's a great summary of concurrency vs. parallelism. My version would be: currency is about non-determinism and multiple threads of control while parallelism is about doing multiple computations at once for performance reasons (possibly deterministically). EDIT: sorry I see this has already been posted almost verbatim a few other places in the thread
- danbruc 14y agoI personally would not draw a (strong) line between concurrency and nondeterminism - while concurrent (real-world) systems usually show a fair amount of nondeterminism there is still no inherent requirement for that. The dependencies are static and one can always schedule task execution in a fully deterministic way.
- jberryman 14y agoWell, sure we're assuming ultimately some sort of deterministic result of our computation, but we're discussing pl semantics and properties of the computation itself, and non-deterministic semantics are one of the most important characteristics of concurrent programming, no?
- danbruc 14y agoWe definitely want a deterministic result for every task execution even if the execution of some subtasks happens nondeterministically. But after rethinking what I wrote last time I would now even strengthen my statement. Concurrency is a structural property of a system, parallelism is property of an (specific) schedule of subtasks and therefore a property of the runtime behavior of a task. Nondeterminism is also a property of the runtime behavior and therefore nondeterminism MAY be associated with parallelism but CAN NOT be associated with concurrency.