# US 12,112,193 B2 · Thread state transitions

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

- Number: US 12,112,193 B2
- Document ID: US12112193B2
- Status: Granted
- Kind: B2
- Application number: 17/452,871
- Filed: 2021-10-29
- Published: 2023-05-04
- Granted: 2024-10-08
- Earliest claimed: 2021-10-29
- Assignees: BlackBerry Limited
- Applicants: BlackBerry Limited
- Inventors: Elad Lahav
- Web page: https://patentgrep.com/patent/US12112193B2

## CPC

- G06F 9/485: {Task life-cycle, e.g. stopping, restarting, resuming execution (G06F9/4881 takes precedence)}
- G06F 9/4881: {Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues}
- G06F 9/52: Program synchronisation; Mutual exclusion, e.g. by means of semaphores
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

In some examples, a system includes an operating system (OS) kernel, one or more hardware processors, and a kernel scheduler. The kernel scheduler receives a first indication that a first thread is to wait for an event, receives a second indication that the first thread has transitioned to a blocked state in which the first thread is blocked on the event, and receives a third indication from a second thread delivering the event, the third indication to unblock the first thread. In response to the third indication, the kernel scheduler causes a transition of the first thread from the wait state to an active state if the first thread is in the wait state and has not yet transitioned to the blocked state, and causes a transition of the first thread from the blocked state to a ready state if the first thread is in the blocked state.

## Claims

### Claim 1

A system comprising:
an operating system (OS) kernel;
one or more hardware processors;
a kernel scheduler to:
receive a first indication that a first thread is to wait for an event, wherein the first thread has transitioned to a wait state while the first thread remains active;
receive a second indication that the first thread has transitioned to a blocked state in which the first thread is blocked on the event;
receive a third indication from a second thread delivering the event, the third indication to unblock the first thread;
in response to the third indication:
cause a transition of the first thread from the wait state to an active state if the first thread is in the wait state and has not yet transitioned to the blocked state, and
cause a transition of the first thread from the blocked state to a ready state if the first thread is in the blocked state,
wherein a third thread is to set an indicator associated with the first thread to indicate a cancellation of the first thread's waiting or blocking on the event, wherein the cancellation is triggered by an occurrence of another event, and
wherein the kernel scheduler is to drop the cancellation in response to the first thread switching from a kernel persona to a user persona.

### Claim 2 (depends on 1)

The system of claim 1, wherein a time interval exists between when the first thread is in the wait state and when the first thread has transitioned to the blocked state.

### Claim 3 (depends on 2)

The system of claim 2, wherein the first thread is to transition from the wait state to the blocked state, and is unable to transition directly from the active state to the blocked state.

### Claim 4 (depends on 3)

The system of claim 3, wherein the first thread is to initiate the transition from the wait state to the blocked state in response to the first thread determining that the first thread is still waiting on the event.

### Claim 5 (depends on 1)

The system of claim 1, wherein the first thread is to transition to the blocked state while the first thread executes in the kernel persona.

### Claim 6 (depends on 1)

The system of claim 1, wherein the kernel scheduler is to:
preempt the first thread while the first thread is in the wait state and cause a transition of the first thread from the wait state to a ready and wait state.

### Claim 7 (depends on 6)

The system of claim 6, wherein the kernel scheduler is to:
in response to the third indication, cause the first thread to transition from the ready and wait state to a ready state if the first thread has transitioned to the ready and wait state.

### Claim 8 (depends on 1)

The system of claim 1, wherein the kernel scheduler is to:
receive, from the first thread, a fourth indication that the first thread is waiting on a mutex of the kernel scheduler; and
in response to the fourth indication, cause a transition of the first thread to a mutex wait state while the first thread remains active, wherein the first thread is to transition from the mutex wait state to a mutex blocked state in which the first thread blocks on the mutex.

### Claim 9 (depends on 8)

