Semester 2, 2017

Lecture time and place

Tuesday 11:00 A.M. – 12:50 P.M.; room G34, Owheo building.


  1. 1. Introduction (Slides,PDF) (MP3)
  2. 2. Mutual Exclusion and Memory Hierarchy (Slides,PDF) (MP3)
    Dekker's algorithm in C and assembler.
  3. 3. Stacks and threads, C11/POSIX Part 1. (Slides,PDF)
  4. 4. Atomic variables, mutexes, and semaphores (Slides,PDF). (MP3)
    See also last year's C11 interface lecture and The Little Book of Semaphores.
  5. 5. Compare-and-Swap and concurrent stacks and queues
  6. 6. Message Passing (in UNIX, but also general issues)
  7. 7. Distributed programming (MP3). See also last year's Time, Happens-Before, and Logical Clocks PDF
  8. 8. Erlang (MP3)
  9. 9. Higher-order functions and a case study (MP3) — Source code
  10. 10. Patterns of Concurrency and Parallelism (MP3).
  11. 11. Message passing and shared memory can simulate each other. (MP3). sample code.
  12. 12. Property-based testing (Slides,PDF) and symbolic model checking (Slides,PDF), (MP3).
  13. 13. Wrapup

Previous exams


Please ensure that you have read the notes for 400-level students carefully, especially the section on E-mail.


The primary resource is the (Open Source) Erlang web site, There you will find (half of) the old book about Erlang as a free PDF. You will also find the users' guide and reference manual, which I've made a local copy of the PDF for. There is a four-day course there. Finally, here's a source file I discuss in class.

For C programming in general, and thread programming in particular, you may find A. D. Marshall's "Programming in C" notes useful; it's a little dated but there is some code in there you will definitely want to use (with acknowledgement!) in the first assignment.

Here are some more things:

  • Joe Armstrong's Ph.D. thesis explaining the fundamental ideas behind Erlang
  • A 20-page Introduction to the Occam Programming Language by Dr Daniel C. Hyde. We shan't be using Occam this year, but you may find it of interest.
  • The Occam 2.1 Reference Manual (171 pages)
  • The Architecture of Concurrent Programs, a classic book by Per Brinch Hansen (329 pages). It "describes a method for writing concurrent computer programs of high quality" and was "written for professional programmers and students who are faced with the complicated task of building reliable computer operating systems or real-time control programs." The language it describes is called Concurrent Pascal, and is noteworthy as much for the bad things it was designed not to let you do as for the good things it was designed to make easy to express. The language was successfully used on many industrial projects. This is a good place to find out about the "monitor" concept.
  • Sun's "Multithreaded Programming Guide". It mainly describes POSIX threads although there is some material here specific to Solaris.


  1. 1. simple thread creation in C
  2. 2. publish-subscribe task in C
  3. 3. simple thread creation in Erlang
  4. 4. publish-subscribe task in Erlang