Patent ID: 7984444

Claim:
A method for acquiring a lock associated with a shared resource, comprising: selecting, by a thread, a first node from a plurality of nodes preallocated for the lock, wherein the lock is configured to protect the shared resource such that the thread is required to acquire the lock prior to being able to access the shared resource, and wherein the plurality of nodes is constant and independent of a number of threads requesting the lock; making a first node acquisition attempt, by the thread, to acquire the first node; making a first node insertion attempt, by the thread, to insert the first node into a wait queue associated with the lock, upon success of the first node acquisition attempt; acquiring the lock, by the thread, based on a position of the first node in the wait queue, upon success of the first node insertion attempt; determining, by the thread, whether a first time period specified for the thread to acquire the lock has elapsed, upon failure of the first node acquisition attempt; when the first time period has elapsed: aborting, by the thread, any further attempts to acquire one of the plurality of nodes for the lock; when the first time period has not elapsed: waiting, by the thread, for a second time period; when the first time period has not elapsed and the second time period has elapsed: selecting, by the thread, a second node from the plurality of nodes for the lock; and making, by the thread, a second node acquisition attempt to acquire the second node.