# US 2003/0079094 A1 · Concurrent execution of critical sections by eliding ownership of locks

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2003/0079094 A1
- Document ID: US20030079094A1
- Status: Published application
- Kind: A1
- Application number: 10/037,041
- Filed: 2001-10-19
- Published: 2003-04-24
- Earliest claimed: 2001-10-19
- Assignees: Wisconsin Alumni Research Foundation
- Inventors: Ravi Rajwar; James R. Goodman
- Web page: https://patentgrep.com/patent/US20030079094A1

## CPC

- G06F 9/528: {by using speculative mechanisms}
- G06F 9/3004: {to perform operations on memory}
- G06F 9/30072: {to perform conditional operations, e.g. using predicates or guards}
- G06F 9/30087: {Synchronisation or serialisation instructions}
- G06F 9/3009: {Thread control instructions}
- G06F 9/3834: {Maintaining memory consistency}
- G06F 9/3842: {Speculative instruction execution}
- G06F 9/3851: {from multiple instruction streams, e.g. multistreaming}
- G06F 9/52: Program synchronisation; Mutual exclusion, e.g. by means of semaphores
- G06F 12/0808: with cache invalidating means (G06F12/0815 takes precedence)
- G06F 12/0844: Multiple simultaneous or quasi-simultaneous cache accessing
- G06F 12/0891: using clearing, invalidating or resetting means
- G06F 12/128: adapted to multidimensional cache systems, e.g. set-associative, multicache, multiset or multilevel
- G06F 12/1458: {by checking the subject access rights}
- G06F 12/1475: {in a virtual system, e.g. with translation means}
- G06F 12/12: Replacement control
- G06F 2212/1041: Resource optimization
- G06F 2212/1052: Security improvement
- G06F 2212/283: Plural cache memories
- G06F 2212/62: Details of cache specific to multiprocessor cache arrangements
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Critical sections of multi-threaded programs, normally protected by locks providing access by only one thread, are speculatively executed concurrently by multiple threads with elision of the lock acquisition and release. Upon a completion of the speculative execution without actual conflict as may be identified using standard cache protocols, the speculative execution is committed, otherwise the speculative execution is squashed. Speculative execution with elision of the lock acquisition, allows a greater degree of parallel execution in multi-threaded programs with aggressive lock usage.

## Claims

### Claim 1

A method of coordinating access to common memory by multiple program threads comprising the steps of:
in each given program thread,
(a) detecting the beginning of a critical section of the given program thread in which conflicts to access of the common memory could occur resulting from execution of other program threads;
(b) speculatively executing the critical section; and
(c) committing the speculative execution of the critical section if there has been no conflict and squashing the speculative execution of the critical section if there has been a conflict.

### Claim 2 (depends on 1)

The method of claim 1 wherein the conflict is:
(a) another thread writing data read by the given program thread in the critical section, or
(b) another thread reading or writing data written by the given program thread.

### Claim 3 (depends on 2)

The method of claim 2 wherein the conflict is detected by an invalidation of a cache block holding data of the critical section.

### Claim 4 (depends on 1)

The method of claim 1 wherein the speculative execution is committed at the end of the critical section.

### Claim 5 (depends on 4)

The method of claim 4 wherein the end of the critical section is detected by a pattern of instructions typically associated with a lock release.

### Claim 6 (depends on 5)

The method of claim 5 wherein the pattern of instructions is a store instruction to a deduced lock variable address.

### Claim 7 (depends on 1)

The method of claim 1 wherein the speculative execution is committed at a resource boundary limiting further speculation.

### Claim 8 (depends on 7)

The method of claim 7 including the step of:
(d) if at step (c) there was no conflict from the execution of another thread acquiring a lock variable allowing the given thread to have exclusive access to the critical section and continuing execution from the commitment point to the conclusion of the critical section.

### Claim 9 (depends on 1)

The method of claim 1 wherein the speculative execution is committed upon the occurrence of a non cacheable operation limiting further speculation.

### Claim 10 (depends on 9)

The method of claim 9 including the step of:
(d) if at step (c) there was no conflict from the execution of another thread acquiring a lock variable allowing the given thread to have exclusive access to the critical section and continuing execution from the commitment point to the conclusion of the critical section.

### Claim 11 (depends on 1)

The method of claim 1 wherein step (a) includes reading of a lock variable and wherein step (b) is performed only when the lock variable is not held by another program thread.

### Claim 12 (depends on 1)

The method of claim 1 wherein step (a) includes reading a prediction table holding historical data indicating past successes in speculatively executing the critical section and wherein step (b) is performed only when the prediction table indicates a likelihood of successful speculative execution of the critical section of above a predetermined threshold.

### Claim 13 (depends on 1)

The method of claim 1 wherein step (a) deduces the beginning of a critical section by detecting patterns of instructions typically associated with a lock acquisitions.

### Claim 14 (depends on 13)

The method of claim 13 wherein the pattern includes an atomic read/modify/write sequence.

### Claim 15 (depends on 1)

The method of claim 1 wherein the critical section is preceded by a lock acquisition section and including the step of eliding the lock acquisition before step (b).

### Claim 16 (depends on 1)

The method of claim 1 wherein the critical section ends with a lock release section and including the step of eliding the lock release section after step (c) when at step (c) upon reaching the end of the critical section, no conflict from the execution of another thread occurred.

