# US 2009/0271789 A1 · Method, apparatus and article of manufacture for timeout waits on locks

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

- Number: US 2009/0271789 A1
- Document ID: US20090271789A1
- Status: Published application
- Kind: A1
- Application number: 12/111,157
- Filed: 2008-04-28
- Published: 2009-10-29
- Earliest claimed: 2008-04-28
- Assignees: International Business Machines Corporation
- Inventors: ALAN F. BABICH
- Web page: https://patentgrep.com/patent/US20090271789A1

## CPC

- G06F 9/526: {Mutual exclusion algorithms}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Embodiments of the invention provide techniques for performing timeout waits of process threads. Generally, a thread requesting access to locked resource sends a timeout request to a timeout handler process, and then goes to sleep. The timeout request is received by a receiving thread of the timeout handler process. The receiving thread may insert the timeout request into a minimum heap of timeout requests, and may determine whether the inserted request is due earlier than any of the existing timeout requests. If so, the receiving thread may interrupt a timing thread of the timeout handler process. The timing thread may then wait until reaching the requested timeout, and then send a wakeup message to the sleeping thread.

## Claims

### Claim 1

A computer-implemented method for performing a timeout wait for a thread requesting access to a shared resource locked by a process lock, comprising:
sending, by a first thread, a timeout request message to a timeout handler process;
transitioning the first thread to an indefinitely blocked state;
determining, from the timeout request message, a timeout period after which the first thread should be unblocked from the indefinitely blocked state while waiting to access to the shared resource;
storing the timeout request message in a data structure configured to store a plurality of timeout request messages; and
upon determining that the timeout period has elapsed and that the first thread is still requesting access to the shared resource, sending a wakeup message to a message queue associated with the indefinitely blocked thread.

### Claim 2 (depends on 1)

The computer-implemented method of claim 1, further comprising, prior to storing the timeout request message in the data structure:
upon determining that the timeout period ends prior to any time period in the plurality of timeout request messages stored in the data structure:
interrupting a timing thread performing a sleep period corresponding to the earliest time period; and
setting a new sleep period for the timing thread to correspond to the timeout period specified in the a timeout request message sent by the first thread.

### Claim 3 (depends on 2)

The computer-implemented method of claim 2, wherein the timeout handler process includes a message receiving thread, the timing thread and the data structure.

### Claim 4 (depends on 1)

The computer-implemented method of claim 1, wherein the data structure is a minimum heap.

### Claim 5 (depends on 4)

The computer-implemented method of claim 4, wherein each node of the minimum heap stores one of the plurality of timeout request messages, and wherein the minimum heap is sorted based on a timeout period corresponding to each respective timeout request message.

### Claim 6 (depends on 5)

The computer-implemented method of claim 5, wherein the timeout period corresponding to each respective timeout request message is determined from at least one of: (i) a wakeup time specified in the timeout request message, and (ii) a timeout period specified in the timeout request message.

### Claim 7 (depends on 1)

The computer-implemented method of claim 1, further comprising, in response to receiving the wakeup message, unblocking the first thread.

### Claim 8 (depends on 1)

The computer-implemented method of claim 1, wherein determining that the first thread is still requesting access to the shared resource comprises evaluating one or more data elements of a thread control record corresponding to the first thread.

### Claim 9 (depends on 8)

The computer-implemented method of claim 8, wherein the one or more data elements comprise at least one of: (i) a process identifier, (ii) a thread identifier, and (iii) a variable indicating the number of times that the sleeping thread has waited in a timeout wait.

### Claim 10

A computer-readable storage medium containing a program, which when executed on a processor performs an operation, comprising:
sending, by a first thread, a timeout request message to a timeout handler process;
transitioning the first thread to an indefinitely blocked state;
determining, from the timeout request message, a timeout period after which the first thread should be unblocked from the indefinitely blocked state while waiting to access to the shared resource;
storing the timeout request message in a data structure configured to store a plurality of timeout request messages; and
upon determining that the timeout period has elapsed and that the first thread is still requesting access to the shared resource, sending a wakeup message to a message queue associated with the indefinitely blocked thread.

### Claim 11 (depends on 10)

The storage medium of claim 10, further comprising, prior to storing the timeout request message in the data structure:
upon determining that the timeout period ends prior to any time period in the plurality of timeout request messages stored in the data structure:
interrupting a timing thread performing a sleep period corresponding to the earliest time period; and
setting a new sleep period for the timing thread to correspond to the timeout period specified in the a timeout request message sent by the first thread.

### Claim 12 (depends on 11)

The storage medium of claim 11, wherein the timeout handler process includes a message receiving thread, the timing thread and the data structure.

### Claim 13 (depends on 10)

The storage medium of claim 10, wherein the data structure is a minimum heap.

### Claim 14 (depends on 13)

The storage medium of claim 13, wherein each node of the minimum heap stores one of the plurality of timeout request messages, and wherein the minimum heap is sorted based on a timeout period corresponding to each respective timeout request message.

### Claim 15 (depends on 14)

The storage medium of claim 14, wherein the timeout period corresponding to each respective timeout request message is determined from at least one of: (i) a wakeup time specified in the timeout request message, and (ii) a timeout period specified in the timeout request message.

### Claim 16 (depends on 10)

The storage medium of claim 10, further comprising, in response to receiving the wakeup message, unblocking the first thread.

### Claim 17 (depends on 10)

The storage medium of claim 10, wherein determining that the first thread is still requesting access to the shared resource comprises evaluating one or more data elements of a thread control record corresponding to the first thread.

### Claim 18 (depends on 17)

The storage medium of claim 17, wherein the one or more data elements comprise at least one of: (i) a process identifier, (ii) a thread identifier, and (iii) a variable indicating the number of times that the sleeping thread has waited in a timeout wait.

### Claim 19

A system, comprising:
a processor; and
a memory containing a program, which when executed by the processor is configured to perform the steps of:
sending, by a first thread, a timeout request message to a timeout handler process;
transitioning the first thread to an indefinitely blocked state;
determining, from the timeout request message, a timeout period after which the first thread should be unblocked from the indefinitely blocked state while waiting to access to the shared resource;
storing the timeout request message in a data structure configured to store a plurality of timeout request messages; and
upon determining that the timeout period has elapsed and that the first thread is still requesting access to the shared resource, sending a wakeup message to a message queue associated with the indefinitely blocked thread.

### Claim 20 (depends on 19)

The system of claim 19, further comprising, prior to storing the timeout request message in the data structure:
upon determining that the timeout period ends prior to any time period in the plurality of timeout request messages stored in the data structure:
interrupting a timing thread performing a sleep period corresponding to the earliest time period; and
setting a new sleep period for the timing thread to correspond to the timeout period specified in the a timeout request message sent by the first thread.
