7

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?

6 Answers6

13

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.

hengxin
  • 9,671
  • 3
  • 37
  • 75
1

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.

N. Osil
  • 111
  • 2
0

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.

lPlant
  • 1,622
  • 9
  • 19
0

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.

andre
  • 1
  • 1
-1

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.

-1

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.