On Concurrency

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Apr 20 23:26:04 PDT 2014


On Friday, 18 April 2014 at 17:20:06 UTC, Nordlöw wrote:
> Could someone please give some references to thorough 
> explainings on these latest concurrency mechanisms

Coroutines is nothing more than explicit stack switching. 
Goroutines/fiber etc are abstractions that may be implemented 
using coroutines.

Threads are new execution contexts with their own register sets 
(and stack/stackpointer) that run in parallell (coroutines don't).

Processes have their own resource space (memory, file handles 
etc).

Supervisor mode is a state where the core has access to all 
memory, hardware registers and the ability to touch the config of 
other cores. Typically only for the OS.

> 5. And finally how does data sharing/immutability relate to the 
> above questions?

The key difference is the granularity/parallellism of the 
concurrency. With threads you have to consider locking 
mechanisms/memorybarriers. With coroutines you don't if you 
switch context when the data set is in a consistent state.

One key difference is that coroutines won't make your programs 
run faster. It is a modelling mechanism that can simplify your 
programs where you otherwise would have to implement a state 
machine.


More information about the Digitalmars-d-learn mailing list