Unit 3: Concurrent Components

 

 

High-level Performance Concepts/Lessons

 

Internal parallelism: Components may use internal parallelism to speed up interactions

·         This may result in other components being called concurrently

·         Sequential component specifications may no longer be suitable

 

Restrictive specifications:

·         Constraints may inhibit parallelism

·         Contracts may need to be weakened to harness full power of parallelism

 

Independent loops: iterations do not conflict

·         Easy to parallelize, while preserving sequential behaviour

 

 

High-level Correctness Concepts/Lessons

 

Component: implements a particular functionality, supporting modular design

·         Failure can point to a particular component

·         Components can be modified independently

 

Determinacy: Different schedules under which a program is run do not change the behaviour of the program

 

Serializability: All operations (functions) appear to take effect at a single temporal point

 

Linearizability: All operations appear to take effect at a single temporal point, and that point is between the call and the return

 

Interface: provides a contract between client and implementation

·         Needs to provide the right level of abstraction

·         Preconditions: requirements for the calling context of a method

·         Postconditions: requirements which a method will fulfill upon execution

 

 

Code-level Concepts/Lessons

 

 

 

Sample Learning Outcomes

 

·         Identify linearizability violations.

·         Analyze API for concurrent component to identify situations of potential interference.

·         Use code contracts to write preconditions and postconditions for an interface.

·         Identify situations in which specifications need to be relaxed for parallelism; also identify specifications that should not be relaxed.

 

 

Assignment Ideas

 

First, write a sequential implementation for a buffer which you could use in the design patterns from Unit2, complete with preconditions and postconditions.  Now create a concurrent buffer implementation, based on your sequential implementation. Clearly identify (in comments) situations where specifications needed to be relaxed (If no such situations exist, strengthen the sequential specifications first). This buffer should have the property that producers and consumers can access it at the same time -- the add and remove methods cannot be protected by the same lock. Verify your implementation does the expected thing with Alpaca tests.

 

Resources

               

Parallel Extensions Samples & Extras (http://code.msdn.microsoft.com/ParExtSamples):

·         AcmePizza

·         ParallelExtensionsExtras.CoordinationDataStructures

·         ParallelExtensionsExtras.Extensions.

o   BlockingCollectionExtensions

o   IProducerConsumerCollectionExtensions

 

Parallel Programming with Microsoft .NET book (http://parallelpatterns.codeplex.com):

·         Chapter 7 (Pipelines)