Patent ID: 8914588

Claim:
A system for supporting a locking mechanism in a transactional middleware machine environment, comprising: a semaphore provided by an operating system running on a plurality of processors, wherein the semaphore operates to control access to data in a shared memory; and a test-and-set (TAS) assembly component that is associated with a process of one or more processes, wherein each said process operates to use the TAS assembly component to perform one or more TAS operations in order to obtain a lock for data in the shared memory, wherein the process operates to be blocked on the semaphore and waits for a release of a lock on data in the shared memory, after the TAS component has performed a specified maximum rounds of TAS operations allowed and failed to obtain the lock, and wherein a spin count, which is the specified number of maximum rounds of TAS operations allowed, is determined periodically, wherein the spin count is increased from the spin count of a previous period, if a number of spin failures in the previous period exceeds a spin failure limit and a CPU idle ratio in the previous period is below a CPU idle ratio limit, and the spin count is decreased from the spin count of a previous period, if the CPU idle ratio exceeds a CPU idle ratio limit.