(Latest Revision: Sun Apr 26, 2020) cs3750q7-8Recap

cs3750q7-8Recap


Quiz #7-8 Answer Information

What you needed to know to get the questions right
  1. The bounded-buffer, readers-writers, and dining-philosophers problems are used for testing nearly every newly proposed synchronization scheme.
  2. In the solution to the bounded-buffer problem presented in chapter 7, empty and full are semaphores that count the number of empty and full buffers.
  3. In the solution to the readers-writers problem presented in chapter 7, if two or more readers access the shared data, no adverse effects will result.
  4. Our text gives some solution code for the first readers-writers problem. A disadvantage of the solution is that writers may starve.
  5. In the dining-philosophers problem, a philosopher is required to get exclusive access to the chopsticks on left and right before she eats.
  6. Chapter 7 of our text explains how to use semaphores to make a partial solution to the dining-philosophers problem. However that code has the following disadvantage. Deadlock is possible.
  7. One necessary condition for deadlock is circular wait, which states that there is a chain of waiting processes whereby P0 is waiting for a resource held by P1, P1 is waiting for a resource held by P2, ... , and Pn is waiting for a resource held by P0.
  8. In a system resource-allocation graph, a directed edge from a process to a resource type is called a request edge.
  9. The necessary conditions for deadlock are mutual exclusion; circular wait; no preemption; and hold and wait.
  10. Suppose we have a resource allocation graph (RAG) - the kind of RAG that may have request and assignment (allocation) edges, but not the kind of RAG that has any (dotted) claim edges. Recall that in a RAG, there are circular nodes to represent processes and square nodes to represent resource types. If every resource type has only one instance, then there can't be deadlock if there are no cycles in the RAG.
  11. Suppose that there is just one instance of each resource type. Deadlock can be prevented by numbering resources and making processes request resources in order; or by allowing processes to request resources only when they have none; or by requiring processes to give up all their resources if they need to wait for a resource; or by requiring processes to request all resources they may need before they begin execution; but NOT just by requesting resources one at a time.
  12. Suppose that the OS is doing deadlock avoidance and that the system is in a safe state. Then if all the processes in the system immediately request their current needs, the system will NOT be deadlocked.