Everyone:

Last week, we have studied two different forms of concurrency: event-based programming via select/poll and threads (ala pthreads). While the former allowed us to overlap I/O and computation, it did not allow us to take advantage of parallelism. To do harness multiple hardware resources, we will need to utilize threads. Unfortunately, using threads also means we need to employ locks and condition variables to ensure correct concurrent access to shared resources.

The readings this week focus on how locks and condition variables work and how we can use them to implement concurrent data structures.

TL;DR

For this reading assignment, you are to read about using locks and condition variables to synchronize pthreads and submit your responses to the Reading 05 Quiz.

Reading

The readings for Tuesday, September 25 are:

  1. Operating Systems: Three Easy Pieces

    1. Locks
    2. Lock-based Concurrent Data Structures
    3. Condition Variables

Optional Readings

The following are optional related readings:

  1. Simple, Fast, and Practical Non-Blocking and Blocking Concurrent Queue Algorithms

  2. The Producer/Consumer Problem

  3. Concurrency in C++11

  4. Multithreading: Producer Consumer Problem

C++11 Threads

Although the textbook and class examples will revolve around pthreads, you may also utilize the threading library introduced in C++11.

Quiz

Once you have done the readings, answer the following Reading 05 Quiz questions:

Submission

To submit you work, follow the same process outlined in Reading 00:

$ git checkout master                 # Make sure we are in master branch
$ git pull --rebase                   # Make sure we are up-to-date with GitLab

$ git checkout -b reading05           # Create reading05 branch and check it out

$ cd reading05                        # Go into reading05 folder
$ $EDITOR answers.json                # Edit your answers.json file

$ ../.scripts/submit.py               # Check reading05 quiz
Submitting reading05 assignment ...
Submitting reading05 quiz ...
     Q01 0.50
     Q02 0.20
     Q03 0.30
     Q04 0.50
     Q05 0.30
     Q06 0.20
     Q07 0.20
     Q08 0.20
     Q09 0.20
     Q10 0.40
   Score 3.00

$ git add answers.json                # Add answers.json to staging area
$ git commit -m "Reading 05: Done"    # Commit work

$ git push -u origin reading05        # Push branch to GitLab

Remember to create a merge request and assign the appropriate TA from the Reading 05 TA List.