### Claim 17 (depends on 1)

The method of claim 1 including the further step of:
(d) after squashing the speculative execution of the critical section if there has been a conflict, re-executing the critical section speculatively.

### Claim 18 (depends on 17)

The method of claim 17 wherein the speculative re-execution of the critical section is repeated up to a predetermined number of times until there is not a conflict.

### Claim 18 (depends on 17)

The method of claim 17 wherein (d) if after the predetermined number of tries there remains a conflict from the execution of another thread, acquiring a lock variable allowing the given thread to have exclusive access to the critical section and continuing execution of the critical section from its beginning.

### Claim 20 (depends on 1)

The method of claim 1 wherein the speculation executes the critical section using a cache memory to record the speculative execution without visibility to other processing units.

### Claim 21 (depends on 1)

The method of claim 1 wherein the speculation executes the critical section eliding write instructions that do not change a value of memory location being written to.

### Claim 22

A lock elision circuit for a computer architecture allowing the access of common memory by multiple program threads, the circuit comprising:
means for controlling the execution of each given program thread to:
(a) detect the beginning of a critical section of the given program thread in which conflicts to access of the common memory could occur resulting from execution of other program threads;
(b) speculatively execute the critical section; and
(c) commit the speculative execution of the critical section if there has been no conflict and squashing the speculative execution of the critical section if there has been a conflict.

### Claim 23 (depends on 22)

The lock elision circuit of claim 22 wherein the conflict is:
(a) another thread writing data read by the given program thread in the critical section, or
(b) another thread reading or writing data written by the given program thread.

### Claim 24 (depends on 23)

The lock elision circuit of claim 23 wherein the computer architecture includes a cache and the conflict is detected by an invalidation of a cache block holding data of the critical section.

### Claim 25 (depends on 22)

The lock elision circuit of claim 22 wherein the speculative execution is committed at the end of the critical section.

### Claim 26 (depends on 25)

The lock elision circuit of claim 25 wherein the end of the critical section is detected by a pattern of instructions typically associated with a lock release.

### Claim 27 (depends on 26)

The lock elision circuit of claim 26 wherein the pattern of instructions is a store instruction to a deduced lock variable address.

### Claim 28 (depends on 22)

The lock elision circuit of claim 22 wherein the speculative execution is committed at a resource boundary limiting further speculation.

### Claim 29 (depends on 28)

The lock elision circuit of claim 28 wherein when there is no conflict from the execution of another thread acquiring a lock variable, the lock elision circuit allows the given thread to have exclusive access to the critical section and continues execution from the commitment point to the conclusion of the critical section.

### Claim 30 (depends on 22)

The lock elision circuit of claim 22 wherein the lock elision circuit reads a lock variable and speculatively executes the critical section only when the lock variable is not held by another program thread.

### Claim 31 (depends on 22)

The lock elision circuit of claim 22 wherein the speculative execution is committed upon the occurrence of a non cacheable operation limiting further speculation.

### Claim 32 (depends on 31)

The lock elision circuit of claim 31 including the step of:
(d) if at step (c) there was no conflict from the execution of another thread acquiring a lock variable allowing the given thread to have exclusive access to the critical section and continuing execution from the commitment point to the conclusion of the critical section.

### Claim 33 (depends on 22)

The lock elision circuit of claim 22 including a prediction table holding historical data indicating past successes in speculatively executing the critical section and wherein the lock elision circuit speculatively executes the critical section only when the prediction table indicates a likelihood of successful speculative execution of the critical section of above a predetermined threshold.

### Claim 34 (depends on 22)

The lock elision circuit of claim 22 wherein the lock elision circuit determines the beginning of a critical section by detecting patterns of instructions typically associated with a lock acquisitions.

### Claim 35 (depends on 34)

The lock elision circuit of claim 34 wherein the pattern includes an atomic read/modify/write sequence.

### Claim 36 (depends on 22)

The lock elision circuit of claim 22 wherein the critical section is preceded by a lock acquisition section and wherein the lock elision circuit elides the lock acquisition before speculation.

### Claim 37 (depends on 22)

The lock elision circuit of claim 22 wherein the critical section ends with a lock release section and wherein the lock elision circuit elides the lock release section after speculation when upon reaching the end of the critical section, no conflict from the execution of another thread occurred.

### Claim 38 (depends on 22)

The lock elision circuit of claim 22 wherein after squashing the speculative execution of the critical section, if there has been a conflict, the lock elision circuit re-executes the critical section speculatively.

### Claim 39 (depends on 38)

The lock elision circuit of claim 38 wherein the lock elision circuit repeats the speculative re-execution of the critical section up to a predetermined number of times until there is not a conflict.

### Claim 40 (depends on 39)

The lock elision circuit of claim 39 wherein if after the predetermined number of tries there remains a conflict from the execution of another thread, the lock elision circuit allows acquisition of a lock variable allowing the given thread to have exclusive access to the critical section and continuing execution of the critical section from its beginning.

### Claim 41 (depends on 22)

The lock elision circuit of claim 22 wherein the computer architecture includes a cache memory and the lock elision circuit uses the cache memory to record the speculative execution without visibility to other processing units.

### Claim 42 (depends on 22)

The lock elision circuit of claim 22 wherein the lock elision circuit elides write instructions within the critical section that do not change a value of memory location being written to.
