4

The definition of a deadlock is when two or more threads cannot complete their execution because they are mutually blocked and waiting for something from the other thread(s).

Is there a similar term for when two or more threads take a long time to finish, rather than never finish, because they're waiting for another thread to complete?

  • 5
    Yes. It's called a "performance issue." – Mohair Dec 14 '15 at 20:52
  • you use the term "latency"? – Caleb Dec 14 '15 at 20:59
  • 3
    This question has been closed and reopened, and its comments wiped, once already. Let's keep the interaction to actual answers this time, rather than speculating in the comments. – Robert Harvey Dec 14 '15 at 21:10
  • Do you mean that the threads wait on purpose (like if they need a result computed by the other thread) or by accident (like the other thread forgot to release a lock and only does so after it finishes)? – 5gon12eder Dec 14 '15 at 21:20
  • @5gon12eder In this specific case it's that they're accessing a shared resource, but I don't see why the general case wouldn't include generally waiting on purpose. – Ian Newson Dec 14 '15 at 22:06
9

The term for this type of behaviour is Thread Synchronization. Also sometimes called serialization because the threads must get in line and go through that piece of code serially.

Lock Contention is a dimension that can be used to measure and predict the performance of a piece of code that requires thread synchronization. If 8 threads are contending for a lock vs. 4 threads, that speaks to how slowly your requests are going to complete for instance.

Thread Starvation is what occurs when all threads are busy, but new requests are coming in and there are no threads to service those requests. Thread starvation can be a side effect of contention, but you can have a highly-contentious system blocking everything into single threading without getting thread starvation depending on the size of your thread pool and or the number of work requests coming in.

So in short, when you have multiple threads contending for a single thing, those threads are said to be synchronized - or serialized in some parlances.

Further Reading
Lock Contention on Wikipedia
Starvation on Wikipedia

  • 2
    Man, this is probably a great answer, but I can't vote in good conscience because you posted it in The Whiteboard. :) – Aaron Hall Dec 14 '15 at 21:22
0

On many operating systems, it is possible to lock a mutex with a timeout. The timeout is typically either infinite (no timeout) or zero (a check whether a mutex is locked or not). Obviously I could have a mutex with a 12 hour timeout, so a "deadlock" would lock down the application for 12 hours without doing anything and then the deadlock stops.

On the other hand, if I try to acquire a mutex, and someone else holds it, working hard for twelve hours, that may not be optimal, but on a single core machine it might not even waste time. Of course that's not a deadlock - I think I've heard the term "livelock" for it, where one thread is locked out for a long time, but the application as a whole actually makes good progress.

  • 1
    I have heard the term live lock before but couldn't remember the meaning of it; according to this answer on SO however, it's not quite as you describe.. – Jimmy Hoffa Dec 14 '15 at 21:56
  • 1
    I think that this is a decent answer except for the term “livelock”. – 5gon12eder Dec 14 '15 at 22:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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