A thread resource configuration method, device and computer-readable storage medium

By obtaining the subtask processing order of the target task, determining the number of subtasks processed in parallel, and reasonably configuring thread resources, solving the problem of insufficient or oversupply of resources caused by improper thread resource configuration, and achieving normal operation and efficient processing of algorithm programs.

CN114461377BActive Publication Date: 2025-08-19ZHEJIANG DAHUA TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111525684.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-14
Publication Date
2025-08-19
Estimated Expiration
2041-12-14

AI Technical Summary

Technical Problem

When configuring thread resources for algorithm programs, the prior art cannot be configured reasonably, resulting in insufficient or oversupply of resources, affecting the normal operation of algorithm programs.

Method used

By obtaining the subtask processing order in the target task, determining the number of subtasks processed in parallel, configuring thread resources according to the processing parameters, ensuring that the number of thread resources reasonably matches task requirements.

Benefits of technology

It effectively avoids the problem of insufficient or excessive thread resource configuration, and ensures the normal operation and efficient processing of algorithm programs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114461377B_ABST
    Figure CN114461377B_ABST
Patent Text Reader

Abstract

The present invention provides a thread resource configuration method, device and computer-readable storage medium, which relate to the field of computer technology and are used to reasonably configure thread resources. An embodiment of the present invention obtains a target task to be processed; wherein the target task contains multiple subtasks to be processed; according to the processing order of each subtask contained in the target task, a processing parameter corresponding to the target task is determined to indicate the number of subtasks that need to be processed in parallel in the target task; according to the processing parameter corresponding to the target task, thread resources are configured for the target task. When configuring thread resources for the target task, thread resources are configured according to the processing parameter, so that reasonable thread resources can be configured for the target task to be processed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a thread resource configuration method, device, and computer-readable storage medium. Background Art

[0002] With the development of science and technology and the widespread popularization of network technology, people's demand for various services has become increasingly strong, and higher and higher requirements have been placed on the processing level of computers.

[0003] During the execution of an algorithm program on an embedded device, a multi-threaded processing method can be used. A thread is a basic unit that can run independently and is also the basic unit for independent scheduling and dispatching. When using multi-threaded execution of an algorithm program in an embedded device, thread resources need to be configured for the algorithm program. Currently, a common method for configuring thread resources for an algorithm program is to configure them based on the number of CPUs in the embedded device where the algorithm program runs. For example, the number of thread resources configured for the algorithm program is the same as the number of CPUs. This method is suitable for simpler embedded devices, which generally have a small number of CPUs. In this case, the number of thread resources configured for the algorithm program is also small, which may result in insufficient configured thread resources and the algorithm program cannot run normally. Therefore, the current thread resource configuration method cannot reasonably configure thread resources. Summary of the Invention

[0004] The present invention provides a thread resource configuration method, device and computer-readable storage medium for reasonably configuring thread resources.

[0005] In a first aspect, an embodiment of the present invention provides a thread resource configuration method, comprising:

[0006] Obtaining a target task to be processed; wherein the target task contains multiple subtasks to be processed;

[0007] Determining, according to the processing order of each subtask included in the target task, a processing parameter corresponding to the target task and used to indicate the number of subtasks in the target task that need to be processed in parallel;

[0008] Thread resources are configured for the target task according to processing parameters corresponding to the target task.

[0009] After the embodiment of the present invention obtains the target task to be processed, the target task contains multiple subtasks; according to the processing order of the subtasks contained in the target task, the processing parameters corresponding to the target task are determined; wherein the processing parameters represent the number of subtasks that need to be processed in parallel in the target task. When configuring thread resources for the target task, the thread resources are configured according to the processing parameters, so that reasonable thread resources can be configured for the target task to be processed.

[0010] In an optional embodiment, determining, according to the processing order of each subtask included in the target task, a processing parameter corresponding to the target task and used to indicate the number of subtasks that need to be processed in parallel in the target task, specifically includes:

[0011] Determining the number of subtasks with the same priority in the target task according to the processing order of each subtask included in the target task;

[0012] The maximum number of the determined subtasks with the same priority is used as a processing parameter corresponding to the target task.

[0013] In an optional implementation, determining the number of threads configured for the target task based on the processing parameters corresponding to the target task specifically includes:

[0014] According to the processing parameters corresponding to the target task, a number of thread resources no less than the processing parameters is configured for the target task.

