Final Exam Review - All Chapters and Tutorials, Focused on 6-9 Flashcards
How do resources work in a model?
There are resource types (R1, R2, …, Rm), which can be CPU cycles, memory space, etc., and each resource type Ri has Wi instances (System with 2 CPUs, resource type CPU has 2 instances)
May a deadlock involve the same resource types or different resource types? True/False?
True
What 4 conditions must be held simultaneously for deadlock to occur?
Mutual exclusion, hold and wait, no preemption, circular wait
Can a deadlock occur with mutex locks?
Yes, if the order of acquiring the mutex locks create a deadlock scenario Ex: thread_one first acquires mutex_one then mutex_two, thread_two first acquires mutex_two then mutex_one. If they both get their first mutex lock at the same time, deadlock occurs.
How are the vertices (V) partitioned in a resource-allocation graph?
P = {P1, P2, …, Pn} (set consisting of all processes) and R = {R1, R2, …, Rn} (set consisting of all resource types)
What edges (E) exist in a resource-allocation graph?
Request edges (directed edge from Pi -> Rj) and assignment edges (directed edge from Rj -> Pi)
What are claim edges?
Noted by dashed lines, point from a process to a resource that it may want to request in the future
What is a cycle in a resource-allocation graph?
A closed walk with no repetitions of vertices (except the ending vertex) and edges.
What if there’s a cycle in a resource-allocation graph?
If there’s one resource instance, then there’s a deadlock; If there’s multiple resource instances, then there’s the possibility of a deadlock
What if there’s no cycle in a resource-allocation graph?
There’s no deadlock
How do you ensure deadlock prevention?
Make sure that at least one of the 4 deadlock conditions are not held
What’s a method that can break the “hold and wait” condition?
Each process requests and is allocated all its resources before execution
How do you ensure deadlock avoidance?
By requiring that the system has some additional priori information available, as well as requiring each process to declare the maximum number of resources of each type that it may need
How do you know if the system is in a safe state?
If there exists a sequence <P1, P2, …, Pn> of all processes such that each process can be satisfied by the currently available resources, including recently released resources from other processes beforehand
What is the importance of a safe state?
All safe states are deadlock free, but not all unsafe states lead to deadlocks (Avoidance means ensuring the system is never in an unsafe state)
What is needed for the Banker’s algorithm?
n (# of processes), m (# of resource categories), Available[m], Max[n][m], Allocation[n][m], Need[n][m] (note: Need[i][j] = Max[i][j] - Allocation[i][j] for all i, j), Work (Initially equals Available, then if Need <= Work, Work = Work + Allocation
How do you perform deadlock detection?
For a single instance of each resource type, a deadlock exists in the system if and only if the wait-for graph contains a cycle (Nodes are processes Pi -> Pj if Pi is waiting for P); For several instances, then use the banker’s algorithm to see if it finishes (use only involved processes which does not have any resources allocated)