Lecture 5: Concurrency in Other Languages

5 October 2010

A brief look at some alternative concurrency mechanisms in other languages. Mentioned mechanisms: locks and conditions, message passing, and lock-free algorithms or transactional memory. Drawbacks of locks, including language-critical point about lack of compositionality. Specific examples of concurrency in other languages: Actors in Scala (asynchronous message passing) and Software Transactional Memory using atomic blocks, retry and orElse.

This was a dense lecture, especially with the new 9am start time (please be on time!) and the recap of control abstractions from last week’s lecture. You will need to study the examples (and background reading) and do the homework exercises.

Link: Slides.

Homework

  • Try out (and complete) the example code from the lecture in Scala and Haskell, or an alternative STM library in a language of your choice. Be sure to write a good test harness for queue processing, which uses multiple threads to insert and remove elements and has a way of reporting progress so you can compare implementations.
  • Prepare for next lecture block: revise (or investigate afresh) Haskell. Useful links: haskell resources blog entry and Learn You a Haskell For Great Good beginners guide.