[0015] In an optional implementation, configuring the number of threads for the target task according to the processing parameters corresponding to the target task specifically includes:

[0016] configuring thread resources for the target task according to the processing parameters corresponding to the target task and the thread threshold parameters corresponding to the target task;

[0017] The thread threshold parameter includes at least one of the total number of subtasks included in the target task, a thread upper limit value corresponding to a preset target task type, and the number of processors processing the target task.

[0018] In an optional implementation, thread resources are configured for the target task in the following manner:

[0019] If the thread threshold parameter includes the total number of subtasks included in the target task, the number of thread resources configured for the target task is not less than the processing parameter and not greater than the total number of subtasks included in the target task;

[0020] If the thread threshold parameter includes a preset thread upper limit value corresponding to the target task type, the number of thread resources configured for the target task is not less than the processing parameter and not greater than the preset thread upper limit value corresponding to the target task type;

[0021] If the thread threshold parameter includes the number of processors that process the target task, the number of thread resources configured for the target task shall not be less than the processing parameter and shall not be greater than n*P; wherein n is a positive integer greater than 1, and the value of n is determined according to the type of the target task, and P is the number of processors that process the target task.

[0022] In a second aspect, an embodiment of the present invention provides a thread resource configuration device, the device comprising:

[0023] An acquisition unit, configured to acquire a target task to be processed; wherein the target task includes a plurality of subtasks to be processed;

[0024] a determining unit, configured to determine, according to a processing order of each subtask included in the target task, a processing parameter corresponding to the target task and used to indicate the number of subtasks in the target task that need to be processed in parallel;

[0025] The configuration unit is used to configure thread resources for the target task according to the processing parameters corresponding to the target task.

[0026] In a third aspect, an embodiment of the present invention provides an electronic device comprising a processor and a memory, wherein the memory stores program code, and when the program code is executed by the processor, the processor executes the steps of any one of the methods described in the first aspect above.

[0027] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium comprising a program code. When the program code is run on an electronic device, the program code is used to enable the electronic device to execute the steps of any one of the methods described in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 This is a flowchart of a thread resource configuration method according to an embodiment of the present invention;

[0029] Figure 2 Schematic diagram of image frame states processed by various intelligent algorithms in the initial stage of the image processing algorithm according to an embodiment of the present invention;

[0030] Figure 3 Schematic diagram of image frame states processed by various intelligent algorithms during the image processing algorithm operation phase in an embodiment of the present invention;

[0031] Figure 4 Schematic diagram of image frame states processed by various intelligent algorithms when the image processing algorithm enters a stuck stage in an embodiment of the present invention;

[0032] Figure 5 Schematic diagram of the execution order of multiple subtasks in a target task in an embodiment of the present invention;

[0033] Figure 6 A schematic diagram of the logic for determining the number of thread resources of an image processing algorithm program according to an embodiment of the present invention;

[0034] Figure 7 This is an overall flow chart of a thread resource configuration method according to an embodiment of the present invention;

[0035] Figure 8 This is an overall flow chart of another thread resource configuration method in an embodiment of the present invention;

[0036] Figure 9 A schematic structural diagram of a thread resource configuration device according to an embodiment of the present invention;

[0037] Figure 10 FIG. 4 is a schematic structural diagram of an electronic device in an embodiment of the present invention. DETAILED DESCRIPTION

[0038] In order to enable ordinary persons in the art to better understand the technical solutions disclosed in the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings.

[0039] It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a particular order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of the present invention described herein can be implemented in sequences other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are merely examples of apparatus and methods consistent with certain aspects of the present invention, as detailed in the appended claims.

[0040] Regarding the related art, when configuring thread resources for algorithm programs, sometimes too many thread resources are configured, resulting in a waste of resources, and sometimes too few thread resources are configured, resulting in low processing efficiency. For example, if the algorithm program is a calculation-based program (CPU-intensive program), thread resources equal to the number of CPUs are configured for the algorithm program; for simple devices, the number of CPUs is often small, which may result in fewer thread resources being allocated to the algorithm components. If the algorithm program is a disk or network location-based program (IO-intensive program), thread resources equal to twice the number of CPUs are configured for the algorithm program; for complex devices, the number of CPUs is often large, which may result in more thread resources being allocated to the algorithm components.

