Coroutine Manager for Blocking Task Scheduling
Find Innovative SolutionsGenerate 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
Engineering 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
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.
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.
2Device complexity
If coroutine-based execution is implemented, then thread overhead is reduced, but programming architecture modification is required
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.
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.
3Adaptability or versatility
If context switching between threads is frequent, then task scheduling flexibility improves, but system performance decreases
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.
Data Source
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.


