6
$\begingroup$

If there is a deadlock between the processes does that mean that there is starvation also?

My Thinking:
deadlock is no process using that resources , but starvation is like not giving chance to only that process so there is progress in starvation but not in deadlock
Is my thinking right?

$\endgroup$
0

6 Answers 6

12
$\begingroup$

You should first state the deadlock freedom property and the starvation freedom property more precisely.

I use the definition in the Book: The Art of Multiprocessor Programming; Section 2.2.

Freedom from Deadlock If some thread attempts to acquire the lock, then some thread (not necessarily the thread referred to in the if statement; emphasis added) will succeed in acquiring the lock.

Freedom from Starvation Every thread that attempts to acquire the lock eventually succeeds.

Note that by definition, starvation freedom implies deadlock freedom. Thus, if a mutual exclusion algorithm suffers from deadlock, it also suffers from starvation.

A direct argument is that: deadlock means that some thread attempts to acquire the lock, but no threads succeed. That is a special kind of starvation.

$\endgroup$
2
  • 1
    $\begingroup$ Your "deadlock" definition doesn't seem right. The simplest case is process A acquiring lock X and trying to acquire lock Y, and process B acquiring lock Y and then trying to acquire lock X. For every lock, some thread has succeeded. $\endgroup$
    – gnasher729
    Sep 30, 2017 at 21:13
  • $\begingroup$ @gnasher729, it is unfortunate that hengxin does not copy the full definition. Here is the full definition of "Freedom from Deadlock" as in that book: "If some thread attempts to acquire the lock, then some thread will succeed in acquiring the lock. If thread A calls lock() but never acquires the lock, then other threads must be completing an infinite number of critical sections." $\endgroup$
    – John L.
    Sep 6, 2018 at 17:06
1
$\begingroup$

Starvation, as the name suggested, is when a process can acquire the lock, but it is being overlooked. It starves even with resources being available.
There is no deadlock in starvation; each process can acquire the lock and release it successfully.
Let three processes A, B and C, compete for a resource. Processes A and B are being granted that resource interchangeably, and subsequently C starves indefinitely.
Imagine the lock as the door that is being knocked to get food, and only one person per a time can enter, lock it, eat, and then exit.
A deadlock is when that person died inside, it will never be opened again, and everyone will be dead. Unless a supervisor (OS) intervenes.
A starvation is when everyone can take a turn smoothly. However, there is a poor guy who whenever he knocked, someone else was inside. They will starve.
Gruesome, but easy to remember.

$\endgroup$
0
$\begingroup$

A process is in starvation when it is waiting for a resource that is continuously given to other processes. This is different then a deadlock where a resource is not being given to anyone because it is being held by a blocked process. So there is not necessarily starvation in a deadlock situation. There might be, but it would be independent of the deadlocked processes.

$\endgroup$
0
$\begingroup$

In both cases you will have a infinite waiting. The difference's Deadlock is when two or more processess are waiting for each other, like a cicrular waiting. On the other hand, starvation is also a kind of waiting, but proccess is expecting a resource that will never be available. So the difference is deadlock occurs between processess and starvation you'll have a process and a "servant" resource.

$\endgroup$
-1
$\begingroup$

Both the cases, CPU needs to wait infinitely, as deadlock definition says:A system is in deadlock if more than one process waiting for a instances that never going to happen. Similarly, in starvation also, the process need to wait infinitely to get their chance to execute.

$\endgroup$
1
  • 1
    $\begingroup$ That's not the definition of deadlock at all. Furthermore, you've essentially said, "Every X is Y and every Z is Y, therefore, every X is Z." (Here, X=deadlock, Y=wait indefinitely, Z=starvation.) That's faulty logic -- every horse has four legs, every cat has four legs, but not every horse is a cat. $\endgroup$ Nov 10, 2017 at 11:23
-1
$\begingroup$

definitely NO deadlock means infinite waiting time and starvation is not a infinite waiting time the process has to definitely take the opportunity to be execute after the some amount of time.

$\endgroup$
1
  • $\begingroup$ Did you read the accepted answer that has been written for nearly two years? If starvation does not imply infinite waiting time, could you explain what do you mean by starvation? $\endgroup$
    – John L.
    Sep 6, 2018 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.