[0041] To solve the above problems, an embodiment of the present invention provides a thread resource configuration method, which obtains a target task to be processed; wherein the target task contains multiple subtasks to be processed; according to the processing order of each subtask contained in the target task, determines the processing parameter corresponding to the target task for indicating the number of subtasks in the target task that need to be processed in parallel; and configures thread resources for the target task according to the processing parameter corresponding to the target task. Since the target task to be processed contains multiple subtasks after the embodiment of the present invention obtains the target task to be processed; according to the processing order of the subtasks contained in the target task, determines the processing parameter corresponding to the target task; wherein the processing parameter indicates the number of subtasks in the target task that need to be processed in parallel, when configuring thread resources for the target task, configuring thread resources according to the processing parameter can configure reasonable thread resources for the target task to be processed.

[0042] like Figure 1 The flowchart of a thread resource configuration method according to an embodiment of the present invention shown includes the following steps:

[0043] Step S101: Acquire a target task to be processed; wherein the target task contains multiple subtasks to be processed;

[0044] Step S102: determining a processing parameter corresponding to the target task and used to indicate the number of subtasks in the target task that need to be processed in parallel, based on the processing order of the subtasks included in the target task;

[0045] Step S103: configuring thread resources for the target task according to the processing parameters corresponding to the target task.

[0046] As can be seen from the thread resource configuration method provided in the embodiment of the present invention, when configuring thread resources for a target task, the embodiment of the present invention takes into account the processing order of multiple subtasks within the target task. Since subtasks within the target task are processed in order of priority, high-priority subtasks are processed first, followed by low-priority subtasks. The target task also includes subtasks of the same priority, and multiple subtasks of the same priority need to be processed in parallel. Only after all subtasks of the same priority have been processed will downstream subtasks be processed.

[0047] If the number of subtasks that need to be processed in parallel in the target task is not considered when configuring thread resources for the target task, assuming that the number of thread resources configured for the target task is less than the number of subtasks that need to be processed in parallel in the target task, some subtasks of the same low priority level cannot grab the execution thread and cannot be processed. The downstream high-priority subtasks cannot be executed because they have to wait for the execution results of the multiple upstream subtasks of the same low priority level. The subtasks of the same low priority level that grab the execution thread continue to process and the execution results cannot be released until the queue resources are exhausted and the program is stuck.

[0048] The following is explained with reference to the accompanying drawings:

[0049] For example, the target task is an image processing algorithm, which contains three subtasks of the same priority: intelligent algorithm A, intelligent algorithm B, and intelligent algorithm C. D is a downstream high-priority intelligent algorithm of intelligent algorithms A, B, and C. Assume that the number of thread resources configured for the target task is 2, and the length of the resource queue corresponding to intelligent algorithms A, B, and C is 25. The resource queue is used to store the data processing results of the corresponding intelligent algorithm.

[0050] like Figure 2 As shown, a schematic diagram of the image frame status processed by each intelligent algorithm in the initial stage of the image processing algorithm. In the initial stage, intelligent algorithm A, intelligent algorithm B and intelligent algorithm C all process 0 image frames; the downstream high-priority intelligent algorithm D processes 0 image frames.

[0051] Since the number of thread resources configured for the target task is 2, it is assumed that intelligent algorithm A and intelligent algorithm B obtain execution threads; Figure 3 As shown in the figure, the state diagram of image frames processed by each intelligent algorithm during the image processing algorithm running stage is shown. Intelligent algorithm A and intelligent algorithm B continuously perform image frame processing, assuming that each processes 10 frames; intelligent algorithm C has not obtained the execution thread, so intelligent algorithm C has been processing 0 image frames; intelligent algorithm D cannot synchronize the image frame processing results of intelligent algorithm A, intelligent algorithm B and intelligent algorithm C because the upstream intelligent algorithm C has not output the image frame result, resulting in the inability to execute intelligent algorithm D, and the number of processed image frames is 0.

[0052] Intelligent algorithm D needs to wait until intelligent algorithms A, B, and C have completed image processing for the same frame before it starts executing. After intelligent algorithm D is completed, intelligent algorithms A, B, and C will release the image frame processing results in the corresponding resource queues.

