In-process resource control method and apparatus, and device and storage medium

By creating resource pools for serial and parallel tasks within the process, configuring the number of threads, and allocating task queues according to task attributes, the problem of performance differences between middleware software on different chips is solved, and cost reduction and accuracy improvement is achieved.

WO2025176140A1PCT designated stage Publication Date: 2025-08-28ZHEJIANG GEELY HLDG GRP CO LTD +1
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2025/077972
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-02-23
Filing Date
2025-02-19
Publication Date
2025-08-28

AI Technical Summary

Technical Problem

Middleware software exhibits different performance on different chips, resulting in the need of different software versions and resource control strategies, increasing maintenance costs and reducing resource control accuracy.

Method used

By creating a first resource pool and a second resource pool in the process, used for serial and parallel tasks, pre-configuring the number of threads, and allocating tasks to the corresponding thread queue according to task attribute information, the threads execute tasks in turn, and implementing resource control to improve accuracy.

Benefits of technology

It reduces software maintenance costs, improves the accuracy of resource control and task execution accuracy, ensuring stable operation on different computing chips.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025077972_28082025_PF_FP_ABST
    Figure CN2025077972_28082025_PF_FP_ABST
Patent Text Reader

Abstract

Provided in the present application are an in-process resource control method and apparatus, and a device and a storage medium, which can be used in the field of computers. The method comprises: acquiring at least one task to be processed and each piece of task attribute information, wherein the task attribute information comprises a task execution type, which is serial execution or parallel execution; on the basis of each piece of task attribute information, determining a thread corresponding to each task, which thread is created by means of a process and is located in a first resource pool or a second resource pool, wherein the first resource pool is a resource pool of threads corresponding to a serial processing task, the second resource pool is a resource pool of threads corresponding to a parallel processing task, and the number of threads in the first resource pool and the number of threads in the second resource pool are configured in advance; allocating the tasks to task queues of corresponding threads; and using corresponding threads to sequentially execute the tasks in the corresponding task queues. The present application improves the accuracy of control precision for resources, and reduces maintenance costs for software.
Need to check novelty before this filing date? Find Prior Art

Description

In-process resource control method, device, equipment and storage medium

[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on February 23, 2024, with application number 202410200024.5 and application name “In-process resource control method, device, equipment and storage medium”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The present application relates to, but is not limited to, the field of computers, and in particular to a method, apparatus, device, and storage medium for controlling resources within a process. Background Art

[0003] Middleware software can run on different systems or chips. However, different chips often have significantly different CPU counts and computing power. Therefore, the same set of middleware software often exhibits different performance when running on different chips.

[0004] To ensure optimal performance of middleware software on different chips, different software versions are typically used. However, these different software versions employ different resource control strategies, resulting in high software maintenance costs. Furthermore, resource control strategies are typically implemented at the process level, resulting in inaccurate resource control. Summary of the Invention

[0005] The following is a summary of the subject matter described in detail herein. This summary is not intended to limit the scope of the claims.

[0006] The present application provides a method, apparatus, device, and storage medium for in-process resource control, which can avoid adopting different resource control strategies for different software versions, thereby avoiding high software maintenance costs. At the same time, it can avoid controlling at the process granularity when adopting different resource control strategies, thereby avoiding inaccurate resource control precision.

[0007] In a first aspect, the present application provides a method for controlling resources within a process, comprising:

[0008] Acquire at least one task to be processed and attribute information of each task; the task attribute information includes: task execution type; the task execution type is serial execution or parallel execution;

[0009] Determining the thread corresponding to each task based on attribute information of each task; the thread is created by a process and is located in a first resource pool or a second resource pool; the first resource pool is a resource pool for threads corresponding to serial processing tasks, and the second resource pool is a resource pool for threads corresponding to parallel processing tasks; the number of threads in the first resource pool and the second resource pool is preconfigured;

[0010] Assign each task to the task queue of the corresponding thread;

[0011] Use the corresponding thread to execute the tasks in the corresponding task queue in sequence.

[0012] In one possible design, determining the thread corresponding to each task to execute based on the attribute information of each task includes:

[0013] In response to a task execution type corresponding to any one of the tasks being serial execution, determining a thread in the first resource pool as a first candidate thread corresponding to the task, and determining a thread to execute the task from the first candidate threads according to a first thread selection policy;

[0014] In response to the task execution type corresponding to any task being parallel execution, a thread in the second resource pool is determined as a second candidate thread corresponding to the task, and a thread executing the task is determined from the second candidate threads according to a second thread selection policy.

[0015] In a possible design, the task attribute information further includes task type and task load weight;

[0016] Determining a thread corresponding to executing the task from the first candidate threads according to the first thread selection strategy includes:

[0017] Determine, based on the task type, whether there is a task of the same type as the task in the task queue corresponding to the first candidate thread;

[0018] If so, the first candidate thread belonging to the task queue corresponding to the task of the same type as the task is determined as the thread corresponding to the task;

[0019] If not, determine the first target task queue that includes the smallest number of task types or the smallest total task load weights from the task queues corresponding to the first candidate thread, and determine the first candidate thread belonging to the first target task queue as the thread that executes the task.

[0020] In one possible design, determining a thread corresponding to executing the task from the second candidate threads according to the second thread selection strategy includes:

[0021] Determine, from the task queues corresponding to the second candidate threads, a second target task queue that includes the smallest number of tasks to be executed or includes tasks with the smallest total task load weights;

[0022] The second candidate thread belonging to the second target task queue is determined as the thread corresponding to executing the task.

[0023] In one possible design, the method further includes:

[0024] Monitor the execution status of each thread according to a first preset period;

[0025] In response to any thread execution state being an abnormal state, determining the thread to be tasked, and transferring tasks in the task queue corresponding to the abnormal thread to the task queue corresponding to the thread to be tasked;

[0026] Delete the abnormal thread.

[0027] In one possible design, monitoring the execution status of each thread according to the first preset period includes:

[0028] Receive heartbeat information sent by each thread according to a second preset period, wherein the heartbeat information includes a thread identifier;

[0029] In response to determining, according to the thread identifier, that a heartbeat message sent by any thread is received in the first preset period, determining that the execution state of the thread is normal;

[0030] In response to determining, according to the thread identifier, that no heartbeat information sent by any thread is received within a first preset period, it is determined that the execution state of the thread is abnormal.

[0031] In one possible design, the method further includes:

[0032] Determining the number of threads in the corresponding resource pool according to a third preset period;

[0033] In response to the number of threads being less than the preconfigured number of threads, a new thread is created in the corresponding resource pool, so that the total number of threads in the corresponding resource pool is equal to the preconfigured number of threads after the thread is created.

[0034] In a second aspect, the present application provides an in-process resource control device, comprising:

[0035] An acquisition module configured to acquire at least one task to be processed and attribute information of each task; the task attribute information includes: a task execution type; the task execution type is serial execution or parallel execution;

[0036] a determination module configured to determine, based on attribute information of each task, a thread corresponding to each task; the thread is created by a process and is located in a first resource pool or a second resource pool; the first resource pool is a resource pool for threads corresponding to serial processing tasks, and the second resource pool is a resource pool for threads corresponding to parallel processing tasks; the number of threads in the first resource pool and the second resource pool is preconfigured;

[0037] An allocation module configured to allocate each task to a task queue of a corresponding thread;

[0038] The execution module is configured to sequentially execute tasks in the corresponding task queue using corresponding threads.

[0039] In a third aspect, the present application provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor;

[0040] The memory stores computer-executable instructions;

[0041] The processor executes the computer-executable instructions stored in the memory to implement the method as described in any one of the first aspects.

[0042] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method as described in any one of the first aspects.

[0043] In a fifth aspect, the present application provides a vehicle comprising the electronic device described in the third aspect above.

[0044] In a sixth aspect, the present application provides a computer program product, comprising a computer program, which, when executed by a processor, implements the method as described in any one of the first aspects.

[0045] In a seventh aspect, the present application provides a computer program, comprising a program code. When the computer program is executed by a processor, the program code is used to implement the method as described in any one of the first aspects.

[0046] The in-process resource control method, device, equipment and storage medium provided by the present application obtain at least one task to be processed and attribute information of each task; the task attribute information includes: task execution type; the task execution type is serial execution or parallel execution; the thread corresponding to each task is determined according to the attribute information of each task; the thread is created by the process and is located in the first resource pool or the second resource pool; the first resource pool is a resource pool for threads corresponding to serial processing tasks, and the second resource pool is a resource pool for threads corresponding to parallel processing tasks; the number of threads in the first resource pool and the second resource pool is pre-configured; each task is assigned to the task queue of the corresponding thread; the corresponding thread is used to execute the tasks in the corresponding task queue in sequence. By processing serial tasks through threads in the first resource pool and assigning serial tasks to the task queue of the corresponding thread, and processing parallel tasks through threads in the second resource pool and assigning parallel tasks to the task queue of the corresponding thread, serial tasks and parallel tasks can be executed in a certain order, thereby avoiding the problem of task execution failure caused by disorder in order during task execution and ensuring the accuracy of task execution. In this solution, the number of threads in the first resource pool and the second resource pool is pre-configured, and the threads are maintained at a fixed number. Therefore, the computing power requirements for different chips are consistent. Therefore, only the same set of middleware software needs to be used to run smoothly on chips with different computing powers, reducing software maintenance costs. At the same time, this solution controls resources at the thread granularity, improving the accuracy of resource control precision.

[0047] Still other aspects will become apparent upon reading and understanding the accompanying drawings and detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0049] FIG1 is an application scenario diagram of an in-process resource control method provided by an embodiment of the present application;

