38.7.1 How the System Detects a Deadlock
Deadlock detection is a process performed on a time interval basis. It is carried out in four major phases:
1. Identifying stalled tasks -- To identify tasks that are stalled, all dispatch control elements (DCEs) in the system are examined. Any DCE found stalled while waiting on an internal resource is entered into the deadlock detection matrix (DDM). All subsequent processing begins with the DCE address stored in the DDM table. This eliminates the need to scan all DCEs in the system.
2. Identifying task dependencies -- Next, the dependencies between the stalled tasks are identified. The deadlock detection matrix is updated. For each task on which another task is waiting, a bit in the deadlock detection matrix is set to one.
3. Identifying deadlocks -- To determine which tasks are involved in a deadlock cycle, a transformation is performed on the matrix. From this process, a pair of deadlocked tasks is identified. From this pair, a victim is selected.
4. Selecting a victim -- The task running for the shortest period of time is chosen as the victim of the two tasks as long as:
[o] The priority of the victim task is less than that of the other task
[o] The victim task's wait was not entered with COND=NONE and the other task's wait was entered with COND=DEAD
The task running for the shortest period of time is chosen as the victim because it is more likely that it will have consumed fewer resources than a longer running task. As a result, less duplication of work should be required when the victim is restarted, with these exceptions:
[o] If the other task is of a higher priority, implying that it is of more importance
[o] If the victim task entered the deadlock with COND=NONE and the other task specified COND=DEAD. In this case, the task specifying COND=DEAD is chosen as the victim since COND=DEAD indicates that the task is designed to handle and recover from deadlock situations. This prevents an abend.
Victim Selection User Exit: The algorithm used to select a victim in a deadlock situation may not be optimal for your installation or applications.
User exit 30 allows victims to be selected based upon specific requirements. The exit is passed the DCE addresses of each pair of deadlocked tasks and may take one of two actions:
[o] Choose one of the tasks as the victim task
[o] Return control to the deadlock detector by requesting that the default deadlock detection logic be applied
>> For a discussion of user exit 30, refer to Advantage CA-IDMS System Operations.
Deadlock Detection Interval: You can control the frequency with which the deadlock detection mechanism searches for deadlocked tasks using the DEADLOCK DETECTION parameter of the SYSTEM statement.
The DEADLOCK DETECTION parameter allows you to specify the amount of time that elapses before the deadlock detection mechanism searches for deadlocked tasks. Note that in an idle system, deadlock detection is also idled until new tasks are started. This eliminates CPU consumption for deadlock detection when no tasks could possibly be deadlocked.
You can use the
DCMT VARY DEADLOCK command at runtime to override the system generation specification.
For further information on the DEADLOCK DETECTION parameter of the SYSTEM statement, refer to Advantage CA-IDMS System Generation. For further information on the DCMT VARY DEADLOCK command, refer to Advantage CA-IDMS System Tasks and Operator Commands.
--------------------------------------------------------------------------------
George Lewandowski
Database Administrator
GIS