# US 2019/0377582 A1 · Adaptive locking in elastic threading systems

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

- Number: US 2019/0377582 A1
- Document ID: US20190377582A1
- Status: Published application
- Kind: A1
- Application number: 16/004,412
- Filed: 2018-06-10
- Published: 2019-12-12
- Earliest claimed: 2018-06-10
- Assignees: International Business Machines Corporation
- Applicants: International Business Machines Corporation
- Inventors: Xavier Rene Guérin; Scott Schneider; Xiang Ni
- Web page: https://patentgrep.com/patent/US20190377582A1

## CPC

- G06F 8/45: {Exploiting coarse grain parallelism in compilation, i.e. parallelism between groups of instructions}
- G06F 9/3851: {from multiple instruction streams, e.g. multistreaming}
- G06F 9/30087: {Synchronisation or serialisation instructions}
- G06F 9/3009: {Thread control instructions}
- G06F 9/3017: {Runtime instruction translation, e.g. macros}
- G06F 9/5027: {the resource being a machine, e.g. CPUs, Servers, Terminals}
- G06F 9/524: {Deadlock detection or avoidance}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A multithreading system that performs elastic threading and dynamic patching is provided. The system receives a compiled object of a computing process, the compiled object comprising a set of locking instructions for ensuring exclusive access of a resource by the computing process. The system determines a thread count for the computing process. When the thread count indicates that a single thread is allocated to execute the computing process, the system patches the compiled object with a set of no-operation (NOP) instructions in place of the set of locking instructions. When the thread count indicates that two or more threads are allocated to execute the computing process, the system patches the compiled object with the set of locking instructions in place of the set of NOP instructions. The system executes the computing process according to the patched compiled object.

## Claims

### Claim 1

A computing device comprising:
a processor; and
a storage device storing a set of instructions, wherein an execution of the set of instructions by the processor configures the computing device to perform acts comprising:
receiving a compiled object of a computing process, the compiled object comprising a set of locking instructions for ensuring exclusive access of a resource by the computing process;
determining a thread count for the computing process;
upon determining that the thread count indicates that a single thread is allocated to execute the computing process, patching the compiled object with a set of no-operation (NOP) instructions in place of the set of locking instructions; and
executing the computing process according to the patched compiled object.

### Claim 2 (depends on 1)

The computing device of claim 1, wherein the execution of the set of instructions by the processor further configures the computing device to perform acts comprising:
upon determining that the thread count indicates that two or more threads are allocated to execute the computing process, patching the compiled object with the set of locking instructions in place of the set of NOP instructions.

### Claim 3 (depends on 1)

The computing device of claim 1, wherein:
the compiled object comprises a preamble symbol that points to the set of locking instructions, and
the patching comprises using the preamble symbol to locate the set of locking instructions and to determine a number of NOP instructions to patch in place of the set of locking instructions.

### Claim 4 (depends on 1)

The computing device of claim 1, wherein:
the compiled object comprises a set of unlocking instructions for releasing the computing resource locked by the set of locking instructions,
the set of NOP instruction is a first set of NOP instructions, and
the execution of the set of instructions by the processor further configures the computing device to perform acts comprising:
upon determining that the thread count indicates that a single thread is allocated to execute the computing process, patching the compiled object with a second set of NOP instructions in place of the set of unlocking instructions.

### Claim 5 (depends on 4)

The computing device of claim 4, wherein the execution of the set of instructions by the processor further configures the computing device to perform acts comprising:
upon determining that the thread count indicates that two or more threads are allocated to execute the computing process, patching the compiled object with the set of unlocking instructions in place of the second set of NOP instructions.

### Claim 6 (depends on 4)

The computing device of claim 4, wherein:
the compiled object comprises a postamble symbol that points to the set of unlocking instructions, and
patching the compiled object comprises using the postamble symbol to locate the set of unlocking instructions and to determine a number of NOP instructions to patch in place of the set of unlocking instructions.

### Claim 7