[0050] FIG2 is a flowchart of a method for controlling in-process resources according to an embodiment of the present application;

[0051] FIG3 is a flowchart of a method for controlling intra-process resources according to another embodiment of the present application;

[0052] FIG4 is a flowchart of a method for controlling in-process resources according to another embodiment of the present application;

[0053] FIG5 is a schematic diagram of a business process structure framework provided in an embodiment of the present application;

[0054] FIG6 is a schematic diagram of the structure of an in-process resource control device provided by an embodiment of the present application;

[0055] FIG7 is a schematic structural diagram of an electronic device provided in one embodiment of the present application.

[0056] The above drawings illustrate specific embodiments of the present application, which will be described in more detail below. These drawings and the textual description are not intended to limit the scope of the present application in any way, but rather to illustrate the concepts of the present application to those skilled in the art by reference to specific embodiments. DETAILED DESCRIPTION

[0057] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.

[0058] In order to clearly understand the technical solution of the present application, the solution of the prior art is first introduced in detail.

[0059] Middleware is generally a universal system that can run on different systems or chips. However, the number of CPUs and computing power of chips used for different services often vary significantly. For example, chips designed for intelligent driving may have more than a dozen CPU cores, while some gateway chips may only have a single or dual-core CPU. Therefore, when running on these two chips, a set of middleware software requires different resource utilization strategies. When running on high-computing chips, more threads can be created to handle tasks to achieve higher performance. However, when running on low-computing chips, this strategy results in high task scheduling overhead due to the large number of threads and limited CPUs, impacting performance. Currently, to ensure consistent performance of middleware software on different chips, different software versions are typically used. However, different software versions use different resource control strategies, resulting in high software maintenance costs. Furthermore, these resource control strategies are generally implemented at the process level, resulting in inaccurate resource control.

[0060] Based on this, in order to avoid adopting different resource control strategies for different software versions, thereby avoiding high software maintenance costs, resource control and task scheduling can be implemented within a process, and for this process, the number of threads in the first resource pool and the second resource pool are pre-configured, and tasks are assigned to the task queues of the corresponding threads based on the task execution type. The corresponding threads execute the tasks in the corresponding task queues in turn. Since the threads corresponding to this process are kept at a fixed number, the computing power requirements for different chips are consistent, so the same set of software can run smoothly on chips with different computing powers. In order to avoid using different resource control strategies and controlling at the process granularity, thereby avoiding inaccurate resource control precision, control can be performed at the thread granularity to improve the accuracy of resource control.

[0061] The following introduces the application scenarios of the embodiments of the present application.

[0062] Figure 1 is an application scenario diagram of the in-process resource control method provided by an embodiment of the present application. As shown in Figure 1, for example, the specific application scenario of the present application can be a scenario in which resources are controlled when the middleware software runs on a chip for intelligent driving. The system corresponding to the in-process resource control method provided by the present application includes: an electronic device corresponding to the in-process resource control, such as an on-board terminal. The on-board terminal includes a user operation interface 1 and an intelligent driving chip 2. The user sends a task instruction to the intelligent driving chip 2 by clicking on the user operation interface 1 of the on-board terminal, or the intelligent driving chip 2 automatically triggers the task instruction through a sensor in the on-board terminal or other means. The task instruction includes the task to be processed and the task attribute information. The intelligent driving chip creates a different number of threads according to the attribute information of each task and determines the thread corresponding to each task. The first resource pool processes serial tasks, and the second resource pool processes parallel tasks. Each task is assigned to the task queue of the corresponding thread, and the corresponding thread is used to execute the tasks in the corresponding task queue in sequence.

[0063] It is understandable that the application scenarios of the in-process resource control method provided in this embodiment can also be other application scenarios, and the corresponding chip can also be other types of chips, such as the chip in the gateway device, which is not limited in this embodiment.

