{ "q08": { "type": "blank", "question": "\n\nRather than prevent deadlock, we can instead try to avoid it by having a\nsmart ____ that will consider the dependencies between threads or by having a\nservice that ____ deadlock and provides ____ techniques.\n\n\n" }, "q02": { "type": "multiple", "question": "\n\nRegarding using semaphores to implement locks and condition variables,\nwhich of the following statements are true (choose all that apply)?\n\n\n", "responses": { "cond_init": "To make a condition variable, we initialize the semaphore to 1.", "lock_call": "To make a lock (binary semaphore), we first sem_post, perform the critical section, and then sem_wait", "cond_call": "To make a condition variable, we use sem_post to signal and sem_wait to wait.", "lock_init": "To make a lock (binary semaphore), we initialize the semaphore to 1." } }, "q03": { "type": "multiple", "question": "\n\nRegarding reader-writer locks, which of the following statements are true\n(choose all that apply)?\n\n\n", "responses": { "starvation": "Reader-writer locks are prone to starvation problems.", "overhead": "Reader-writer locks generally improve performance over simple and fast locking primitives.", "writers": "Reader-writer locks suspend all readers once a writer requires access.", "concurrency": "Reader-writer locks allow for multiple concurrent readers as long as there are no writers." } }, "q01": { "type": "blank", "question": "\n\nA ____ is a synchronization primitive that consists of an ____ value that\nwe can manipulate with two routines:\n\n\n
    \n\n
  1. ____: This function decrements the value of the semaphore and\n waits if the value of the semaphore is negative.
  2. \n\n
  3. ____: This function increments the value of the semaphore and\n then wakes up any waiting threads.
  4. \n \n
\n" }, "q06": { "type": "blank", "question": "\n\nDeadlock occurs when the following four conditions hold:\n\n\n\n
    \n\n
  1. ____: There exists a circular chain of threads such that each\nthread holds one or more resources that are being requested by the next\nthread in the chain.
  2. \n\n
  3. ____: Resources cannot be forcibly removed from threads that are\nholding them.
  4. \n\n
  5. ____: Threads hold resources allocated to them while waiting for\nadditional resources.
  6. \n\n
  7. ____: Threads claim exclusive control of resources that they\nrequire.
  8. \n\n
\n" }, "q07": { "type": "multiple", "question": "\n\nWhich of the following are ways to prevent deadlock (choose all that apply)?\n\n\n", "responses": { "ordering": "Provide some form of ordering to circumvent circular waiting.", "livelock": "Prefer methods that utilize livelock instead of deadlock.", "holding": "Make sure we always acquire locks one at a time.", "lockfree": "Avoid locks by using atomic hardware instructions." } }, "q04": { "type": "single", "question": "\n\nTo solve the Dining Philosopher's problem, the book proposes the following\nsolution:\n\n\n", "responses": { "waiter": "Have a waiter direct which philosophers can eat.", "starve": "Just let some of the philosophers starve.", "forks": "Buy more forks.", "order": "Change the order in which the last philosopher acquires the forks.", "rdrn": "Have philosophers eat in round-robin fashion." } }, "q05": { "type": "blank", "question": "\nTwo types of non-deadlock concurrency bugs are:\n\n\n
    \n\n
  1. ____: These bugs occur when the assumption of atomicity is incorrect.
  2. \n\n
  3. ____: These bugs occur when the desired order of operations is\nnot enforced during execution.
  4. \n\n
\n" } }