Chapter 12: Concurrency

Concurrency: logically simultaneous, not necessarily physically so

Parallelism

Levels of parallelism

The cases for and against multithreading

Communication and synchronization

Languages and libraries

Languages with significant built-in support for concurrency

Expressions of parallelism

Co-begin

co-begin    -- all n statements run concurrently
   ... [stmt1]
   ... [stmt2]
   ... [stmt3]
   ...
   ... [stmtN]
co-end

Parallel loops

Parallel.For(0,3,i => { somefunction(i); })

Parallel loops

Parallel.Map( somefunction somelist );
Parallel.Fold( somefunction someaccum somelist );

Launch at elaboration

Fork/join

Implicit receipt

Implementation

Synchronization

Synchronization

Synchronization

Semaphores

Transactional Memory

Hardware support for transactional memory

$ cpuid
   [ ... ]
   extended feature flags (7):
      [ ... ]
      HLE hardware lock elision                = false
      [ ... ]
      RTM: restricted transactional memory     = false

Message Passing