Commit 5b001ee
Changed files (1)
doc
doc/assignment2.md
@@ -196,6 +196,31 @@ need to be able to do this in a safe way without contention (sharing a chopstick
1. What is the difference between deadlock prevention and deadlock avoidance? (6 marks)
+ Deadlock prevention provides a set of methods for ensuring that at least one of the necessary condition cannot hold.
+ These methods provide deadlocks by constraining how requests for resources can be made.
+
+ * Mutual exclusion: At least one resource must be held in a nonsharable mode.
+ * Hold and wait: A process must be holding at least one resource and waiting to acquire additional resources that are currently being held by other processes.
+ * No preemption: Resources cannot be preempted; that is, a resource can be released only voluntarily by the process holding it, after that process has completed its task.
+ * Circular wait: A set {P0, P1,...,Pn} of waiting processes must exist such that P0 is waiting for resource held by P1, P1 is waiting for a resource held by P2,...,Pn-1 is waiting for a resource held by Pn, and Pn is waiting for ar resource held by P0.
+
+ Deadlock avoidance requires the operating system be given in advance additional information concerning which resources a process will request and use during its lifetime.
+ With additional knowledge, it can decide for each request whether or not the process should wait. To decide whether the current request can be satisfied or must be delayed,
+ the system must consider the resources currently available, the resources currently allocated to each process, and the future requests and releases of each process.
+
1. Describe a wait-for graph, and explain how it detects deadlock. (6 marks)
+ A system resource-allocation graph consists of a set of vertices V and a set of edges E.
+ When process Pi requests an instance of resource type Rj, a request edge is inserted in the resource-allocation
+ graph. When this request can be fulfilled, the request edge is instantaneously transformed to an assignment edge.
+ When the process no longer needs access to the resource, it releases the resource; as a result, the assignment edge
+ is deleted.
+
+ If the graph contains no cycles, then no process in the system is deadlocked. If the graph does contain a cycle, then a deadlock may exist.
+
1. Describe how a safe state ensures that deadlock will be avoided. (6 marks)
+
+ A state is safe if the system can allocate resources to each process (up to its maximum) in some order and still avoid a deadlock.
+ A system is in a safe state only if there exists a safe sequence.
+ A sequence of processes is a safe sequence when each resources that each process needs to request can be satisfied by the
+ currently available resources that each process needs. If this cannot be satisfied then the system state is said to be unsafe.