[0053] like Figure 4As shown, the resource queue lengths for intelligent algorithms A, B, and C are 25, meaning each intelligent algorithm's corresponding resource queue can only store the processing results of 25 image frames. After intelligent algorithms A and B process 25 frames, intelligent algorithm C still hasn't processed any image frames because it hasn't yet acquired an execution thread. Consequently, intelligent algorithm D is also unable to process any frames. When intelligent algorithms A and B process the 26th frame, the processing results for the image frames in the corresponding resource queues remain unreleased, causing queue resource exhaustion and the image processing algorithm to become stuck.

[0054] As can be seen from the above, the image processing algorithm may have become stuck because the number of thread resources configured for it was less than the number of intelligent algorithms of the same priority within the image processing algorithm. If the number of thread resources configured for the image processing algorithm were not less than the number of intelligent algorithms of the same priority within the image processing algorithm, each intelligent algorithm of the same priority would have been able to obtain an execution thread, thus ensuring the subsequent image processing flow and the normal operation of the image processing algorithm.

[0055] The thread resource configuration method provided by the embodiment of the present invention takes into account the processing parameters of the number of subtasks that need to be processed in parallel in the target task, and reasonably configures thread resources for the target task according to the processing parameters.

[0056] In an optional implementation manner, the embodiment of the present invention determines the processing parameters corresponding to the target task according to the following method:

[0057] According to the processing order of each subtask included in the target task, the number of subtasks with the same priority in the target task is determined; and the maximum number of the determined subtasks with the same priority is used as the processing parameter corresponding to the target task.

[0058] In implementation, the embodiment of the present invention reflects the processing order of each subtask in the form of priority, and determines the number of subtasks with the same priority in the target task;

[0059] For example, the target task contains 10 subtasks, and the execution order of the 10 subtasks is as follows: Figure 5 As shown; among them, subtask 1, subtask 2, and subtask 3 have the same priority, subtask 5 and subtask 6 have the same priority, and subtask 8, subtask 9, and subtask 10 have the same priority. It can be determined that the maximum number of subtasks with the same priority is 3, and the processing parameter corresponding to the target task is 3.

[0060] The following describes in detail a specific method of configuring thread resources for a target task according to processing parameters corresponding to the target task according to an embodiment of the present invention.

[0061] Method 1: Configure thread resources for the target task according to the processing parameters corresponding to the target task;

[0062] Optionally, according to the processing parameters corresponding to the target task, configuring a number of thread resources for the target task that is not less than the processing parameters;

[0063] As mentioned above, if the number of thread resources configured for the target task is less than the processing parameters, that is, the number of thread resources for the target task is less than the number of subtasks that need to be processed in parallel in the target task, then some of the subtasks in the parallel processing will not be able to obtain execution threads, resulting in the failure of the target task processing;

[0064] Therefore, the embodiment of the present invention provides a method for configuring the number of thread resources only according to the processing parameters corresponding to the target task, which can avoid the problem that multiple subtasks of the same priority cannot be processed normally due to insufficient thread resources.

[0065] Mode 2: configuring thread resources for the target task according to the processing parameters corresponding to the target task and the thread threshold parameters corresponding to the target task;

[0066] The thread threshold parameter includes at least one of the total number of subtasks included in the target task, a thread upper limit value corresponding to a preset target task type, and the number of processors processing the target task.

[0067] An optional implementation manner is that the number of thread resources configured for the target task is not less than the processing parameter and not greater than the thread threshold parameter corresponding to the target task;

[0068] 1. The thread threshold parameter can be the total number of subtasks contained in the target task;

[0069] Since the target task is running at full load during processing, that is, each subtask occupies an execution thread, the subtasks contained in the target task can be processed in parallel at the same time; setting up more threads will cause a waste of resources, so the total number of subtasks in the target task can be used as the thread threshold parameter, and the number of thread resources configured for the target task is not greater than the total number of subtasks contained in the target task.

[0070] 2. The thread threshold parameter can be the thread upper limit value corresponding to the preset target task type;

[0071] Optionally, an embodiment of the present invention can pre-set different thread upper limits for different types of target tasks; when configuring thread resources for a target task, the thread upper limit corresponding to the type of the target task is determined, and the number of thread resources configured for the target task is not greater than the thread upper limit.

[0072] For example, when the target task runs on an embedded device, the target task may not belong to an X86 architecture server with many CPU cores. A reasonable empirical threshold can be set for this type of target task as the thread upper limit value, assuming it can be 128.

