HW5 released: 02/16, 11:00 due: 02/22, 23:59 Answer the following questions. Submit your answers to Canvas assignments. There is an entry for this homework. 1. Six commandments (3 points) Have you read Mike Dahlin's "Basic Threads Programming: Standards and Strategy"? Answer "Yes" if you do; otherwise, "No" (then you will lose points). 2. OSTEP (4 points) Read OSTEP chapter 30 (https://pages.cs.wisc.edu/~remzi/OSTEP/threads-cv.pdf) and answer the following questions. 2.a. (2 point) Why do we need condition variables? Aren't mutexs enough? Explain in two sentences. 2.b. (2 point) Read Figure 30.8. What can go wrong using "if" (line 9 and 21)? Explain in a few sentences. 3. Four-step solving process (3 points) Read the "database reader/writer problem" below and write down the first three steps of our 4-step problem solving strategy. Problem: - We have a database. - There are readers and writers: -- readers will read data from the database. -- writers will write data to the database. - We need to give writers **exclusive access**: a single active writer means there should be no other writers and no readers. - We allow multiple readers: multiple reads can read the database at the same time. - This is a question in our handout and the code-level solution is here: (https://naizhengtan.github.io/23spring/notes/handout_w06a.pdf) Please write down the first three steps of your design of this problem: [hint: the 4 steps are: 1. Getting started: 1a. Identify units of concurrency. 1b. Identify shared chunks of state. 1c. Write down the high-level main loop of each thread. 2. Write down the synchronization constraints on the solution. 3. Create a lock or condition variable corresponding to each constraint 4. Write the methods, using locks and condition variables for coordination ] [update 02/21: We expect to see English sentences for all the steps above. For step 2, there are two types of "synchronization constraints": (a) mutual exclusion and (b) scheduling constraints. * For (a), it is something like, "among multiple entities (i.e., ABC, XYZ), only one can do something." * For (b), it is something like, "only when something happens, then can XYZ do something." or "if something happens, then XYZ should wait until other things happen." ]