Patent ID: 8117616

Claim:
A method, comprising: providing a deadlock prevention mode indicator, wherein the deadlock prevention mode indicator can be held in a shared mode or in an exclusive mode by one or more of a plurality of threads, wherein the plurality of threads can cause deadlocks while acquiring a plurality of data locks; and serializing, an execution of the plurality of threads, by allowing a data lock to be acquired by a thread in response to the thread holding the deadlock prevention mode indicator, wherein serializing the plurality of threads avoids any deadlock from occurring; and downgrading the deadlock prevention mode indicator from the exclusive mode to the shared mode, in response to determining from downgrading rules that the deadlock prevention mode indicator can be safely downgraded, wherein the downgrading further comprises atomically moving the deadlock prevention mode indicator from the exclusive mode to the shared mode, and wherein the serializing further comprises: determining, whether the thread is of a safe thread type or an unsafe thread type, wherein safe threads are those threads that never block while attempting an out of order data lock, and wherein unsafe threads may block while attempting an out of order data lock; in response to determining that the thread is of the safe thread type, and determining that the deadlock prevention mode indicator is not being held in exclusive mode by another thread, acquiring the deadlock prevention mode indicator in a shared mode; in response to determining that the thread is of the unsafe thread type, and determining that the deadlock prevention mode indicator is not being held by another thread, acquiring the deadlock prevention mode indicator in an exclusive mode.