[0064] The technical solution of the present application is described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below with reference to the accompanying drawings.

[0065] FIG2 is a flow chart of an in-process resource control method provided by an embodiment of the present application. As shown in FIG2 , the execution subject of this embodiment is an in-process resource control device, which is located in an electronic device, which may be a vehicle-mounted terminal. The in-process resource control method provided by this embodiment includes the following steps:

[0066] Step 201: Obtain at least one task to be processed and attribute information of each task; the task attribute information includes: task execution type; task execution type is serial execution or parallel execution.

[0067] The task attribute information refers to the attribute information corresponding to the task to be processed, which may include the task type and the task execution type, wherein the task execution type is serial execution or parallel execution.

[0068] Among them, serial execution means that there is a relationship between tasks, and one task needs to be executed after another task is completed.

[0069] Among them, parallel execution means that tasks do not need to be executed in sequence, but can be executed at the same time.

[0070] Specifically, in this embodiment, the user sends a task instruction to the electronic device by clicking on the user operation interface of the vehicle terminal, or the electronic device automatically triggers the task instruction through the sensor in the vehicle terminal or other means. The task instruction includes the task to be processed and the task attribute information, so the electronic device can obtain the task to be processed and the task attribute information.

[0071] Step 202, determine the thread corresponding to each task based on the attribute information of each task; the thread is created by the process and is located in the first resource pool or the second resource pool; the first resource pool is a resource pool for threads corresponding to serial processing tasks, and the second resource pool is a resource pool for threads corresponding to parallel processing tasks; the number of threads in the first resource pool and the second resource pool is pre-configured.

[0072] The first resource pool is a resource pool for storing threads whose task execution type is serial execution.

[0073] The second resource pool is a resource pool for storing threads whose task execution type is parallel execution.

[0074] Specifically, in this embodiment, the user can configure the number of threads in the first resource pool and the second resource pool. The electronic device creates a corresponding number of threads in the first resource pool and the second resource pool according to the number of threads in the first resource pool and the second resource pool pre-configured by the user, and judges whether the task is executed serially or in parallel based on the acquired task and task attribute information. If the task execution type is serial execution, the task is assigned to the first resource pool; if the task execution type is parallel execution, the task is assigned to the second resource pool.

[0075] Step 203: Allocate each task to the task queue of the corresponding thread.

[0076] Among them, the task queue is used to cache tasks to be processed.

[0077] Specifically, in this embodiment, one thread corresponds to one task queue, and the electronic device assigns tasks to the task queue of the corresponding thread based on the task execution type. If the task execution type is serial execution, the task is assigned to the task queue of the corresponding thread in the first resource pool. If the task execution type is parallel execution, the task is assigned to the task queue of the corresponding thread in the second resource pool. Specifically, the task can be stored at the top of the task queue of the corresponding thread. The task can be executed after the previously stored tasks are executed.

[0078] Step 204: Use the corresponding thread to execute the tasks in the corresponding task queue in sequence.

[0079] Specifically, in this embodiment, the corresponding threads in the first resource pool and the second resource pool execute the tasks in the corresponding task queues in turn. The tasks in the task queues are executed in a first-in-first-out manner. When the task queue is not empty, the first task in the task queue is taken for processing. When there is no task in the task queue, the thread is suspended and enters a non-executable state. At this time, the thread will no longer occupy CPU resources.

[0080] The in-process resource control method provided by this embodiment obtains at least one task to be processed and attribute information of each task; the task attribute information includes: task execution type; the task execution type is serial execution or parallel execution; the thread corresponding to each task is determined based on the attribute information of each task; the thread is created by the process and is located in the first resource pool or the second resource pool; the first resource pool is a resource pool for threads corresponding to serial processing tasks, and the second resource pool is a resource pool for threads corresponding to parallel processing tasks; the number of threads in the first resource pool and the second resource pool is pre-configured; each task is assigned to the task queue of the corresponding thread; the corresponding thread is used to execute the tasks in the corresponding task queue in sequence. By processing serial tasks through threads in the first resource pool and assigning serial tasks to the task queue of the corresponding thread, and processing parallel tasks through threads in the second resource pool and assigning parallel tasks to the task queue of the corresponding thread, serial tasks and parallel tasks can be executed in a certain order, thereby avoiding the problem of task execution failure caused by disorder in order during task execution, and ensuring the accuracy of task execution. In this solution, the number of threads in the first resource pool and the second resource pool is pre-configured, and the threads are kept at a fixed number. Therefore, the computing power requirements for different chips are consistent. Therefore, only the same set of middleware software needs to be used to run smoothly on chips with different computing powers, reducing software maintenance costs. At the same time, this solution controls resources at the thread granularity, improving the accuracy of resource control precision.

[0081] As an optional implementation, in this embodiment, step 202 includes the following steps:

[0082] Step 2021: In response to the task execution type corresponding to any task being serial execution, a thread in the first resource pool is determined as a first candidate thread corresponding to the task, and a thread executing the task is determined from the first candidate threads according to a first thread selection strategy.

[0083] The first candidate thread refers to a candidate thread in the first resource pool for processing tasks whose task execution type is serial execution.

[0084] The first thread selection strategy refers to a strategy for selecting the best thread for a task whose task execution type is serial execution.

[0085] Specifically, in this embodiment, after determining that the task execution type is serial execution, the electronic device determines a thread in the first resource pool as the first candidate thread for the task. It first determines whether there is a task associated with the task to be processed in the task queue of the threads in the first resource pool. If so, the thread corresponding to the task associated with the task to be processed is selected as the optimal thread for executing the task, and the task is assigned to the task queue of the optimal thread. If not, the thread with the minimum computing power required for the task included in the first candidate threads is selected according to the first thread selection strategy as the optimal thread for executing the task, and the task is assigned to the task queue of the optimal thread.

[0086] Step 2022: In response to the task execution type corresponding to any task being parallel execution, a thread in the second resource pool is determined as a second candidate thread corresponding to the task, and a thread executing the task is determined from the second candidate threads according to a second thread selection policy.

[0087] The second candidate thread refers to a candidate thread in the second resource pool for processing tasks whose task execution type is parallel execution.

[0088] The second thread selection strategy refers to a strategy for selecting the best thread for a task whose task execution type is parallel execution.

[0089] Specifically, in this embodiment, after the electronic device determines that the task execution type is parallel execution, it determines the thread in the second resource pool as the second candidate thread of the task, and then finds the thread with the smallest computing power required for the task from the second candidate threads according to the second thread selection strategy as the best thread to execute the task, and assigns the task to the task queue of the best thread.

