HW3 released: 10/05, 22:00 due: 10/12, 13:00 - Read Mike Dahlin's "Basic Threads Programming: Standards and Strategy" (https://naizhengtan.github.io/21fall/notes/programming-with-threads.pdf) - Study 10/05's lecture handout (https://naizhengtan.github.io/21fall/notes/handout_5a.pdf) and answer the following questions. Submit your answers to Canvas assignments. There is an entry for this homework. Question 1: is the program still correct if we replace the "cond_signal" at handout line 48 with "cond_broadcast"? (yes/no) Why? (explain in 1-2 sentences) Question 2: here is the "database problem" we discussed on class: """ - readers and writers interact with a database - readers never modify database - writers read and modify data - we allow multiple readers touching the database - we only allow one writer (no other readers) touching the database """ Follow Mike Dahlin's problem solving strategy (S3 in his write-up) and write down your step 1-3 below. Answer: 1. 1.a [your words] 1.b [your words] 1.c [your words] 2. [your words] 3. [your words] Question 3: read the "smoker problem" and write down the first 3 steps of our problem solving strategy. """ smoker problem - There are three smokers and one agent. - Each smoker continuously rolls a cigarette and then smokes it. - But to roll and smoke a cigarette, the smoker needs three ingredients: tobacco, paper, and matches. - One of the smoker has paper, another has tobacco, and the third has matches. - The agent has an infinite supply of all three materials. - The agent randomly places two of the ingredients on the table. - The smoker who has the remaining ingredient then makes and smokes a cigarette, telling the agent on completion. - The agent then puts out another two of the three ingredients, and the cycle repeats. """ Answer: 1. 1.a [your words] 1.b [your words] 1.c [your words] 2. [your words] 3. [your words] Question 4: Read the handout panel 2 and answer the question at line 178 in 1-2 sentences. Question 5: Read the handout panel 3 and answer the question B at line 223 below. (note: write pseudocode like the handout; use comments to explain if necessary) Answer: // assume you have the sharedlock in panel 3 /* init code you have */ Database::read() { // your pseudocode here } Database::write() { // your pseudocode here }