CS 332 s20 — Writing Concurrent Software

Table of Contents

1 Video Lecture

Please watch the video lecture: It contains sections on

  1. Introduction (0:00)
  2. Shared Object Design: Standard OOP + Synchronization (0:33)
  3. Use a Lock to Protect Object State (3:13)
  4. Ask When Can This Method Wait and Add Condition Variables (8:23)
  5. Six Best Practices (13:11)
  6. What If a Lock is a Bottleneck? (16:25)
  7. Replace Single Lock With Many, Each Protecting Part of the Shared State (17:34)
  8. How might we use fine-grained locking to reduce lock contention for the heap? (23:05)
  9. Partition the Data Among Available Processors (24:22)
  10. One Thread Per Object—No Locks Needed (27:26)
  11. Divide System Into Multiple Subsystems Each With Its Own Threads (30:17)
  12. Lab 3—Design Document (34:07)
  13. osv Synchronization Primitives (37:44)
  14. fork() (39:51)
  15. wait()/exit() (40:47)
  16. end notes (42:26)

The Panopto viewer has table of contents entries for each slide (https://carleton.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=61ecb50c-cdc1-4ede-b553-abb30114dd92). You can access the lecture slides here.

2 Reading: Concurrent Data Structures

Read OSTEP chapter 29, (p. 353-366). It walks through C implementations of several concurrent data structures and measures their performance.

3 Homework

  1. If you would like to work with a partner on lab 3, email me by this Friday (5/8). Your email should contain either
    • your name, your partner's name, and which of your two osv repos you will use
    • OR if you would like me to match you with a partner, send me your timezone and preferred working times. I will do my best to create compatible pairs.
  2. Starting working on your lab 3 design doc
  3. Work through the questions in OSTEP chapter 30 (p. 386) to explore how real code uses locks and condition variables to implement producer/consumer queues. Download the code here: http://pages.cs.wisc.edu/~remzi/OSTEP/Homework/HW-Threads-RealCV.tgz