[0090] The in-process resource control method provided by this embodiment determines the thread corresponding to each task based on the attribute information of each task, including: in response to the task execution type corresponding to any task being serial execution, determining the thread in the first resource pool as the first candidate thread corresponding to the task, and determining the thread corresponding to the task from the first candidate thread according to the first thread selection strategy; in response to the task execution type corresponding to any task being parallel execution, determining the thread in the second resource pool as the second candidate thread corresponding to the task, and determining the thread corresponding to the task from the second candidate thread according to the second thread selection strategy. By judging the task execution type and allocating tasks to different resource pools according to the task type, serial tasks and parallel tasks can be separated, thereby avoiding the problem of task execution failure caused by disordered order during task execution and ensuring the accuracy of task execution. At the same time, the best thread for executing the task is determined according to the first thread selection strategy and the second thread selection strategy. Based on the different task execution types, the optimal processing resources can be accurately selected for the task to be processed according to different thread selection strategies, ensuring that the task can be processed as quickly as possible and improving the execution efficiency of the task.

[0091] FIG3 is a flowchart of an intra-process resource control method provided by another embodiment of the present application. As shown in FIG3 , as an optional implementation, in this embodiment, the task attribute information also includes the task type and the task load weight.

[0092] Accordingly, step 2021 includes the following steps:

[0093] Step 301 : Determine, based on the task type, whether there is a task of the same type as the task in the task queue corresponding to the first candidate thread.

[0094] Here, the tasks of the same type as the task refer to tasks that are associated with the task.

[0095] Specifically, in this embodiment, the electronic device obtains task and task attribute information, which includes the task execution type, task type, and task load weight. The electronic device stores information such as the task, task execution type, task type, and task load weight in a newly created table. Specifically, in the table, the tasks in the task queue corresponding to each thread may have corresponding task attribute information in the table. If the task execution type is serial execution, the electronic device compares the task queue of the thread in the first resource pool with the task that is associated with the task to be processed based on the task and task type information in the table.

[0096] Step 302: If yes, the first candidate thread belonging to the task queue corresponding to the task of the same type as the task is determined as the thread corresponding to the task.

[0097] Specifically, in this embodiment, if there is a task in the task queue of the thread in the first resource pool that has an associated relationship with the task to be processed, the task to be processed is assigned to the task queue of the first candidate thread to which the task queue corresponding to the task that has an associated relationship with the task belongs, and the task is processed by the first candidate thread to which the task queue corresponding to the task that has an associated relationship with the task belongs.

[0098] Step 303: If not, determine the first target task queue that includes the smallest number of task types or the smallest total task load weights from the task queues corresponding to the first candidate thread, and determine the first candidate thread belonging to the first target task queue as the thread that executes the task.

[0099] The task load weight is the weight corresponding to the computing power required to execute the task. Specifically, the larger the weight, the more computing power is required.

[0100] The first target task queue refers to the best task queue for caching tasks to be processed whose task execution type is serial execution.

[0101] Specifically, in this embodiment, the electronic device obtains task and task attribute information, where the task attribute information includes task execution type, task type, and task load weight. The electronic device stores information such as task, task execution type, task type, and task load weight in a newly created table. If there is no task associated with the task to be processed in the task queue of the thread in the first resource pool, the electronic device calculates the number of task types or the sum of the task load weights of the tasks included in the task queue corresponding to each thread in the first candidate thread based on the information in the table, and sorts the calculated number of task types or the sum of the task load weights of the tasks included in the task queue corresponding to each thread in the first candidate thread in ascending order, thereby determining the first target task queue with the smallest number of task types or the smallest sum of the task load weights of the tasks included from the task queue corresponding to the first candidate thread according to the first thread selection strategy, and assigns the task to the first target task queue with the smallest number of task types or the smallest sum of the task load weights of the tasks included, and the first candidate thread belonging to the first target task queue executes the thread corresponding to the task.

[0102] In the in-process resource control method provided by this embodiment, the task attribute information also includes the task type and the task load weight. Accordingly, when determining the thread corresponding to the task to be executed from the first candidate thread according to the first thread selection strategy, it is determined from the task queue corresponding to the first candidate thread whether there is a task of the same type as the task; if so, the first candidate thread belonging to the task queue corresponding to the task of the same type as the task is determined as the thread corresponding to the task to be executed; if not, the first target task queue including the smallest number of task types or the smallest sum of task load weights of the tasks included is determined from the task queue corresponding to the first candidate thread, and the first candidate thread belonging to the first target task queue is determined as the thread corresponding to the task to be executed. By judging whether there is a task associated with the task to be processed in the task queue of the thread in the first resource pool, if so, the first candidate thread belonging to the task queue corresponding to the task associated with the task to be processed is determined as the thread corresponding to the task to be processed, it can be ensured that the associated tasks are processed by the same thread, so that the tasks can be executed in a certain order, preventing the task execution order from being disordered, and ensuring the accuracy of task execution. If not, then calculate the number of task types included or the sum of the task load weights corresponding to the tasks included from the task queue corresponding to each thread in the first candidate thread respectively, and determine the first target task queue with the smallest number of task types or the smallest sum of the task load weights corresponding to the tasks included from the task queue corresponding to the first candidate thread according to the first thread selection strategy. Since the computing power required for the tasks included in the first target task queue is the smallest and the processing time required for the tasks included in the first target task queue is also the shortest, the waiting time required for the task is the shortest. Therefore, the first candidate thread belonging to the first target task queue is the best thread to execute the task, thereby selecting the optimal processing resources for the task to be processed, ensuring that the task can be processed as soon as possible, and improving the execution efficiency of the task.

[0103] As an optional implementation, in this embodiment, step 2022 includes the following steps:

[0104] Step 401 : Determine, from the task queues corresponding to the second candidate threads, a second target task queue that includes the smallest number of tasks to be executed or includes tasks with the smallest total task load weights.

[0105] The second target task queue refers to the optimal task queue for caching tasks to be processed whose task execution type is parallel execution.

[0106] Specifically, in this embodiment, the electronic device obtains task and task attribute information, where the task attribute information includes task execution type, task type, and task load weight. The electronic device stores information such as task, task execution type, task type, and task load weight in a newly created table. Based on the information in the table, the electronic device calculates the number of pending tasks or the sum of the task load weights corresponding to the tasks included in the task queue corresponding to each thread in the second candidate thread, and sorts the calculated number of pending tasks or the sum of the task load weights corresponding to the tasks included in the task queue corresponding to each thread in the second candidate thread in ascending order, thereby determining the second target task queue with the smallest number of pending tasks or the smallest sum of the task load weights corresponding to the tasks included from the task queue corresponding to the second candidate thread according to the second thread selection strategy.

[0107] Step 402: Determine the second candidate thread belonging to the second target task queue as the thread corresponding to executing the task.

