# US 2017/0286186 A1 · Fast transfer of workload between multiple processors

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

- Number: US 2017/0286186 A1
- Document ID: US20170286186A1
- Status: Published application
- Kind: A1
- Application number: 15/189,868
- Filed: 2016-06-22
- Published: 2017-10-05
- Earliest claimed: 2016-03-29
- Assignees: Microsoft Technology Licensing, LLC
- Applicants: Microsoft Technology Licensing, LLC
- Inventors: Oleg Kagan
- Web page: https://patentgrep.com/patent/US20170286186A1

## CPC

- G06F 9/524: {Deadlock detection or avoidance}
- G06F 9/4812: {by interrupt, e.g. masked}
- G06F 9/4843: {by program, e.g. task dispatcher, supervisor, operating system}
- G06F 9/52: Program synchronisation; Mutual exclusion, e.g. by means of semaphores
- G06F 2209/509: Offload
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Techniques and systems for prescheduling an alternative CPU as soon as a need for a task is detected by a primary CPU are disclosed. A process includes detecting, by a producer thread running on a first CPU, an external interrupt, acquiring, by the producer thread, a spinlock, and in response to acquiring the spinlock, sending, by the producer thread, an event to a consumer thread that is to run on a second CPU. Upon receiving the event by the consumer thread, the consumer thread acquires the spinlock, which “stalls” the consumer thread in a loop until the spinlock is released by the producer thread. While the consumer thread is “waking up” in response to receiving the event from the producer thread, the producer thread creates a task, publishes the task, and releases the spinlock, thereby causing the consumer thread to exit the loop, retrieve the task, and execute the task.

## Claims

### Claim 1

A method comprising:
detecting, by a producer thread running on a first processor, an external interrupt;
acquiring, by the producer thread, a spinlock;
in response to acquiring the spinlock, sending, by the producer thread, an event;
creating, by the producer thread, a task;
publishing, by the producer thread, the created task;
in response to publishing the created task, releasing, by the producer thread, the spinlock;
in response to releasing the spinlock, retrieving, by a consumer thread running on a second processor, the published task; and
executing, by the consumer thread, the retrieved task.

### Claim 2 (depends on 1)

The method of claim 1, further comprising:
prior to retrieving the task, receiving, by the consumer thread, the event; and
in response to receiving the event, acquiring, by the consumer thread, the spinlock.

### Claim 3 (depends on 2)

The method of claim 2, wherein the consumer thread acquires the spinlock prior to the producer thread releasing the spinlock, and wherein acquiring, by the consumer thread, the spinlock comprises iteratively checking, by the consumer thread, a value of a spinlock parameter associated with the spinlock.

### Claim 4 (depends on 2)

The method of claim 2, wherein the consumer thread acquires the spinlock after the producer thread releases the spinlock.

### Claim 5 (depends on 1)

The method of claim 1, wherein:
the consumer thread is one of multiple consumer threads in a pool of consumer threads;
the producer thread is one of multiple producer threads in a pool of producer threads;
the task is one of multiple tasks; and
the event comprises a semaphore having a count equal to a number of the multiple consumer threads in the pool of consumer threads.

### Claim 6 (depends on 1)

The method of claim 1, wherein publishing the task comprises storing information to be utilized for executing the task in shared memory that is accessible to the second processor via the consumer thread.

### Claim 7 (depends on 1)

The method of claim 1, further comprising performing, by the consumer thread, loading operations while the producer thread creates the task and publishes the task, wherein the loading operations:
prepare the consumer thread to execute the task; and
are performed based at least in part on receipt of the event by the consumer thread.

### Claim 8

A system comprising:
multiple processors including a first processor and a second processor; and
memory storing computer-executable instructions that, when executed by at least one processor of the multiple processors, cause the at least one processor to perform operations comprising:
executing, by the second processor, an instruction causing the second processor to wait for an event;
executing a producer thread on the first processor based at least in part on an interrupt detected by the first processor;
setting, by the producer thread, a parameter associated with a synchronization primitive to a first value;
in response to setting the parameter to the first value, sending, by the producer thread, the event to the second processor;
executing a consumer thread on the second processor based at least in part on the second processor receiving the event;
performing, by the consumer thread, loading operations while the producer thread creates a task;
publishing, by the producer thread, the task for consumption;
setting, by the producer thread, the parameter to a second value;
in response to setting the parameter to the second value, retrieving, by the consumer thread, the task; and
executing, by the consumer thread, the task.

### Claim 9 (depends on 8)

The system of claim 8, wherein the synchronization primitive comprises a spinlock.

### Claim 10 (depends on 9)

The system of claim 9, the operations further comprising:
iteratively checking, by the consumer thread, the parameter associated with the spinlock to determine whether the parameter has been set to the second value; and
in response to the producer thread setting the parameter to the second value, acquiring, by the consumer thread, the spinlock.

### Claim 11 (depends on 8)

The system of claim 8, wherein:
the consumer thread is one of multiple consumer threads in a pool of consumer threads;
the producer thread is one of multiple producer threads in a pool of producer threads;
the task is one of multiple tasks; and
the event comprises a semaphore having a count equal to a number of the multiple consumer threads in the pool of consumer threads.

### Claim 12 (depends on 11)

The system of claim 11, wherein the synchronization primitive comprises a spinlock, the operations further comprising, in response to the producer thread setting the parameter to the second value, acquiring, by the pool of consumer threads, the spinlock in a shared manner.

### Claim 13 (depends on 11)

The system of claim 11, wherein:
the multiple processors include a third processor;
a first subset of the multiple consumer threads execute on the second processor; and
a second subset of the multiple consumer threads execute on the third processor.

### Claim 14

A method comprising:
detecting, by a producer thread running on a first processor, an external interrupt;
setting, by the producer thread, a parameter associated with a spinlock to a first value;
in response to setting the parameter to the first value, sending, by the producer thread, an event;
performing, by a consumer thread running on a second processor, loading operations while the producer thread creates a task;
publishing, by the producer thread, the created task;
in response to publishing the created task, setting, by the producer thread, the parameter to a second value;
setting, by the consumer thread, the parameter to the first value;
retrieving, by the consumer thread, the published task; and
executing, by the consumer thread, the retrieved task.

### Claim 15 (depends on 14)

The method of claim 14, wherein the consumer thread performs the loading operations in response to receiving the event from the producer thread.

### Claim 16 (depends on 14)

The method of claim 14, further comprising iteratively checking, by the consumer thread and prior to the producer thread setting the parameter to the second value, the parameter to determine whether the parameter has been set to the second value, wherein the consumer thread sets the parameter to the first value in response to determining that the parameter has been set to the second value.

### Claim 17 (depends on 14)

The method of claim 14, wherein:
the consumer thread is one of multiple consumer threads in a pool of consumer threads;
the producer thread is one of multiple producer threads in a pool of producer threads;
the task is one of multiple tasks; and
the event comprises a semaphore having a count equal to a number of the multiple consumer threads in the pool of consumer threads.

### Claim 18 (depends on 17)

The method of claim 17, wherein:
a first subset of the multiple consumer threads execute on the second processor; and
a second subset of the multiple consumer threads execute on a third processor.

### Claim 19 (depends on 14)

The method of claim 14, wherein publishing the task comprises storing information to be utilized for executing the task in shared memory that is accessible to the second processor via the consumer thread.

### Claim 20 (depends on 14)

The method of claim 14, wherein:
setting the parameter to the first value acquires the spinlock; and
setting the parameter to the second value releases the spinlock.