The system of claim 8, wherein the kernel scheduler is to:
receive a fifth indication from a further thread to release the mutex; and
in response to the fifth indication:
cause a transition of the first thread from the mutex wait state to the active state if the first thread is in the mutex wait state and has not yet transitioned to the mutex blocked state, and
cause a transition of the first thread from the mutex blocked state to the ready state if the first thread is in the mutex blocked state.

### Claim 10 (depends on 1)

The system of claim 1, wherein the indicator to indicate the cancellation comprises an asynchronous indicator.

### Claim 11 (depends on 1)

The system of claim 1, wherein with the indicator set, the first thread is prevented from transitioning to the blocked state if the first thread has not yet transitioned to the blocked state.

### Claim 12 (depends on 1)

The system of claim 1, wherein the kernel scheduler is to:
cause a transition of the first thread from the blocked state to a ready and cancel state in response to the setting of the indicator to indicate the cancellation, wherein in the ready and cancel state the cancellation is pending.

### Claim 13 (depends on 1)

The system of claim 1, wherein if the first thread has transitioned to a state that waits or blocks on a mutex of the kernel scheduler, the first thread is not subject to the cancellation.

### Claim 14 (depends on 1)

The system of claim 1, wherein a transition of a thread between different states occurs using a per-thread lock.

### Claim 15

A non-transitory machine-readable storage medium comprising instructions that upon execution cause a system to:
transition a first thread in its kernel persona to a wait state to wait for an event, wherein in the wait state the first thread remains active;
transition the first thread from the wait state to a blocked state in which the first thread is blocked on the event, wherein a time interval exists between when the first thread is in the wait state and when the first thread is in the blocked state;
responsive to a second thread delivering the event:
transition the first thread from the wait state to an active state if the first thread is in the wait state and has not yet transitioned to the blocked state, and
transition the first thread from the blocked state to a ready state if the first thread is in the blocked state; and
responsive to a cancellation of the first thread's waiting or blocking on the event:
transition the first thread from the wait state to a wait and cancel state in which the cancellation is pending, if the first thread has not yet transitioned to the blocked state, and
transition the first thread from the blocked state to a ready and cancel state in which the cancellation is pending, if the first thread has transitioned to the blocked state.

### Claim 16 (depends on 15)

The non-transitory machine-readable storage medium of claim 15, wherein the first thread is to transition from the wait state to the blocked state, and is unable to transition directly from the active state to the blocked state.

### Claim 17 (depends on 15)

The non-transitory machine-readable storage medium of claim 15, wherein the instructions upon execution cause the system to:
in response to a preemption of the first thread while the first thread is in the wait state, transition the first thread from the wait state to a ready and wait state.

### Claim 18 (depends on 15)

The non-transitory machine-readable storage medium of claim 15, wherein the cancellation is indicated by an indicator set by a further thread.

### Claim 19

A method of a system including a hardware processor, comprising:
receiving, by a scheduling executive that is separate from a micro-kernel, a first indication that a first thread is to wait for an event, wherein the first thread has transitioned to a wait state while the first thread remains active, wherein the scheduling executive and the micro-kernel are part of an operating system (OS) kernel;
receiving, by the scheduling executive, a second indication that the first thread has transitioned to a blocked state in which the first thread is blocked on the event;
receiving, by the scheduling executive, a third indication from a second thread delivering the event, the third indication to unblock the first thread;
in response to the third indication, the scheduling executive:
causing a transition of the first thread from the wait state to an active state if the first thread is in the wait state and has not yet transitioned to the blocked state, and
causing a transition of the first thread from the blocked state to a ready state if the first thread is in the blocked state; and
in response to a cancellation of the first thread's waiting or blocking on the event:
transition the first thread from the wait state to a wait and cancel state in which the cancellation is pending, if the first thread has not yet transitioned to the blocked state, and
transition the first thread from the blocked state to a ready and cancel state in which the cancellation is pending, if the first thread has transitioned to the blocked state.

### Claim 20 (depends on 19)

The method of claim 19, further comprising:
dropping the cancellation responsive to the first thread switching from a kernel persona to a user persona.
