Issues related to deadlock

Filter Course


Issues related to deadlock

Published by: Zaya

Published date: 22 Jun 2021

Issues related to deadlock Photo

Issues related to deadlock

1.  Two-phase locking

In databases and transaction processing, two-phase locking (2PL) is a concurrency control method that guarantees serializability. It is also the name of the resulting set of database transaction schedules (histories). The protocol utilizes locks, applied by a transaction to data, which may block (interpreted as signals to stop) other transactions from accessing the same data during the transaction's life. By the 2PL protocol, locks are applied and removed in two phases:

  • Expanding phase: locks are acquired and no locks are released.
  • Shrinking phase: locks are released and no locks are acquired.

Two types of locks are utilized by the basic protocol: Shared and Exclusive locks. Refinements of the basic protocol may utilize more lock types. Using locks that block processes, 2PL may be subject to deadlocks that result from the mutual blocking of two or more transactions.

2. Non-resource deadlock

In a non-resource deadlock, a deadlock occurs without the involvement of any resources. Say you have two nodes in a network that communicate and have a 3 steps handshake:

  • node1 sends a message to node2 and waits for a response
  • node2 receives the message and sends back the response to node1 and waits
  • but the response is lost on the network due to a temporary disruption

Both nodes are waiting for each other => deadlock

3. Starvation

Starvation is the phenomenon in which a process is not able to acquire the desired resources (like processor, I/O device, etc) for a very long time to progress with its execution.
This can happen due to the drawbacks of scheduling algorithms. Scheduling algorithms are used to decide to which process the resource(s) needs to be given next.
Example:

  • In Shortest Job First Algorithm, if there is a process with a rather large CPU burst waiting for its execution and a stream of processes with a smaller CPU burst keep entering the ready queue (a queue consisting of those processes which are ready to execute), then the CPU will always be allocated to the process with the shorter CPU burst and there is a probability that the process with the large CPU burst might never get the CPU to complete its execution and starve.
  • In Priority Scheduling, a constant stream of high priority processes might starve one or lower priority processes (es) as the CPU will always be allocated to the process with the highest priority.

Deadlock VS Starvation

Deadlock VS Starvation

 

4. Livelock

Livelock occurs when two or more processes continually repeat the same interaction in response to changes in the other processes without doing any useful work. These processes are not in the waiting state, and they are running concurrently. This is different from a deadlock because in a deadlock all processes are in the waiting state.