[0073] In implementation, the thread upper limit value corresponding to the type of the target task can be used as the thread threshold parameter, and the number of thread resources configured for the target task is not greater than the thread upper limit value.

[0074] 3. The thread threshold parameter may be a multiple of the number of processors processing the target task;

[0075] Optionally, the thread threshold parameter may be set to n*P.

[0076] Wherein, n is a positive integer greater than 1, and the value of n is determined according to the type of the target task, and P is the number of processors processing the target task.

[0077] It should be noted that the value of n may vary depending on the type of target task. For example, when the target task is an image processing algorithm program, since the image processing algorithm program mainly spends time on frequent reading and writing operations on the algorithm results, the value of n may be 2.

[0078] In implementation, a multiple of the number of processors processing the target task may be used as a thread threshold parameter, and the number of thread resources configured for the target task shall not be greater than the multiple of the number of processors processing the target task.

[0079] The following describes a specific method of configuring thread resources for a target task using a specific embodiment:

[0080] Assume that the target task is an image processing algorithm program, and the image processing algorithm program runs on an embedded device;

[0081] When configuring thread resources for the image processing algorithm program, the number of thread resources for the image processing algorithm program is determined based on processing parameters corresponding to the image processing algorithm program, a multiple of the number of processors of the embedded device, and a preset thread upper limit value corresponding to the image processing algorithm;

[0082] Here, it is assumed that the processing parameters corresponding to the image processing algorithm program are the number of intelligent algorithms of the same priority in the image processing algorithm program as value A; twice the number of processors of the embedded device as value B; and the thread upper limit value corresponding to the preset image processing algorithm as value C;

[0083] The judgment logic for determining the number of thread resources for the image processing algorithm program is as follows: Figure 6 As shown:

[0084] 1. Start by assigning the number of thread resources Thread_num to 0;

[0085] 2. First, use the value A as the number of thread resources Thread_num;

[0086] 3. Determine whether value A is less than value B; if so, proceed to step 4; if not, proceed to step 9;

[0087] 4. Use value B as the number of thread resources Thread_num;

[0088] 5. Determine whether the value C is less than B; if so, proceed to step 6; if not, proceed to step 9;

[0089] 6. Use the value C as the number of thread resources Thread_num;

[0090] 7. Determine whether value C is less than value A; if so, proceed to step 8; if not, proceed to step 9;

[0091] 8. Use value A as the number of thread resources Thread_num;

[0092] 9. End and output the current number of thread resources Thread_num.

[0093] It should be noted that the number of thread resources Thread_num obtained by directly executing step 9 after executing step 3 is value A; the number of thread resources Thread_num obtained by directly executing step 9 after executing step 5 is value B; the number of thread resources Thread_num obtained by directly executing step 9 after executing step 7 is value C.

[0094] like Figure 7 As shown in FIG, an overall flow chart of a thread resource configuration method according to an embodiment of the present invention includes the following steps:

[0095] Step S701: Acquire a target task to be processed; wherein the target task includes multiple subtasks to be processed.

[0096] Step S702: Determine the number of subtasks with the same priority in the target task according to the processing order of each subtask included in the target task.

[0097] Step S703: Using the maximum number of the determined subtasks with the same priority as a processing parameter corresponding to the target task.

[0098] Step S704: According to the processing parameters corresponding to the target task, configure the target task with a number of thread resources that is not less than the processing parameters.

[0099] like Figure 8As shown in FIG, another overall flow chart of a thread resource configuration method according to an embodiment of the present invention includes the following steps:

[0100] Step S801: Acquire a target task to be processed; wherein the target task includes multiple subtasks to be processed.

[0101] Step S802: Determine the number of subtasks with the same priority in the target task according to the processing order of each subtask included in the target task.

[0102] Step S803: Using the maximum number of the determined subtasks with the same priority as a processing parameter corresponding to the target task.

[0103] Step S804: Determine the thread threshold parameter corresponding to the target task;

[0104] The thread threshold parameter includes at least one of the total number of subtasks included in the target task, the thread upper limit value corresponding to the preset target task type, and the number of processors processing the target task.

[0105] Step S805 : According to the processing parameters corresponding to the target task and the thread threshold parameters corresponding to the target task, configure for the target task a number of thread resources that is not less than the processing parameters and not greater than the total number of subtasks included in the target task.