[0108] Specifically, in this embodiment, after determining the second target task queue that includes the smallest number of tasks to be executed or the smallest total sum of task load weights corresponding to the tasks included, the task is assigned to the second target task queue that includes the smallest number of tasks to be executed or the smallest total sum of task load weights corresponding to the tasks included, and the thread corresponding to the task is executed by the second candidate thread belonging to the second target task queue.

[0109] The in-process resource control method provided by this embodiment, when determining the thread corresponding to the task to be executed from the second candidate threads according to the second thread selection strategy, determines the second target task queue with the smallest number of tasks to be executed or the smallest sum of the task load weights corresponding to the tasks from the task queues corresponding to each second candidate thread; and determines the second candidate thread belonging to the second target task queue as the thread corresponding to the task to be executed. Because the electronic device calculates the number of tasks to be processed or the sum of the task load weights corresponding to the tasks in the task queues corresponding to the second candidate threads based on the task load weights configured by the user, and determines the second target task queue with the smallest number of tasks to be executed or the smallest sum of the task load weights corresponding to the tasks from the task queues corresponding to the second candidate threads according to the second thread selection strategy, since the computing power required for the tasks included in the second target task queue is the smallest and the processing time required for the tasks included in the second target task queue is also the shortest, the waiting time required for the task to be processed is the shortest, so the second candidate thread belonging to the second target task queue is the best thread to execute the task, thereby selecting the optimal processing resources for the task to be processed, ensuring that the task can be processed as quickly as possible, and improving the execution efficiency of the task.

[0110] FIG4 is a flowchart of a method for controlling in-process resources according to another embodiment of the present application. As shown in FIG4 , as an optional implementation, in this embodiment, the method for controlling in-process resources further includes the following steps:

[0111] Step 501: Monitor the execution status of each thread according to a first preset period.

[0112] The first preset period is a period for monitoring the execution status of each thread, which may be 2s, 3s or other time periods, and is not specifically limited here.

[0113] Specifically, optionally, in this embodiment, the health management thread may monitor the execution status of each thread in the two resource pools according to a first preset period, and the health management thread determines whether the execution status of each thread in the two resource pools is abnormal by judging whether each thread in the two resource pools periodically sends heartbeat information.

[0114] Step 502 : In response to any thread being in an abnormal state, a thread to receive a task is determined, and tasks in a task queue corresponding to the abnormal thread are transferred to a task queue corresponding to the thread to receive the task.

[0115] Among them, an abnormal thread refers to a thread that cannot run normally.

[0116] Specifically, in this embodiment, since the number of threads in the resource management module is pre-configured, the resource management module first sends the number of threads in the first resource pool and the second resource pool and the thread identifiers of each thread to the health management thread, and each thread in the two resource pools periodically sends heartbeat information to the health management thread. If the health management thread does not receive the same number of heartbeat messages as the threads in the first resource pool and the second resource pool, it is considered that the thread that has not sent the heartbeat message is in an abnormal state. By comparing the thread identifier in the received heartbeat message with the thread identifiers sent by the resource management module to the health management thread, the thread that has not sent the heartbeat message is found, and the task in the task queue corresponding to the abnormal thread is transferred to the task queue corresponding to the thread to receive the task. If the task execution type in the task queue corresponding to the abnormal thread is serial execution, the electronic device calculates the number of task types or the sum of the task load weights corresponding to the tasks in the task queue corresponding to the first candidate thread, and determines the first target task queue with the smallest number of task types or the smallest sum of the task load weights corresponding to the tasks from the task queue corresponding to the first candidate thread according to the first thread selection strategy, and transfers the task to the first target task queue with the smallest number of task types or the smallest sum of the task load weights corresponding to the tasks, and the first candidate thread belonging to the first target task queue executes the thread corresponding to the task. If the task execution type in the task queue corresponding to the abnormal thread is parallel execution, the electronic device calculates the number of tasks to be processed or the sum of the task load weights corresponding to the tasks in the task queue corresponding to the second candidate thread, and determines the second target task queue with the smallest number of tasks to be executed or the smallest sum of the task load weights corresponding to the tasks from the task queue corresponding to the second candidate thread according to the second thread selection strategy, and transfers the task to the second target task queue with the smallest number of tasks to be executed or the smallest sum of the task load weights corresponding to the tasks, and the second candidate thread belonging to the second target task queue executes the thread corresponding to the task.

[0117] Step 503: Delete the abnormal thread.

[0118] Specifically, in this embodiment, after transferring the tasks in the task queue corresponding to the abnormal thread to the task queue corresponding to the thread to receive the task, the health management thread deletes the abnormal thread, that is, deregisters the abnormal thread.

[0119] The in-process resource control method provided by this embodiment also includes: monitoring the execution status of each thread according to a first preset period; in response to any thread execution status being an abnormal state, determining the thread to be received, and transferring the tasks in the task queue corresponding to the abnormal thread to the task queue corresponding to the thread to be received; and deleting the abnormal thread. By periodically monitoring the health status of each thread in the two resource pools through the health management thread, abnormal threads can be discovered in a timely manner, and tasks in the task queue corresponding to the abnormal thread can be transferred to the task queue corresponding to the thread to be received, thereby preventing tasks from being in the task queue corresponding to the abnormal thread for a long time, resulting in the task not being processed in a timely manner, and the task being unable to be executed in a timely manner.

[0120] As an optional implementation, in this embodiment, step 501 includes the following steps:

[0121] Step 601: Receive heartbeat information sent by each thread according to a second preset period, where the heartbeat information includes a thread identifier.

[0122] The second preset period is a period for receiving heartbeat information of each thread, which may be 1 second or other time, and is not specifically limited here.

[0123] The heartbeat information includes the thread identifier and the task execution type.

[0124] The thread identifier refers to the ID of the thread, and each thread ID is globally unique.

[0125] Illustratively, in this embodiment, each thread in the two resource pools sends heartbeat information to the health management thread once every 1 second, so the health management thread can receive heartbeat information sent by each thread once every 1 second.

[0126] Step 602: In response to receiving heartbeat information sent by any thread in a first preset period according to the thread identifier, it is determined that the execution state of the thread is normal.

[0127] Specifically, in this embodiment, the health management thread receives heartbeat information sent by any thread in the two resource pools according to the second preset period, and the health management thread determines that the execution status of the thread sending the heartbeat information is normal according to the thread identifier in the heartbeat information according to the first preset period.

[0128] Step 603 : In response to determining according to the thread identifier that no heartbeat information sent by any thread is received within the first preset period, determining that the execution state of the thread is abnormal.

[0129] Specifically, in this embodiment, the health management thread does not receive heartbeat information sent by any thread in the two resource pools within the second preset period. The health management thread compares the thread identifier in the received heartbeat information with the thread identifiers sent to the health management thread by the resource management module according to the first preset period, finds the thread that has not sent the heartbeat information and determines that the execution status of the thread is abnormal.

