Patent ID: 6862664

Claim:
A method for avoiding locks by speculatively executing critical sections of code, comprising: allowing a process to speculatively execute a critical section of code within a program without first acquiring a lock associated with the critical section; wherein if the process completes the critical section without encountering an interfering data access from another process, the method further comprises: committing changes made during the speculative execution, and resuming normal non-speculative execution of the program past the critical section; and wherein if an interfering data access from another process is encountered during execution of the critical section, the method further comprises: discarding changes made during the speculative execution, and attempting to re-execute the critical section zero or more times; wherein attemping to re-execute the critical section involves speculatively re-executing the critical section, wherein if the critical section is not successfully completed after a number of attempts at speculative execution, the method further comprises: acquiring a lock associated with the critical section, non-speculatively executing the critical section, and releasing the lock associated with the critical section.