# US 2008/0313656 A1 · User mode stack disassociation

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

- Number: US 2008/0313656 A1
- Document ID: US20080313656A1
- Status: Published application
- Kind: A1
- Application number: 11/820,164
- Filed: 2007-06-18
- Published: 2008-12-18
- Earliest claimed: 2007-06-18
- Assignees: Microsoft Corporation
- Inventors: Matthew D. Klein; Paul England
- Web page: https://patentgrep.com/patent/US20080313656A1

## CPC

- G06F 9/545: {where tasks reside in different layers, e.g. user- and kernel-space}
- G06F 9/544: {Buffers; Shared memory; Pipes}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Various technologies and techniques are disclosed for allowing a user mode stack to be shared by multiple contexts. A user mode stack can be shared between execution contexts that are guaranteed to not need the user mode stack at the same time. For example, each user mode portion of a kernel thread is provided with a dedicated backing thread. When a respective dedicated backing thread is sleeping and not using a respective user mode stack, the user mode stack is allowed to float with a respective user mode portion to other kernel threads. The user mode stack is disassociated from the kernel portion of the thread. The kernel is notified of an address of a user mode thread context. The kernel mode portion of the converted thread becomes a backing thread that waits. The user mode portion of the converted thread can be switched without entering the kernel.

## Claims

### Claim 1

A computer-readable medium having computer-executable instructions for causing a computer to perform steps comprising:
share a user mode stack between at least two execution contexts that are guaranteed to not need the user mode stack at a same time.

### Claim 2 (depends on 1)

The computer-readable medium of claim 1, wherein one of the at least two execution contexts is a kernel thread other than an initial kernel thread that is initially associated with the user mode stack.

### Claim 3 (depends on 1)

The computer-readable medium of claim 1, wherein one of the at least two execution contexts is a dedicated backing thread.

### Claim 4 (depends on 1)

The computer-readable medium of claim 1, further having computer-executable instructions for causing a computer to perform steps comprising:
provide a user mode portion of a kernel thread with a dedicated backing thread, with the user mode stack being assigned to the user mode portion.

### Claim 5 (depends on 4)

The computer-readable medium of claim 4, wherein the user mode stack floats with the user mode portion to other kernel threads when the dedicated backing thread is sleeping.

### Claim 6 (depends on 5)

The computer-readable medium of claim 5, wherein the user mode stack is correctly re-associated with the dedicated backing thread when the dedicated backing thread wakes up.

### Claim 7

A method for sharing a user mode stack between multiple contexts comprising the steps of:
providing each user mode portion of a kernel thread with a dedicated backing thread; and
when a respective dedicated backing thread is sleeping and not using a respective user mode stack, allowing the user mode stack to float with a respective user mode portion to other kernel threads.

### Claim 8 (depends on 7)

The method of claim 7, further comprising:
re-associating the respective user mode stack with the respective backing thread when the respective backing thread wakes up.

### Claim 9 (depends on 7)

The method of claim 7, wherein the respective backing thread is woken up when the user mode portion needs to perform work on the respective backing thread.

### Claim 10 (depends on 9)

The method of claim 9, wherein execution is resumed in a user mode procedure that restores correct values before continuing execution.

### Claim 11 (depends on 10)

The method of claim 10, wherein the correct values include an instruction pointer.

### Claim 12 (depends on 10)

The method of claim 10, wherein the correct values include a stack pointer.

### Claim 13 (depends on 10)

The method of claim 10, wherein the correct values include non-volatile register values.

### Claim 14 (depends on 7)

The method of claim 7, wherein the respective user mode stack is not dedicated to the backing thread.

### Claim 15 (depends on 7)

A computer-readable medium having computer-executable instructions for causing a computer to perform the steps recited in claim 7.

### Claim 16

A method for disassociating a user mode stack from a kernel portion of a thread comprising the steps of:
when a particular thread is converted to a converted thread that can be switched in user mode, notifying a kernel of an address of a user mode thread context;
a kernel mode portion of the converted thread becomes a backing thread that waits using a kernel mode wait primitive; and
allowing a user mode runtime to switch a user mode portion of the converted thread without entering the kernel.

### Claim 17 (depends on 16)

The method of claim 16, wherein during process initialization, a context restoration procedure is registered with the kernel.

### Claim 18 (depends on 16)

The method of claim 16, wherein the address remains constant for a life of the user mode portion.

### Claim 19 (depends on 16)

The method of claim 16, wherein the address is stored in a kernel mode thread control structure for later retrieval.

### Claim 20 (depends on 16)

A computer-readable medium having computer-executable instructions for causing a computer to perform the steps recited in claim 16.