[0130] The in-process resource control method provided by this embodiment, when monitoring the execution status of each thread according to a first preset period, receives heartbeat information sent by each thread according to a second preset period, wherein the heartbeat information includes a thread identifier; in response to determining, based on the thread identifier, that a heartbeat information sent by any thread is received during the first preset period, the execution status of the thread is determined to be normal; in response to determining, based on the thread identifier, that no heartbeat information sent by any thread is received during the first preset period, the execution status of the thread is determined to be abnormal. Whether each thread is abnormal can be determined by whether it sends heartbeat information, and the thread identifier in the heartbeat information can be further used to determine which specific thread has an abnormal execution status, thereby facilitating further processing of the abnormal thread.

[0131] As an optional implementation, in this embodiment, the in-process resource control method further includes the following steps:

[0132] Step 701: Determine the number of threads in the corresponding resource pool according to a third preset period.

[0133] The third preset period is a period for monitoring the number of threads, which may be 2s or 3s, and is not specifically limited here.

[0134] Specifically, in this embodiment, since the number of threads in the two resource pools is pre-configured, the two resource pools first send the number of threads in the first resource pool and the second resource pool to the health management thread, and each thread in the two resource pools sends heartbeat information to the health management thread according to the second preset period, so the health management thread determines the number of threads that send heartbeat information at a time according to the third preset period.

[0135] Step 702: In response to the number of threads being less than the pre-configured number of threads, a new thread is created in the corresponding resource pool, so that the total number of threads in the corresponding resource pool after the thread is created is equal to the pre-configured number of threads.

[0136] The pre-configured number of threads is pre-configured by the user, and the resource pool can create a corresponding number of threads according to the pre-configured number of threads by the user.

[0137] Specifically, in this embodiment, the health management thread determines the number of threads sending heartbeat information every 2 seconds. If the number of first candidate threads is less than the pre-configured number of threads, the resource management module's add resource interface is called to create a new thread in the first resource pool, so that the total number of threads in the first resource pool after the thread is created is equal to the pre-configured number of threads. If the number of second candidate threads is less than the pre-configured number of threads, the resource management module's add resource interface is called to create a new thread in the second resource pool, so that the total number of threads in the second resource pool after the thread is created is equal to the pre-configured number of threads.

[0138] The in-process resource control method provided by this embodiment also includes: determining the number of threads in the corresponding resource pool according to a third preset period; in response to the number of threads being less than the pre-configured number of threads, creating a new thread in the corresponding resource pool so that the total number of threads in the corresponding resource pool after the thread is created is equal to the pre-configured number of threads. By monitoring the number of threads in the corresponding resource pool according to the third preset period, when it is found that the number of threads is less than the pre-configured number of threads, the resource management module can be called immediately to create a new thread to prevent the number of threads from not matching the load of the tasks to be processed, resulting in an overload of the normal thread load. By creating a new thread, the total number of threads in the corresponding resource pool after the thread is created is equal to the pre-configured number of threads, thereby achieving control of the number of threads, and at the same time enabling tasks to be processed in a timely manner, preventing a reduction in task execution efficiency.

[0139] Figure 5 is a schematic diagram of the business process structure framework provided in an embodiment of the present application. As shown in Figure 5, the business process structure framework provided in the present application is located in an electronic device, and the business process structure framework includes: a business processing module, a task scheduling module, and a resource management module.

[0140] Among them, the business processing module is used to receive tasks, task attribute information and the number of threads in the first resource pool and the second resource pool sent by the user, and send tasks, task attribute information and the number of threads in the first resource pool and the second resource pool to the task scheduling module.

[0141] The task scheduling module is configured to receive tasks, task attribute information, and the number of threads in the first resource pool and the second resource pool sent by the task scheduling module, and calculate the current workload of each thread according to the first thread selection strategy or the second thread selection strategy. The task scheduling module includes a health management thread, which is configured to monitor the health status of each thread in the resource management module. If an abnormal thread status is detected, the task of the thread is transferred to another thread. If the number of threads detected is less than the pre-configured number of threads, the resource management module is called to create a new thread.

[0142] The resource management module is used to create threads and send the number of threads to the health management thread of the task scheduling module.

[0143] The first resource pool is used to process tasks whose execution type is serial execution.

[0144] The second resource pool is used to process tasks whose task execution type is parallel execution.

[0145] Among them, threads are used to process tasks.

[0146] Among them, the task queue is used to cache tasks to be processed.

[0147] The in-process resource control method corresponding to FIG5 includes the following steps:

[0148] Step 801: Obtain at least one task to be processed and attribute information of each task; the task attribute information includes: task execution type; task execution type is serial execution or parallel execution.

[0149] Step 802 : In response to the task execution type corresponding to any task being serial execution, a thread in the first resource pool is determined as a first candidate thread corresponding to the task, and a thread executing the task is determined from the first candidate threads according to a first thread selection strategy.

[0150] Step 803 : Determine, based on the task type, whether there is a task of the same type as the task in the task queue corresponding to the first candidate thread.

[0151] Step 804: If yes, the first candidate thread belonging to the task queue corresponding to the task of the same type as the task is determined as the thread corresponding to the task.

[0152] Step 805: If not, determine the first target task queue that includes the smallest number of task types or the smallest total task load weights from the task queues corresponding to the first candidate thread, and determine the first candidate thread belonging to the first target task queue as the thread that executes the task.

[0153] Step 806 , in response to the task execution type corresponding to any task being parallel execution, determine the thread in the second resource pool as the second candidate thread corresponding to the task, and determine the thread that executes the task from the second candidate threads according to the second thread selection policy.

[0154] Step 807 : Determine, from the task queues corresponding to the second candidate threads, a second target task queue that includes the smallest number of tasks to be executed or includes tasks with the smallest total task load weights.

[0155] Step 808: Determine the second candidate thread belonging to the second target task queue as the thread corresponding to executing the task.

[0156] Step 809: Allocate each task to the task queue of the corresponding thread.

[0157] Step 810: Use the corresponding thread to execute the tasks in the corresponding task queue in sequence.

[0158] Step 811: Receive heartbeat information sent by each thread according to a second preset period, where the heartbeat information includes a thread identifier.

[0159] Step 812: In response to receiving heartbeat information sent by any thread in the first preset period according to the thread identifier, determine that the execution status of the thread is normal.

[0160] Step 813 : In response to determining according to the thread identifier that no heartbeat information sent by any thread is received within the first preset period, determining that the execution state of the thread is abnormal.

[0161] Step 814 , in response to any thread execution state being an abnormal state, determining the thread to receive the task, and transferring the tasks in the task queue corresponding to the abnormal thread to the task queue corresponding to the thread to receive the task.

[0162] Step 815: Delete the abnormal thread.

