/** * The given thread could not get the given lock and is waiting for it. * Update the graph. */ Deadlock lockWaitStart(Thread client, ISchedulingRule lock) { setToWait(client, lock, false); int lockIndex = indexOf(lock, false); int[] temp = new int[lockThreads.size()]; //check if the addition of the waiting thread caused deadlock if (!checkWaitCycles(temp, lockIndex)) return null; //there is a deadlock in the graph Thread[] threads = getThreadsInDeadlock(client); //find a thread whose locks can be suspended to resolve the deadlock Thread candidate = resolutionCandidate(threads); ISchedulingRule[] locksToSuspend = realLocksForThread(candidate); Deadlock deadlock = new Deadlock(threads, locksToSuspend, candidate); reportDeadlock(deadlock); if (JobManager.DEBUG_DEADLOCK) throw new IllegalStateException("Deadlock detected. Caused by thread " + client.getName() + '.'); //$NON-NLS-1$ // Update the graph to indicate that the locks will now be suspended. // To indicate that the lock will be suspended, we set the thread to wait for the lock. // When the lock is forced to be released, the entry will be cleared. for (int i = 0; i < locksToSuspend.length; i++) setToWait(deadlock.getCandidate(), locksToSuspend[i], true); return deadlock; }
/** * The given thread could not get the given lock and is waiting for it. * Update the graph. */ Deadlock lockWaitStart(Thread client, ISchedulingRule lock) { setToWait(client, lock, false); int lockIndex = indexOf(lock, false); int[] temp = new int[lockThreads.size()]; //check if the addition of the waiting thread caused deadlock if (!checkWaitCycles(temp, lockIndex)) return null; //there is a deadlock in the graph Thread[] threads = getThreadsInDeadlock(client); Thread candidate = resolutionCandidate(threads); ISchedulingRule[] locksToSuspend = realLocksForThread(candidate); Deadlock deadlock = new Deadlock(threads, locksToSuspend, candidate); //find a thread whose locks can be suspended to resolve the deadlock if (JobManager.DEBUG_LOCKS) reportDeadlock(deadlock); if (JobManager.DEBUG_DEADLOCK) throw new IllegalStateException("Deadlock detected. Caused by thread " + client.getName() + '.'); //$NON-NLS-1$ // Update the graph to indicate that the locks will now be suspended. // To indicate that the lock will be suspended, we set the thread to wait for the lock. // When the lock is forced to be released, the entry will be cleared. for (int i = 0; i < locksToSuspend.length; i++) setToWait(deadlock.getCandidate(), locksToSuspend[i], true); return deadlock; }
/** * The given thread could not get the given lock and is waiting for it. * Update the graph. */ Deadlock lockWaitStart(Thread client, ISchedulingRule lock) { setToWait(client, lock, false); int lockIndex = indexOf(lock, false); int[] temp = new int[lockThreads.size()]; //check if the addition of the waiting thread caused deadlock if (!checkWaitCycles(temp, lockIndex)) return null; //there is a deadlock in the graph Thread[] threads = getThreadsInDeadlock(client); //find a thread whose locks can be suspended to resolve the deadlock Thread candidate = resolutionCandidate(threads); ISchedulingRule[] locksToSuspend = realLocksForThread(candidate); Deadlock deadlock = new Deadlock(threads, locksToSuspend, candidate); reportDeadlock(deadlock); if (JobManager.DEBUG_DEADLOCK) throw new IllegalStateException("Deadlock detected. Caused by thread " + client.getName() + '.'); //$NON-NLS-1$ // Update the graph to indicate that the locks will now be suspended. // To indicate that the lock will be suspended, we set the thread to wait for the lock. // When the lock is forced to be released, the entry will be cleared. for (int i = 0; i < locksToSuspend.length; i++) setToWait(deadlock.getCandidate(), locksToSuspend[i], true); return deadlock; }
/** * The given thread could not get the given lock and is waiting for it. * Update the graph. */ Deadlock lockWaitStart(Thread client, ISchedulingRule lock) { setToWait(client, lock, false); int lockIndex = indexOf(lock, false); int[] temp = new int[lockThreads.size()]; //check if the addition of the waiting thread caused deadlock if (!checkWaitCycles(temp, lockIndex)) return null; //there is a deadlock in the graph Thread[] threads = getThreadsInDeadlock(client); //find a thread whose locks can be suspended to resolve the deadlock Thread candidate = resolutionCandidate(threads); ISchedulingRule[] locksToSuspend = realLocksForThread(candidate); Deadlock deadlock = new Deadlock(threads, locksToSuspend, candidate); reportDeadlock(deadlock); if (JobManager.DEBUG_DEADLOCK) throw new IllegalStateException("Deadlock detected. Caused by thread " + client.getName() + '.'); //$NON-NLS-1$ // Update the graph to indicate that the locks will now be suspended. // To indicate that the lock will be suspended, we set the thread to wait for the lock. // When the lock is forced to be released, the entry will be cleared. for (int i = 0; i < locksToSuspend.length; i++) setToWait(deadlock.getCandidate(), locksToSuspend[i], true); return deadlock; }