Harnessing the Power of Threads
Image by Thomas B. from Pixabay
In this module, we will begin to control the threads, so that we can ensure data integrity even as the threads share an address space.
Learning Objectives
We've learned about the process, threads of control, and multi-threaded processes. We've also learned about race conditions through Too Much Milk---now we'll get begin to see how to prevent them.
Upon completion of this module, you will be able to:
- Control threads using locks and semaphores so that desired behavior is ensured
- Prevent concurrency bugs, such as race conditions, through the proper use of locks and semaphores
Learning
- Video: Where We Are (8 minutes)
- Video: Formalizing Our Understanding (16 minutes)
- Video: What is a Lock? (5 minutes)
- Video: Implementing Locks (15 minutes)
- Video: Implementing Locks, Continued (12 minutes)
- Video: Semaphores (6 minutes)
- Video: Using Semaphores (5 minutes)
-
Slides that were presented in the videos
Note that these videos have embedded formative assessments---you'll want to watch the videos and complete those before class, so that you can earn participation credit.
Recommended Readings
Completing the readings in this class is highly recommended---it can be very helpful to see how the concepts are explained by a different person, and the extra details can help the pieces fit together.
OSTEP: Locks (skip 28.8-28.11) and Semaphores (up to 31.5)
Fun Insights
From Class
Any in-class resources will be posted here after class.
Evaluating Your Understanding
We are providing these rubrics for each module so that you can better understand what is expected and evaluate your understanding against those expectations. The hope is that, if you find yourself earning a 3 or below, you will continue to enhance your understanding until you find yourself earning a 4 or a 5.
| Standards | 5 | 4 | 3 | 2 |
|---|---|---|---|---|
| Controlling Threads | Student accurately explains the purpose and actions of concurrency control mechanisms and accurately demonstrates their use on example problems. | Student satisfactorily explains the purpose and actions of concurrency control mechanisms and accurately demonstrates their use on example problems. | Student unsatisfactorily explains the purpose and actions of concurrency control mechanisms, but satisfactorily demonstrates their use on example problems. | Student does not submit the work OR student unsatisfactorily explains the purpose and actions of concurrency control mechanisms and unsatisfactorily demonstrates their use on example problems. |
| Threads Project | Student submitted project that 1) when executed, passes all tests cases, 2) when visually inspected, does not reveal any race conditions or concurrency errors, 3) includes a design document that accurately describes the code and answers the given questions, and 4) follows all given formatting guidelines | Student submitted project that 1) when executed, passes most tests cases, 2) when visually inspected, does reveals one or no race conditions or concurrency errors, 3) includes a design document that satisfactorily describes the code and answers the given questions, and 4) follows most given formatting guidelines | Student submitted project that 1) when executed, passes some tests cases, 2) when visually inspected, does reveals a few race conditions or concurrency errors, 3) includes a design document that unsatisfactorily describes the code and answers the given questions, and 4) follows few given formatting guidelines | Student fails to submit the project or submitted project that 1) when executed, passes no or few tests cases or doesn’t execute, 2) when visually inspected, does reveals many race conditions or concurrency errors, 3) includes a design document that incorrectly describes the code and answers the given questions, and 4) follows few given formatting guidelines |
| Short Answer Questions: Thread-Specific | Student submitted answers to given questions that accurately and succinctly answer the questions. | Student submitted answers to given questions that satisfactorily and succinctly answer the questions. | Student submitted answers to given questions that unsatisfactorily answer the questions. | Student does not submit the answers OR submitted answers to given questions that incorrectly answer the questions. |
| Short Answer Questions: Threads as part of the larger system | Student submitted answers to given questions that accurately and succinctly answer the questions. | Student submitted answers to given questions that satisfactorily and succinctly answer the questions. | Student submitted answers to given questions that unsatisfactorily answer the questions. | Student does not submit the answers OR submitted answers to given questions that incorrectly answer the questions. |