Beispiel #1
0
void Lock::printOutCircularDeadLock(Thread* starting)
{
  debug(LOCK, "CIRCULAR DEADLOCK when waiting for %s (%p) with thread %s (%p)!\n",
        getName(), this, currentThread->getName(), currentThread);
  debug(LOCK, "Printing out the circular deadlock:\n");
  currentThread->lock_waiting_on_ = this;
  // in this case we can access the other threads, because we KNOW that they are indirectly waiting on the current thread.
  for(Thread* thread = starting; thread != 0; thread = thread->lock_waiting_on_->held_by_)
  {
    Thread * holding = thread->lock_waiting_on_->held_by_;
    Lock* lock = thread->lock_waiting_on_;
    debug(LOCK, "Thread %-40.40s (%p) holding lock %-40.40s (%p), waiting for lock %-40.40s (%p)\n",
          holding->getName(), holding, lock->getName(),
          lock, holding->lock_waiting_on_->getName(),
          holding->lock_waiting_on_);
    if(kernel_debug_info)
    {
      debug(LOCK, "This lock has been locked at ");
      kernel_debug_info->printCallInformation(lock->last_accessed_at_);
    }
    // In the thread we are looking at is the current one, we have to stop.
    // It would result in an endless loop (circular print out ^^).
    if(thread == currentThread) break;
  }
}