[0106] like Figure 9 As shown, a thread resource configuration device 900 provided by an embodiment of the present invention includes:

[0107] An acquisition unit 901 is configured to acquire a target task to be processed; wherein the target task includes a plurality of subtasks to be processed;

[0108] A determining unit 902 is configured to determine, according to the processing order of each subtask included in the target task, a processing parameter corresponding to the target task and indicating the number of subtasks that need to be processed in parallel in the target task;

[0109] The configuration unit 903 is configured to configure thread resources for the target task according to the processing parameters corresponding to the target task.

[0110] In an optional implementation, the determining unit 902 is specifically configured to:

[0111] According to the processing order of each subtask included in the target task, the number of subtasks with the same priority in the target task is determined; and the maximum number of the determined subtasks with the same priority is used as the processing parameter corresponding to the target task.

[0112] In an optional implementation, the configuration unit 903 is specifically configured to:

[0113] According to the processing parameters corresponding to the target task, a number of thread resources no less than the processing parameters is configured for the target task.

[0114] In an optional implementation, the configuration unit 903 is specifically configured to:

[0115] configuring thread resources for the target task according to the processing parameters corresponding to the target task and the thread threshold parameters corresponding to the target task;

[0116] The thread threshold parameter includes at least one of the total number of subtasks included in the target task, a thread upper limit value corresponding to a preset target task type, and the number of processors processing the target task.

[0117] In an optional implementation, the configuration unit 903 is specifically configured to:

[0118] Configure thread resources for the target task in the following manner:

[0119] If the thread threshold parameter includes the total number of subtasks included in the target task, the number of thread resources configured for the target task is not less than the processing parameter and not greater than the total number of subtasks included in the target task;

[0120] If the thread threshold parameter includes a preset thread upper limit value corresponding to the target task type, the number of thread resources configured for the target task is not less than the processing parameter and not greater than the preset thread upper limit value corresponding to the target task type;

[0121] If the thread threshold parameter includes the number of processors that process the target task, the number of thread resources configured for the target task shall not be less than the processing parameter and shall not be greater than n*P; wherein n is a positive integer greater than 1, and the value of n is determined according to the type of the target task, and P is the number of processors that process the target task.

[0122] An embodiment of the present invention further provides an electronic device comprising at least a memory for storing data and a processor. The processor for processing data can be implemented using a microprocessor, a CPU, a GPU (Graphics Processing Unit), a DSP, or an FPGA. The memory stores operating instructions, which can be computer-executable code, that implement the various steps in the thread resource configuration method described in the embodiment of the present invention.

[0123] Figure 10 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. Figure 10 As shown, the electronic device 1000 includes a memory 1001, a processor 1002, a data acquisition module 1003 and a bus 1004. The memory 1001, the processor 1002 and the data acquisition module 1003 are connected via the bus 1004, and the bus 1004 is used to transmit data between the memory 1001, the processor 1002 and the data acquisition module 1003.

[0124] The memory 1001 can be used to store software programs and modules. The processor 1002 executes the various functional applications and data processing of the electronic device 1000 by running the software programs and modules stored in the memory 1001, such as the thread resource configuration method provided in the embodiment of the present invention. The memory 1001 can mainly include a program storage area and a data storage area. The program storage area can store an operating system, at least one application program, etc.; the data storage area can store data created based on the use of the electronic device 1000, etc. In addition, the memory 1001 can include a high-speed random access memory and a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device.

[0125] The processor 1002 is the control center of the electronic device 1000. It connects the various parts of the entire electronic device 1000 using the bus 1004 and various interfaces and lines. It executes or runs software programs and / or modules stored in the memory 1001 and calls data stored in the memory 1001 to perform various functions of the electronic device 500 and process data. Optionally, the processor 1002 may include one or more processing units, such as a CPU, a GPU (Graphics Processing Unit), a digital processing unit, etc.

[0126] Optionally, the electronic device according to the embodiment of the present invention may be an embedded device.

[0127] An embodiment of the present invention further provides a computer-readable storage medium storing computer-executable instructions. When the computer program is executed by a processor, the computer program can be used to implement the thread resource configuration method described in any embodiment of the present invention.