[0163] Step 816: Determine the number of threads in the corresponding resource pool according to the third preset period.

[0164] Step 817 : In response to the number of threads being less than the pre-configured number of threads, a new thread is created in the corresponding resource pool, so that the total number of threads in the corresponding resource pool after the thread is created is equal to the pre-configured number of threads.

[0165] It should be noted that there is no strict order restriction for executing these steps, and these steps can be executed in other orders.

[0166] The implementation of the in-process resource control method provided in this embodiment is similar to the implementation of the corresponding steps in the above embodiments, and will not be described in detail here.

[0167] Figure 6 is a structural diagram of an in-process resource control device provided in an embodiment of the present application. As shown in Figure 6, the in-process resource control device provided in this embodiment is located in an electronic device, and the in-process resource control device 900 provided in this embodiment includes: an acquisition module 901, a determination module 902, an allocation module 903, and an execution module 904.

[0168] Among them, the acquisition module 901 is configured to obtain at least one task to be processed and the attribute information of each task; the task attribute information includes: task execution type; the task execution type is serial execution or parallel execution; the determination module 902 is configured to determine the thread corresponding to each task based on the attribute information of each task; the thread is created by the process and is located in the first resource pool or the second resource pool; the first resource pool is the resource pool for the threads corresponding to the serial processing tasks, and the second resource pool is the resource pool for the threads corresponding to the parallel processing tasks; the number of threads in the first resource pool and the second resource pool is pre-configured; the allocation module 903 is configured to assign each task to the task queue of the corresponding thread; the execution module 904 is configured to use the corresponding thread to execute the tasks in the corresponding task queue in sequence.

[0169] The in-process resource control device provided in this embodiment can execute the method embodiment shown in Figure 2. The specific implementation principles and technical effects are similar and will not be repeated here.

[0170] Optionally, when determining the thread corresponding to each task to be executed based on the attribute information of each task, the determination module 902 is specifically set to: in response to the task execution type corresponding to any task being serial execution, the thread in the first resource pool is determined as the first candidate thread corresponding to the task, and the thread corresponding to the task to be executed is determined from the first candidate thread according to the first thread selection strategy; in response to the task execution type corresponding to any task being parallel execution, the thread in the second resource pool is determined as the second candidate thread corresponding to the task, and the thread corresponding to the task to be executed is determined from the second candidate thread according to the second thread selection strategy.

[0171] Optionally, the task attribute information also includes the task type and task load weight.

[0172] Accordingly, when the determination module 902 determines the thread corresponding to the execution of the task from the first candidate thread according to the first thread selection strategy, it is specifically set to: determine whether there is a task of the same type as the task in the task queue corresponding to the first candidate thread according to the task type; if so, the first candidate thread belonging to the task queue corresponding to the task of the same type as the task is determined as the thread corresponding to the execution of the task; if not, the first target task queue with the smallest number of task types or the smallest total task load weights included in the tasks included is determined from the task queue corresponding to the first candidate thread, and the first candidate thread belonging to the first target task queue is determined as the thread corresponding to the execution of the task.

[0173] Optionally, when the determination module 902 determines the thread corresponding to the execution of the task from the second candidate threads according to the second thread selection strategy, it is specifically set to: determine the second target task queue that includes the smallest number of tasks to be executed or the smallest sum of task load weights corresponding to the tasks included from the task queues corresponding to each second candidate thread; and determine the second candidate thread belonging to the second target task queue as the thread corresponding to the execution of the task.

[0174] Optionally, the in-process resource control device provided by this embodiment further includes: a monitoring module and a deletion module.

[0175] Among them, the monitoring module is configured to monitor the execution status of each thread according to a first preset period; the determination module 902 is also configured to determine the thread to be received, and transfer the tasks in the task queue corresponding to the abnormal thread to the task queue corresponding to the thread to be received in response to the abnormal execution status of any thread being an abnormal state; the deletion module is configured to delete the abnormal thread.

[0176] Optionally, when the monitoring module monitors the execution status of each thread according to the first preset period, it is specifically configured to: receive heartbeat information sent by each thread according to the second preset period, the heartbeat information including the thread identifier; in response to determining according to the thread identifier that the heartbeat information sent by any thread is received in the first preset period, determine that the execution status of the thread is normal; in response to determining according to the thread identifier that the heartbeat information sent by any thread is not received in the first preset period, determine that the execution status of the thread is abnormal.

[0177] Optionally, the in-process resource control device provided by this embodiment further includes: a creation module.

[0178] Among them, the determination module 902 is also configured to determine the number of threads in the corresponding resource pool according to a third preset period; the creation module is configured to create a new thread in the corresponding resource pool in response to the number of threads being less than the pre-configured number of threads, so that the total number of threads in the corresponding resource pool after the thread is created is equal to the pre-configured number of threads.

[0179] The in-process resource control device provided in this embodiment can execute the method embodiments shown in Figures 3 to 4. The specific implementation principles and technical effects are similar and will not be repeated here.

[0180] FIG7 is a schematic structural diagram of an electronic device provided in an embodiment of the present application. As shown in FIG7 , the electronic device 1000 provided in this embodiment includes: a processor 1001 and a memory 1002 communicatively connected to the processor.

[0181] Memory 1002 stores computer-executable instructions; processor 1001 executes the computer-executable instructions stored in memory 1002 to implement the in-process resource control method provided by any of the above-described embodiments. For related explanations, reference can be made to the corresponding descriptions and effects of the steps in the accompanying drawings, and detailed descriptions are omitted here.

[0182] The program may include program code, and the program code includes computer-executable instructions. The memory 1002 may include a high-speed RAM memory, or may also include a non-volatile memory, such as at least one disk memory.

[0183] In this embodiment, the memory 1002 and the processor 1001 are connected via a bus. The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. Buses can be classified into address buses, data buses, and control buses. For ease of illustration, FIG7 shows only one thick line, but this does not mean that there is only one bus or only one type of bus.

[0184] The present application also provides a computer-readable storage medium that stores computer-executable instructions. When executed by a processor, the computer-executable instructions implement the in-process resource control method provided in any of the above-mentioned embodiments. For example, the computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, or optical data storage device.

[0185] An embodiment of the present application also provides a vehicle, including the electronic device shown in FIG7 .

[0186] An embodiment of the present application also provides a computer program product, including a computer program, which, when executed by a processor, implements the in-process resource control method provided by any of the above embodiments.

[0187] An embodiment of the present application further provides a computer program, comprising program code. When the computer program is executed by a processor, the program code is used to implement the in-process resource control method provided by any one of the above embodiments.

[0188] It should be noted that for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all optional embodiments, and the actions and modules involved are not necessarily required by this application.