A computer program product comprising:
one or more non-transitory computer-readable storage devices and program instructions stored on at least one of the one or more non-transitory storage devices, the program instructions executable by a processor, the program instructions comprising sets of instructions for:
determining a number of threads for executing a compiled object of a computing process that comprises a set of one or more preamble instructions that is (i) a set of locking instruction for ensuring exclusive access of a computing resource by one thread of the computing process or (ii) a set of placeholder instructions in place of the locking instruction;
upon determining that the number of threads is one, altering the compiled object by replacing the set of preamble instructions with the set of placeholder instructions;
upon determining that the number of threads is two or more, altering the compiled object by replacing the set of preamble instruction with the set of locking instruction; and
providing the altered compiled object for execution by the processor.

### Claim 8 (depends on 7)

The computer program product of claim 7, wherein the set of placeholder instructions comprises no-operation (NOP) instructions.

### Claim 9 (depends on 7)

The computer program product of claim 7, wherein:
the compiled object comprises a preamble symbol that points to the set of locking instructions, and
replacing the set of preamble instructions with the set of placeholder instructions comprises using the preamble symbol to locate the set of locking instructions and to determine a number of NOP instructions to patch in place of the set of locking instructions.

### Claim 10 (depends on 7)

The computer program product of claim 7, wherein the set of locking instructions includes a branching instruction to a routine that locks the resource for the computing process.

### Claim 11 (depends on 7)

The computer program product of claim 7, wherein:
the compiled object comprises a set of unlocking instructions for releasing the computing resource locked by the set of locking instructions, and
the set of placeholder instruction is a first set of placeholder instructions, the program instructions further comprising sets of instructions for:
upon determining that the number of threads is one, altering the compiled object by replacing the set of postamble instructions with the set of placeholder instructions.

### Claim 12 (depends on 11)

The computer program product of claim 11, the program instructions further comprising sets of instructions for:
upon determining that the number of threads is two or more, altering the compiled object by replacing the set of postamble instruction with the set of unlocking instruction.

### Claim 13 (depends on 11)

The computer program product of claim 11, wherein:
the compiled object comprises a postamble symbol that points to the set of unlocking instructions, and
replacing the set of postamble instructions with the set of placeholder instructions comprises using the postamble symbol to locate the set of unlocking instructions and to determine a number of NOP instructions to patch in place of the set of unlocking instructions.

### Claim 14

A computer-implemented method comprising:
receiving a compiled object of a computing process, the compiled object comprising a set of locking instructions for ensuring exclusive access of a resource by the computing process;
determining a thread count for the computing process;
upon determining that the thread count indicates that a single thread is allocated to execute the computing process, patching the compiled object with a set of no-operation (NOP) instructions in place of the set of locking instructions; and
executing the computing process according to the patched compiled object.

### Claim 15 (depends on 14)

The computer-implemented method of claim 14, further comprising:
upon determining that the thread count indicates that two or more threads are allocated to execute the computing process, patching the compiled object with the set of locking instructions in place of the set of NOP instructions.

### Claim 16 (depends on 14)

The computer-implemented method of claim 14, wherein:
the compiled object comprises a preamble symbol that points to the set of locking instructions, and
the patching comprises using the preamble symbol to locate the set of locking instructions and to determine a number of NOP instructions to patch in place of the set of locking instructions.

### Claim 17 (depends on 14)

The computer-implemented method of claim 14, wherein the set of locking instructions includes a branching instruction to a routine that locks the resource for the computing process.

### Claim 18 (depends on 14)

The computer-implemented method of claim 14, wherein:
the compiled object comprises a set of unlocking instructions for releasing the computing resource locked by the set of locking instructions, and
the set of NOP instruction is a first set of NOP instructions, the computer-implemented method further comprising:
upon determining that the thread count indicates that a single thread is allocated to execute the computing process, patching the compiled object with a second set of NOP instructions in place of the set of unlocking instructions.

### Claim 19 (depends on 18)

The computer-implemented method of claim 18, further comprising:
upon determining that the thread count indicates that two or more threads are allocated to execute the computing process, patching the compiled object with the set of unlocking instructions in place of the second set of NOP instructions.

### Claim 20 (depends on 18)

The computer-implemented method of claim 18, wherein:
the compiled object comprises a postamble symbol that points to the set of unlocking instructions, and
patching the compiled object comprises using the postamble symbol to locate the set of unlocking instructions and to determine a number of NOP instructions to patch in place of the set of unlocking instructions.
