Deadlocks Flashcards
What is a deadlock?
Situation where two or more processes are waiting for the other to finish, and thus neither ever does. Deadlock may happen because two or more processes are using/sharing the same resources
What is deadlock detection?
Algorithms which are used to detect of a possible Deadlock situation before it occurs
What are the four coffman conditions?
Mutual Exclusion
Only one process can use the resource at any given instant of time
Hold and Wait (resource holding)
A process is currently holding at least one resource and requesting additional resources which are being held by other processes
No Pre-emption
A resource can be released only voluntarily by the process holding it
Circular Wait
P1 must be waiting for a resource which is being held by P2, which in turn P2 is waiting for the first process to release the resource
What is deadlock resolution?
Ways to resolve deadlock. There are 3 possible ways: By killing one or more processes, by killing all deadlocked processes or by rolling back all the processes to the state before deadlock
What are threads?
Entity within a process that is used to schedule when each part of the program code should be executed on CPU
What is the advantage of threads?
: More responsive (a program may continue running even if part of it getting blocked or performing a lengthy operation), resource sharing (several threads share the same resources), may run in parallel on different processors, and it is cheaper and faster to create a thread than a process
What is the difference between a thread and a process?
Threads define how and when part of the code inside a process should be executed. It shares all of the process resources. Processes are used to allocate different resources. Every process may not share all of the process resources. It is cheaper and faster to create a thread than a process
What constitutes a thread in memory?
Consists of ThreadID, Program Counter, Register Sets, Stack and Thread state. All threads share address space, global variables (program code, files, child processes, accounting information), and signal handlers