[0189] It should be further noted that, although the various steps in the flowchart are shown in sequence as indicated by the arrows, these steps are not necessarily performed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps may be performed in other orders. Moreover, at least a portion of the steps in the flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily performed at the same time, but may be performed at different times. The execution order of these sub-steps or stages is not necessarily to be performed in sequence, but may be performed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.

[0190] It should be understood that the above-described device embodiments are merely illustrative, and the device of the present application may also be implemented in other ways. For example, the division of units / modules in the above-described embodiments is merely a logical functional division, and actual implementations may employ other division methods. For example, multiple units, modules, or components may be combined or integrated into another system, or some features may be omitted or not implemented.

[0191] In addition, unless otherwise specified, the functional units / modules in the various embodiments of the present application may be integrated into a single unit / module, each unit / module may exist physically separately, or two or more units / modules may be integrated together. The aforementioned integrated units / modules may be implemented in the form of hardware or software program modules, and the present invention is not limited to any specific combination of hardware and software.

[0192] If the integrated unit / module is implemented in hardware, the hardware may be digital circuits, analog circuits, etc. The physical implementation of the hardware structure includes, but is not limited to, transistors, memristors, etc. Unless otherwise specified, the artificial intelligence processor may be any appropriate hardware processor, such as a CPU, GPU, FPGA, DSP, and ASIC. Unless otherwise specified, the storage unit may be any appropriate magnetic storage medium or magneto-optical storage medium, such as resistive random access memory (RRAM), dynamic random access memory (DRAM), static random access memory (SRAM), enhanced dynamic random access memory (EDRAM), high-bandwidth memory (HBM), hybrid memory cube (HMC), etc.

[0193] If the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a memory and includes a number of instructions for enabling a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned memory includes various media that can store program codes, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.

[0194] In the above embodiments, the description of each embodiment has its own emphasis. For parts not described in detail in a particular embodiment, please refer to the relevant description of other embodiments. The technical features of the above embodiments can be combined in any way. To keep the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0195] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present application that follow the general principles of the present application and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, and the true scope and spirit of the present application are indicated by the following claims.

[0196] It should be understood that the present application is not limited to the exact structure described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. A method for controlling resources within a process, comprising: Obtain at least one task to be processed and attribute information of each task; The task attribute information includes: task execution type; the task execution type is serial execution or parallel execution; Determining the thread corresponding to each task based on attribute information of each task; the thread is created by a process and is located in a first resource pool or a second resource pool; the first resource pool is a resource pool for threads corresponding to serial processing tasks, and the second resource pool is a resource pool for threads corresponding to parallel processing tasks; the number of threads in the first resource pool and the second resource pool is preconfigured; Assign each task to the task queue of the corresponding thread; Use the corresponding thread to execute the tasks in the corresponding task queue in sequence.

2. The method according to claim 1, wherein Determining the thread corresponding to each task according to the attribute information of each task includes: In response to a task execution type corresponding to any one of the tasks being serial execution, determining a thread in the first resource pool as a first candidate thread corresponding to the task, and determining a thread to execute the task from the first candidate threads according to a first thread selection policy; In response to the task execution type corresponding to any task being parallel execution, a thread in the second resource pool is determined as a second candidate thread corresponding to the task, and a thread executing the task is determined from the second candidate threads according to a second thread selection policy.

3. The method according to claim 2, wherein: The task attribute information also includes task type and task load weight; Determining a thread corresponding to executing the task from the first candidate threads according to the first thread selection strategy includes: Determine, based on the task type, whether there is a task of the same type as the task in the task queue corresponding to the first candidate thread; If so, the first candidate thread belonging to the task queue corresponding to the task of the same type as the task is determined as the thread corresponding to the task; If not, determine the first target task queue that includes the smallest number of task types or the smallest total task load weights from the task queues corresponding to the first candidate thread, and determine the first candidate thread belonging to the first target task queue as the thread that executes the task.

4. The method according to claim 2 or 3, wherein: Determining a thread corresponding to executing the task from the second candidate threads according to the second thread selection strategy includes: Determine, from the task queues corresponding to the second candidate threads, a second target task queue that includes the smallest number of tasks to be executed or includes tasks with the smallest total task load weights; The second candidate thread belonging to the second target task queue is determined as the thread corresponding to executing the task.

5. The method according to any one of claims 1 to 4, further comprising: Monitor the execution status of each thread according to a first preset period; In response to any thread execution state being an abnormal state, determining the thread to be tasked, and transferring tasks in the task queue corresponding to the abnormal thread to the task queue corresponding to the thread to be tasked; Delete the abnormal thread.

6. The method according to claim 5, wherein: The monitoring of the execution status of each thread according to the first preset period includes: Receive heartbeat information sent by each thread according to a second preset period, wherein the heartbeat information includes a thread identifier; In response to determining, according to the thread identifier, that a heartbeat message sent by any thread is received in the first preset period, determining that the execution state of the thread is normal; In response to determining, according to the thread identifier, that no heartbeat information sent by any thread is received within a first preset period, it is determined that the execution state of the thread is abnormal.

7. The method according to any one of claims 1 to 6, further comprising: Determining the number of threads in the corresponding resource pool according to a third preset period; In response to the number of threads being less than the preconfigured number of threads, a new thread is created in the corresponding resource pool, so that the total number of threads in the corresponding resource pool is equal to the preconfigured number of threads after the thread is created.

8. A process resource control device, comprising: An acquisition module configured to acquire at least one task to be processed and attribute information of each task; The task attribute information includes: task execution type; the task execution type is serial execution or parallel execution; a determination module configured to determine, based on attribute information of each task, a thread corresponding to each task; the thread is created by a process and is located in a first resource pool or a second resource pool; the first resource pool is a resource pool for threads corresponding to serial processing tasks, and the second resource pool is a resource pool for threads corresponding to parallel processing tasks; the number of threads in the first resource pool and the second resource pool is preconfigured; An allocation module configured to allocate each task to a task queue of a corresponding thread; The execution module is configured to sequentially execute tasks in the corresponding task queue using corresponding threads.

9. An electronic device comprising: a processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, wherein computer-executable instructions are stored in the computer-readable storage medium, and when the computer-executable instructions are executed by a processor, they are used to implement the method according to any one of claims 1 to 7.

11. A vehicle comprising the electronic device according to claim 9.

12. A computer program product comprising a computer program, wherein when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

13. A computer program comprising program code, wherein when the computer program is executed by a processor, the program code is configured to implement the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • In-process resource control method and device, equipment and storage medium

    CN117971491A

  • Task scheduling method and device and computer storage medium

    CN110515713A

  • Thread management method and device

    CN113535251A

  • Task scheduling method and device, equipment and storage medium

    CN114168302A

  • Task-level thread scheduling and resource allocation

    US20090165007A1