1,417 views
0 votes
0 votes
I have read in some notes that priority inversion problem is a case of spin lock, not deadlock because in deadlock the processes are in blocked state, but here the processes are busy waiting and consuming memory.

I have also read in a note that priority inversion problem is a special case of deadlock called as live lock. In live lock the processes are in different states.

Which one of this is true? Is this problem a case of spin-lock or live lock or deadlock?

3 Answers

1 votes
1 votes

In livelock we can observe that all the processes are in ready/running states. Whereas in deadlock we find the processes in waiting/blocked state. This is the main difference between livelock and deadlock.

Spinlock deals with the busy waiting process.

 

To keep it simple:

Deadlock occurs when no process is able to proceed further due to circular waiting amongst the processes.

Livelock occurs when there is multiple processes are live(ready/running) but blocked together due to Priority Inversion Problem.

Spinlock occurs when we take preemption from one process(which is present in CS) to another process which gets stuck infinitely (spins continuously) in entry section. 

 

0 votes
0 votes

This problem is a case of synchronization.

Suppose, we have 2 processes p1 and p2 both accessing a shared resource, so if any process p1 or p2 is in it’s critical section other process will be in busy waiting or sleeping state (depending upon the synchronization mechanism).

On it’s own this is not a problem, but when we factor in process allocation, particularly Priority Based Preemptive Process Allocation then we’ll be seeing much bigger problems.

For our discussion, we’ll say p1 has higher priority than p2 and p2 is currently running and is in its critical section.

  1. When p1 becomes ready the scheduler preempts p2 which is in it’s critical section and gives cpu to p1. After a while when p1 tries to access it’s critical section, p1 sleeps and p2 resumes. Now suppose, a process p3 such that priority of p1>p3>p2 and p3 becomes ready then p3 will preempt p2 and execute first. So, a lower priority process (p3) affects how long a high priority process (p1) waits.
  2. When p1 becomes ready the scheduler preempts p2 which is in it’s critical section and gives cpu to p1. After a while p1 tries to access it’s critical section, rather than p1 sleeping if it keeps busy waiting then p1 is waiting for p2 to get out of it’s critical section and p2 is waiting for p1 to finish or sleep to get cpu which is a deadlock.

This problem is solved using Priority-Inheritance Protocol. – According to this protocol, all processes that are accessing resources needed by a higher-priority process inherit the higher priority until they are finished with the resources in question. When the are finished, their priorities revert back to their original values.

Source – Galvin Book and others.

0 votes
0 votes

@abhilashbal

Deadlock is a problem, in concurrent programming…

While Spinlock is a solution for threads, so that two threads can not access the same resource at a time....

A spinlock is a lock that causes a thread trying to acquire it to simply wait in a loop ("spin") while repeatedly checking whether the lock is available….

Since the thread remains active but is not performing a useful task, the use of such a lock is a kind of busy waiting...

The Deadlock is actually an example of Spinlock....

Deadlock occurs when a set of processes are blocked which are not in ready or running state and waiting for some resources…

But in our example each one is performing some task i.e., checking the condition again and again ...

In Livelock no process can enter into CS....

A livelock is similar to a deadlock, except that the states of the processes involved in the livelock constantly change with regard to one another, none progressing ..

For your actual question - spinlock is same as busy waiting when one process enter into CS and other keep waiting....

In case of Livelock none of them can able to enter....

 

1. https://gateoverflow.in/156236/Livelock-and-spinlock 

 

2. https://gateoverflow.in/46833/Difference-between-deadloack-%26-spinlock 

 

3. https://gateoverflow.in/144914/Process-synchronization 

 

4. https://gateoverflow.in/299037/Is-priority-inversion-and-spinlock-same