As I understand it:
- Livelock: a thread won’t make progress but yet it’s executing forever (the thread is infinitely alive): for example, it’s in an loop infinitely trying to get access to a shared resource that will never be available again.
- Deadlock: a thread doesn’t make progress but it’s not even executing (the thread is infinitely sleeping, and hence dead): it’s waiting to be waken up by the OS based on a condition that will never happen.
- Starvation: a thread doesn’t make progress and it’s blocking (like in a deadlock), but the condition being waited for to be waken up do occur, it just happens that there are other threads that always take my place before me.
First, are those definitions more or less correct? If they are, do they also apply for single thread programs? For example:
<code>// begin of useful work
until (some_buggy_condition_that_will_never_be_satisfied())
do_something();
// end of useful work
</code>
<code>// begin of useful work
until (some_buggy_condition_that_will_never_be_satisfied())
do_something();
// end of useful work
</code>
// begin of useful work
until (some_buggy_condition_that_will_never_be_satisfied())
do_something();
// end of useful work
In the example above, the loop will execute forever because the condition, that has nothing to do with shared resources, has a bug in it and will never be satisfied. So the thread:
- It’s executing.
- To do useful work the loop must end
- The loop will never end because the condition to end will never be satisfied
So that list omatches my livelock definition above, it just that I’m using the term outside concurrency contexts. Is that ok?