Coroutine Manager for Blocking Task Scheduling

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing methods for managing blocking tasks in computer systems require the creation of numerous threads and context switching, leading to high overhead and reduced system performance, or necessitate a complete redesign of the programming architecture to implement asynchronous execution.

Innovation Solution

The method employs coroutines to execute task functions, allowing for the detection and management of blocking events, pausing and resuming execution as needed, without requiring significant modifications to the existing programming architecture, using a coroutine manager to handle multiple task functions within a single thread.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If multiple threads are created to handle blocking I/O tasks, then asynchronous execution is achieved, but system overhead increases and performance deteriorates

Engineering Contradiction:
Improveasynchronous execution capabilityVSAvoidthread management complexity
Core Design Contradiction:
ReliabilityVSDevice complexity

Solution Approach 1:

The patent segments the thread-based approach into coroutine-based execution units. Each coroutine is a lightweight execution context that can be suspended and resumed, replacing the need for full threads. This segmentation maintains asynchronous execution capability while significantly reducing the overhead associated with thread management, as coroutines are managed at the user level rather than requiring OS-level thread resources.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent introduces an intermediary coroutine manager that mediates between the main thread and blocking I/O operations. The coroutine manager handles suspension, resumption, and scheduling of coroutines, eliminating the need for direct thread-level management. This intermediary layer abstracts the complexity of asynchronous operation management while maintaining the benefits of non-blocking I/O.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Device complexity

If coroutine-based execution is implemented, then thread overhead is reduced, but programming architecture modification is required

Engineering Contradiction:
Improvethread management overheadVSAvoidprogramming architecture compatibility
Core Design Contradiction:
Device complexityVSEase of manufacture

Solution Approach 1:

The patent makes the coroutine manager universal by designing it to work with existing programming models. The coroutine infrastructure can be integrated into traditional multi-threaded applications without requiring complete architectural redesign. The coroutine manager provides multi-functional capabilities including task scheduling, suspension management, and I/O handling, making it applicable to various programming scenarios while maintaining compatibility with existing codebases.

Inventive Principle:
Principle #6Universality (Multi-functionality)

Solution Approach 2:

The coroutine manager serves as an intermediary layer that bridges existing programming architecture and coroutine-based execution. It provides abstraction mechanisms that allow existing code to be wrapped in coroutines without fundamental changes to the programming logic. This intermediary approach enables gradual adoption of coroutine technology while maintaining ease of development and architecture compatibility.

Inventive Principle:
Principle #24Intermediary (Mediator)

3Adaptability or versatility

If context switching between threads is frequent, then task scheduling flexibility improves, but system performance decreases

Engineering Contradiction:
Improvetask scheduling flexibilityVSAvoidsystem throughput
Core Design Contradiction:
Adaptability or versatilityVSProductivity

Solution Approach 1:

The patent segments execution into lightweight coroutines that can be rapidly scheduled and suspended. This segmentation enables frequent context switching between coroutines without the heavy overhead associated with thread context switching. The coroutine-based approach maintains task scheduling flexibility while improving system throughput by reducing the cost of context transitions and enabling more efficient CPU utilization.

Inventive Principle:
Principle #1Segmentation

Data Source

PatentUS9501319B2Method and apparatus for scheduling blocking tasks
Publication Date: 2016.11.22 TENCENT TECHNOLOGY (SHENZHEN) CO LTD
  • US9501319B2 patent drawing
  • US9501319B2 patent drawing
  • US9501319B2 patent drawing

AI summary

Method, system, and computer-readable medium for scheduling blocking tasks are disclosed. A method includes: executing each of a plurality of task functions in a respective coroutine; detecting a first blocking event for a first task function of the plurality of task functions during execution of the first task function; in response to detecting the first blocking event: setting a respective blocking state of the first task function to a pause state; pausing execution of the first task function; and placing the first task function among a group of paused task functions; and after pausing the execution of the first task function: identifying a second task function among the group of paused task functions for which a respective blocking state has been updated to a running state; removing the second task function from the group of paused task functions; and resuming execution of the second task function.