[0128] In some possible implementations, various aspects of the thread resource configuration method provided by the present invention may also be implemented in the form of a program product, which includes program code. When the program product is run on a computer device, the program code is used to enable the computer device to execute the steps of the thread resource configuration method according to various exemplary embodiments of the present invention described above in this specification. For example, the computer device may execute the following steps: Figure 1 The process of the thread resource configuration method of steps S101 to S103 is shown.

[0129] It will be understood by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0130] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0131] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0132] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0133] Obviously, those skilled in the art may make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if such changes and modifications fall within the scope of the claims and their equivalents, the present invention is intended to include such changes and modifications.

Claims

1. A thread resource configuration method, characterized in that: The method includes: Obtaining a target task to be processed; wherein the target task contains multiple subtasks to be processed; Determining, according to the processing order of each subtask included in the target task, a processing parameter corresponding to the target task and used to indicate the number of subtasks in the target task that need to be processed in parallel; Determining a thread threshold parameter corresponding to a target task, the thread threshold parameter including at least one of a total number of subtasks included in the target task, a thread upper limit corresponding to a preset target task type, and a number of processors processing the target task; configuring thread resources for the target task according to the processing parameters corresponding to the target task and the thread threshold parameters corresponding to the target task; Specifically, thread resources are configured for the target task in the following manner: If the thread threshold parameter includes the total number of subtasks included in the target task, the number of thread resources configured for the target task is not less than the processing parameter and not greater than the total number of subtasks included in the target task; If the thread threshold parameter includes a preset thread upper limit value corresponding to the target task type, the number of thread resources configured for the target task is not less than the processing parameter and not greater than the preset thread upper limit value corresponding to the target task type; If the thread threshold parameter includes the number of processors that process the target task, the number of thread resources configured for the target task shall not be less than the processing parameter and shall not be greater than n*P; wherein n is a positive integer greater than 1, and the value of n is determined according to the type of the target task, and P is the number of processors that process the target task.

2. The method according to claim 1, wherein The determining, according to the processing order of each subtask included in the target task, a processing parameter corresponding to the target task and used to indicate the number of subtasks in the target task that need to be processed in parallel, specifically includes: Determining the number of subtasks with the same priority in the target task according to the processing order of each subtask included in the target task; The maximum number of the determined subtasks with the same priority is used as a processing parameter corresponding to the target task.

3. A thread resource configuration device, characterized in that: The device includes: An acquisition unit, configured to acquire a target task to be processed; wherein the target task includes a plurality of subtasks to be processed; a determining unit, configured to determine, according to a processing order of each subtask included in the target task, a processing parameter corresponding to the target task and used to indicate the number of subtasks in the target task that need to be processed in parallel; a configuration unit, configured to determine a thread threshold parameter corresponding to a target task, and configure thread resources for the target task based on a processing parameter corresponding to the target task and the thread threshold parameter corresponding to the target task, wherein the thread threshold parameter includes at least one of a total number of subtasks included in the target task, a thread upper limit corresponding to a preset target task type, and a number of processors for processing the target task; The configuration unit is specifically used to: Configure thread resources for the target task in the following manner: If the thread threshold parameter includes the total number of subtasks included in the target task, the number of thread resources configured for the target task is not less than the processing parameter and not greater than the total number of subtasks included in the target task; If the thread threshold parameter includes a preset thread upper limit value corresponding to the target task type, the number of thread resources configured for the target task is not less than the processing parameter and not greater than the preset thread upper limit value corresponding to the target task type; If the thread threshold parameter includes the number of processors that process the target task, the number of thread resources configured for the target task shall not be less than the processing parameter and shall not be greater than n*P; wherein n is a positive integer greater than 1, and the value of n is determined according to the type of the target task, and P is the number of processors that process the target task.

4. The device according to claim 3, characterized in that The determining unit is specifically configured to: According to the processing order of each subtask included in the target task, the number of subtasks with the same priority in the target task is determined; and the maximum number of the determined subtasks with the same priority is used as the processing parameter corresponding to the target task.

5. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores program codes, and when the program codes are executed by the processor, the processor executes the steps of any one of the methods of claims 1 to 2.

6. A computer-readable storage medium, characterized in that The method comprises a program code, and when the program code is run on an electronic device, the program code is used to enable the electronic device to execute the steps of any one of the methods of claims 1 to 2.

Citation Information

Patent Citations

  • Task state management method and device

    CN109558237A