A multi-threaded resource management method and electronic device

By establishing a one-to-one mapping relationship between threads and resource sub-pools, and dynamically adjusting resource allocation and return, the data concurrency problem in multi-threaded resource management is solved, improving the efficiency of concurrent data processing and resource utilization.

CN121029436BActive Publication Date: 2026-02-13INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511567440.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-30
Publication Date
2026-02-13
Estimated Expiration
2045-10-30

AI Technical Summary

Technical Problem

In multi-threaded resource management, existing technologies suffer from data concurrency issues caused by resources being allocated twice, and mutex locks limit the efficiency of concurrent data processing between threads.

Method used

By establishing a one-to-one mapping relationship between threads and resource sub-pools, resource allocation and return are dynamically adjusted. By utilizing resource re-application and return mechanisms, the resource sub-pools are guaranteed to have sufficient and balanced resources, avoiding situations of insufficient or excessive resources.

Benefits of technology

It improves the speed and efficiency of multi-threaded concurrent data processing, maintains the stability and balance of resource sub-pools, and avoids problems of resource shortage or idleness.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121029436B_ABST
    Figure CN121029436B_ABST
Patent Text Reader

Abstract

The application discloses a multi-thread resource management method and electronic equipment, and relates to the technical field of computers, which comprises the following steps: constructing a one-to-one mapping relationship between threads and resource sub-pools; after a target resource sub-pool allocates resources to a target thread, re-applying a third target resource amount to a resource total pool through the target resource sub-pool according to a resource re-application mechanism, so that the target resource sub-pool always maintains a state of resource sufficiency and the situation of resource insufficiency of the target resource sub-pool is avoided; and after the target resource sub-pool receives a resource release request of the target thread, returning a fourth target resource amount to the resource total pool through the target resource sub-pool according to a resource return mechanism, so that the resource quantity in the plurality of resource sub-pools is in a relatively stable and relatively average state, the situation that some resource sub-pools are short of resources while some resource sub-pools are idle is avoided, and the speed of multi-thread concurrent data processing is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, and particularly relates to a multi-thread resource management method and electronic equipment. BACKGROUND

[0002] Resources required by thread running exist in the form of resource pools in the system, and thread running at least includes two processes of resource application and resource release. In the related technology of multi-thread resource management, when multiple threads apply for resources in the same resource pool, a resource may be allocated at least twice, thereby causing a data concurrency problem. On this basis, although the data concurrency problem can be solved by using a mutual exclusion lock, the method limits the efficiency of concurrent data processing between threads. SUMMARY

[0003] The present application provides a multi-thread resource management method and electronic equipment to solve the data concurrency problem of multi-thread and improve the speed of concurrent data processing of multi-thread.

[0004] The present application provides a multi-thread resource management method, which includes the following steps: determining a target resource sub-pool corresponding to a target thread according to a mapping relationship between multiple threads and multiple resource sub-pools, wherein the multiple threads and the multiple resource sub-pools are in one-to-one correspondence; in response to the target resource sub-pool receiving a first resource application request of the target thread, applying a first target resource amount to the target resource sub-pool from a resource total pool and applying a second target resource amount to the target thread from the target resource sub-pool; in response to the target resource sub-pool receiving a non-first resource application request of the target thread, applying the second target resource amount to the target thread from the target resource sub-pool; determining a first available resource amount of the target resource sub-pool, and applying a third target resource amount to the target resource sub-pool from the resource total pool according to the first available resource amount and a resource re-application mechanism; in response to the target resource sub-pool receiving a resource return request of the target thread, determining a second available resource amount of the target resource sub-pool, and returning a fourth target resource amount from the target resource sub-pool to the resource total pool according to the second available resource amount and a resource return mechanism.

[0005] The application further provides an electronic device, comprising: a memory for storing a computer program; and a processor for executing the computer program to implement a multi-thread resource management method comprising the following steps: determining a target resource sub-pool corresponding to a target thread according to a mapping relationship between a plurality of threads and a plurality of resource sub-pools, wherein the plurality of threads and the plurality of resource sub-pools are in one-to-one correspondence; in response to the target resource sub-pool receiving a first resource application request of the target thread, applying a first target resource amount to the target resource sub-pool from a resource total pool and applying a second target resource amount to the target thread from the target resource sub-pool; in response to the target resource sub-pool receiving a non-first resource application request of the target thread, applying the second target resource amount to the target thread from the target resource sub-pool; determining a first available resource amount of the target resource sub-pool, and applying a third target resource amount to the target resource sub-pool from the resource total pool according to the first available resource amount and a resource re-application mechanism; and in response to the target resource sub-pool receiving a resource return request of the target thread, determining a second available resource amount of the target resource sub-pool, and returning a fourth target resource amount from the target resource sub-pool to the resource total pool according to the second available resource amount and a resource return mechanism.

[0006] By establishing a one-to-one mapping relationship between threads and resource sub-pools, and re-applying a third target resource amount to the resource total pool from the target resource sub-pool according to the resource re-application mechanism after the target resource sub-pool allocates resources to the target thread, the target resource sub-pool can always maintain a state of sufficient resources; and in response to the target resource sub-pool receiving a resource release request of the target thread, the fourth target resource amount is returned from the target resource sub-pool to the resource total pool according to the resource return mechanism, so that the number of resources in the plurality of resource sub-pools is in a relatively stable and relatively average state. BRIEF DESCRIPTION OF DRAWINGS

[0007] In order to more clearly illustrate the embodiments of the application, the drawings required in the embodiments will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the application, and other drawings can be obtained by those skilled in the art without creative effort.

[0008] Figure 1 a flowchart of the multi-thread resource management method in the first embodiment;

[0009] Figure 2 a block diagram of the multi-thread resource management device in the second embodiment;

[0010] Figure 3 an internal structure diagram of the electronic device in the third embodiment. DETAILED DESCRIPTION

[0011] With reference to the drawings and specific embodiments described below, the technical solutions in the embodiments of the present application will be further described in detail.

[0012] It should be noted that, in the description of the present application, the terms "comprising", "containing" or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or equipment including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or further includes elements inherent to such process, method, article or equipment. The terms "first", "second" and the like in the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence.

[0013] In order for those skilled in the art to better understand the technical solutions of the present application, the present application will be further described in detail below with reference to the drawings and specific embodiments.

[0014] In the first embodiment, as shown in Figure 1 A multi-threaded resource management method is provided, which includes: determining a target resource sub-pool corresponding to a target thread according to a mapping relationship between a plurality of threads and a plurality of resource sub-pools, wherein the plurality of threads and the plurality of resource sub-pools are one-to-one corresponding; in response to the target resource sub-pool receiving a first resource application request of the target thread, applying a first target resource amount to the target resource sub-pool from a resource total pool, and applying a second target resource amount to the target thread from the target resource sub-pool; in response to the target resource sub-pool receiving a non-first resource application request of the target thread, applying the second target resource amount to the target thread from the target resource sub-pool; determining a first available resource amount of the target resource sub-pool, and applying a third target resource amount to the target resource sub-pool from the resource total pool according to the first available resource amount and a resource re-application mechanism; in response to the target resource sub-pool receiving a resource return request of the target thread, determining a second available resource amount of the target resource sub-pool, and returning a fourth target resource amount from the target resource sub-pool to the resource total pool according to the second available resource amount and a resource return mechanism.

[0015] Specifically, a one-to-one mapping relationship between the threads and the resource sub-pools is established, and after the target resource sub-pool allocates resources to the target thread, a third target resource amount is re-applied to the resource total pool through the target resource sub-pool according to the resource re-application mechanism, so as to ensure that the target resource sub-pool always maintains a state of sufficient resources and avoid the situation that the target resource sub-pool is insufficient in resources; after the target resource sub-pool receives the resource release request of the target thread, a fourth target resource amount is returned to the resource total pool through the target resource sub-pool according to the resource return mechanism, so as to ensure that the resource amounts in the plurality of resource sub-pools are in a relatively stable and relatively average state, avoid the situation that some resource sub-pools are short of resources while some resource sub-pools are idle, and improve the speed of multi-thread concurrent processing of data.

[0016] In a specific implementation, the number of the second target resource amount is 1. For example, when there is a message or data to be sent to another node, the concurrent thread needs to first find the corresponding resource sub-pool according to the mapping relationship and apply for a resource. The thread applies for a resource for the first time: when the system is initialized, all resources are concentrated in the resource total pool and no resources are allocated to the resource sub-pool, so that the resource sub-pool that receives the resource application cannot allocate resources to the thread at this time, and needs to apply for a part of resources from the resource total pool to be concentrated in its own internal management and allocate a resource to the thread for its use. There are two points to note here. First, when the resource sub-pool applies for resources from the resource total pool, it will face a concurrency problem, that is, other resource sub-pools may also be applying for resources from the resource total pool at the same time, so lock protection is needed. Second, when the resource sub-pool applies for a certain amount of resources from the resource total pool, if the resource total pool is sufficient in resources at this time, that is, the total amount of available resources is greater than the resource application amount, the number of the resource application amount is the number of the resource scheduling amount, and each resource sub-pool maintains the same resource scheduling amount during initialization. The thread applies for a resource during normal operation: after the resource sub-pool receives the resource application, it first allocates a resource from the resources it manages to the thread for sending messages or data to other nodes. After the allocation is completed, the resource sub-pool decides whether to supplement resources according to the use of the resources in the pool.

[0017] Further, before applying for the first target resource amount to the target resource sub-pool, the multi-thread resource management method further includes: determining a first load score of the system; comparing the first load score with a first preset value; in response to the first load score being less than the first preset value, determining that the number of the first resource scheduling amount is a second preset value, and determining the first target resource amount according to the second preset value; in response to the first load score being greater than or equal to the first preset value, determining that the number of the first resource scheduling amount is a third preset value, and determining the first target resource amount according to the third preset value; wherein the third preset value is less than the second preset value.

[0018] Specifically, when the target thread first applies for the resource, and other threads have applied for the resource, the first resource scheduling quantity is determined according to the first load score of the system in the current situation, and the first target resource quantity is determined according to the first resource scheduling quantity, the number of resources in the target resource sub-pool is dynamically adjusted according to the system load score, and the processing efficiency of the multi-thread is improved.

[0019] In specific embodiments, the first preset value can be set to 80, the second preset value can be set to 100, the third preset value can be set to 50, and the fourth preset value can be set to 25. According to the load score of the system, the corresponding resource scheduling quantity can be adjusted step by step, for example, from 100→50→25. The load score of the system can obtain data from four core subsystems of the processor, the memory, the disk input / output, and the network input / output, and perform correlation analysis in combination with business indicators or corresponding thresholds, and obtain the load score of the system through weighted calculation and the like.

[0020] Further, before applying for the third target resource quantity to the target resource sub-pool from the total resource pool according to the first available resource quantity and the resource re-application mechanism, the multi-thread resource management method further comprises: determining a second load score of the system; comparing the second load score with the first preset value; in response to the second load score being less than the first preset value and the number of the first resource scheduling quantity being the second preset value, determining the number of the second resource scheduling quantity as the second preset value; in response to the second load score being less than the first preset value and the number of the first resource scheduling quantity being the third preset value, determining the number of the second resource scheduling quantity as the second preset value; in response to the second load score being greater than or equal to the first preset value and the number of the first resource scheduling quantity being the second preset value, determining the number of the second resource scheduling quantity as the third preset value; in response to the second load score being greater than or equal to the first preset value and the number of the first resource scheduling quantity being the third preset value, determining the number of the second resource scheduling quantity as the fourth preset value; wherein the fourth preset value is less than the third preset value.

[0021] Specifically, before determining the third target resource quantity according to the resource re-application mechanism, the resource scheduling quantity is re-determined according to the load score of the system in the current situation, so as to determine the third target resource quantity according to the second resource scheduling quantity, and maintain the dynamic balance of the multi-thread resource.

[0022] Further, according to the first available resource amount and the resource reapplication mechanism, a third target resource amount is applied to the total resource pool to the target resource sub-pool, including: determining a first resource application threshold according to the quantity value of the second resource scheduling amount and a first preset coefficient; determining a second resource application threshold according to the quantity value of the second resource scheduling amount and a second preset coefficient, wherein the first preset coefficient is greater than the second preset coefficient; comparing the first available resource amount with the first resource application threshold and the second resource application threshold; in response to the first available resource amount being greater than or equal to the first resource application threshold, applying a resource amount with a quantity value of a fifth preset value to the target resource sub-pool from the total resource pool; in response to the first available resource amount being greater than or equal to the second resource application threshold and less than the first resource application threshold, determining a first resource application speed and a first resource return speed of the target resource sub-pool, and determining the quantity value of the third target resource amount according to the first resource application speed, the first resource return speed and the second resource scheduling amount; in response to the first available resource amount being less than the second resource application threshold, determining the quantity value of the third target resource amount according to the second resource scheduling amount.

[0023] Specifically, the resource scheduling amount dynamically changes according to the system load score, and on this basis, the first resource application threshold and the second resource application threshold are determined according to the second resource scheduling amount, and the quantity value of the third target resource amount is determined according to the size relationship between the first available resource amount and the first resource application threshold and the second resource application threshold, avoiding the situation that the target resource sub-pool is insufficient or excessive in resources.

[0024] In specific implementation, the first preset coefficient can be set to 20%, the second preset coefficient can be set to 5%, and the fifth preset value is 0.a. If the available resource amount in the resource sub-pool, i.e., the resource amount directly available for the thread, is not less than 20% of the resource scheduling amount, it is directly returned without processing;b. If the available resource amount in the resource sub-pool is less than 20% of the resource scheduling amount and not less than 5% of the resource scheduling amount, the third target resource amount is further determined according to the first resource application speed and the first resource return speed;c. If the available resource amount in the resource sub-pool is less than 5% of the resource scheduling amount, the resource sub-pool immediately initiates a resource application to the total resource pool, and the quantity value of the resource applied at one time is the quantity value corresponding to the second resource scheduling amount.

[0025] Further, determining the first resource application speed and the first resource return speed of the target resource sub-pool includes: obtaining a resource application time record of the target resource sub-pool, wherein the resource application time record at least includes a plurality of resource application times; determining the first resource application speed according to the plurality of resource application times; obtaining a resource return time record of the target resource sub-pool, wherein the resource return time record at least includes a plurality of resource return times; and determining the first resource return speed according to the plurality of resource return times.

[0026] Specifically, while dynamically adjusting the resource scheduling quantity according to the load score, the third target resource quantity is further dynamically adjusted from the aspects of the resource application speed and the resource return speed, so as to ensure the stability and uniformity of the resource quantity in the target resource sub-pool.

[0027] In a specific embodiment, the resource application speed is automatically updated each time the resource is applied. Each resource sub-pool maintains a resource application time record queue and a resource return time record queue. The resource application time record queue maintains n application records, and the resource return time record queue maintains n return records. n can be set according to the system performance, and a smaller value can be set for a flexible system. The record actually only records the time of each resource application. Taking n=6 as an example for illustration: when the system is initialized, t_1, t_2, t_3, t_4, t_5, and t_6 are initialized as the current system time. When the xthapplication arrives, the time record is updated: id=(x%n)+1, t_id=the current system time, for example, at this time x=100, id=5, V_allocate=1 / (t_5–t_4)×&1+1 / (t_4–t_3)×&2+1 / (t_3–t_2)×&3+1 / (t_2–t_1)×&4+1 / (t_1–t_6)×&5, V_free=1 / (t_5–t_4)×&6+1 / (t_4–t_3)×&7+1 / (t_3–t_2)×&8+1 / (t_2–t_1)×&9+1 / (t_1–t_6)×&10, wherein V_allocate represents the resource application speed, V_free represents the resource return speed, &1, &2, &3, &4, &5, &6, &7, &8, &9, and &10 are adjustable coefficients, and &1+&2+&3+&4+&5=1, &6+&7+&8+&9+&10=1.

[0028] Further, the quantity value of the third target resource quantity is determined according to the first resource application speed, the first resource return speed, and the second resource scheduling quantity, including: in response to the first resource application speed being less than or equal to the first resource return speed, determining the quantity value of the third target resource quantity according to the second resource scheduling quantity; in response to the first resource application speed being greater than the first resource return speed, determining the resource depletion time of the target resource sub-pool according to the first available resource quantity, the first resource application speed, and the first resource return speed; comparing the resource depletion time with a sixth preset value; and in response to the resource depletion time being less than the sixth preset value, determining the quantity value of the third target resource quantity according to the second resource scheduling quantity.

[0029] Specifically, in the case that the first available resource amount is greater than or equal to the second resource application threshold and less than the first resource application threshold, the quantity value of the third target resource amount is determined according to the size relationship between the first resource application speed and the first resource return speed, and the size relationship between the resource depletion time and the sixth preset value, further avoiding the problems of too many resources in the target resource sub-pool or insufficient resources.

[0030] In specific embodiments, V allocate x t = (NUM available + V free x t), that is, t = NUM available / (V allocate - V free), it is judged whether t is less than T alloc threashold. If yes, the resource sub-pool initiates resource application to the resource total pool, and applies for the second resource scheduling amount at a time. Wherein, NUM available represents the available resource amount in the resource pool sub-pool, t represents the resource depletion time, T alloc threashold is the sixth preset value, representing the maximum resource application time caused by competition when the resource sub-pool applies for resources from the resource total pool, which depends on system design, performance requirements and hardware capability, and is set according to actual conditions.

[0031] Further, the quantity value of the third target resource amount is determined according to the second resource scheduling amount, including: in response to the quantity value of the second resource scheduling amount being the second preset value, determining the quantity value of the third target resource amount as the second preset value; in response to the quantity value of the second resource scheduling amount being the third preset value, determining the quantity value of the third target resource amount as the third preset value; in response to the quantity value of the second resource scheduling amount being the fourth preset value, determining the quantity value of the third target resource amount as the fourth preset value.

[0032] Further, before the fourth target resource amount is returned from the target resource sub-pool to the resource total pool according to the second available resource amount and the resource return mechanism, the multi-threaded resource management method further comprises: determining a third load score of the system; comparing the third load score with the first preset value to obtain a comparison result; determining the quantity value of the third resource scheduling amount according to the comparison result; wherein the quantity value of the third resource scheduling amount at least includes the first preset value, the second preset value, the third preset value and the fourth preset value.

[0033] Further, according to the second available resource amount and the resource return mechanism, the fourth target resource amount is returned from the target resource sub-pool to the resource total pool, including: determining a first resource return threshold according to the quantity value of the third resource scheduling amount and a third preset coefficient; determining a second resource return threshold according to the quantity value of the third resource scheduling amount and a fourth preset coefficient, wherein the third preset coefficient is greater than the fourth preset coefficient; comparing the second available resource amount with the first resource return threshold and the second resource return threshold; in response to the second available resource amount being greater than the first resource return threshold, determining that the quantity value of the fourth target resource amount is the quantity value of the third resource scheduling amount, and returning the fourth target resource amount from the target resource sub-pool to the resource total pool; in response to the second available resource amount being greater than the second resource return threshold and less than or equal to the first resource return threshold, determining a second resource application speed and a second resource return speed of the target resource sub-pool, and determining the quantity value of the fourth target resource amount according to the second resource application speed, the second resource return speed, and the third resource scheduling amount; and in response to the second available resource amount being less than the second resource return threshold, applying a resource amount with a quantity value of a fifth preset value from the resource total pool to the target resource sub-pool.

[0034] Specifically, in addition to determining the third target resource amount according to the resource re-application mechanism, the fourth target resource amount is also determined according to the resource return mechanism, so as to avoid the case that the number of resources in the target resource pool is too large on the basis of ensuring that the target resource pool has sufficient resources.

[0035] In specific embodiments, the third preset coefficient can be set to 200%, and the fourth preset coefficient can be set to 150%. After the thread sends a message or data to other nodes using resources, the other nodes will release the resources back to the resource total pool for subsequent re-application. Thread resource release: after the resource sub-pool receives the resource release requirement, it first takes over the resources from the concurrent threads and collects them into the resources managed by itself. After completing the resource recycling action, the resource sub-pool needs to decide whether to return the excess resources to the resource total pool for use by other resource sub-pools according to its own resource usage: a. If the available resource amount in the resource sub-pool exceeds 200% of the third resource scheduling amount, which is an example value, the available resources of the resource sub-pool are returned to the total pool in a certain amount, generally the returned amount is the third resource scheduling amount; b. If the available resource amount in the resource sub-pool exceeds 150% of the third resource scheduling amount and is less than or equal to 200% of the third resource scheduling amount, and V_allocate<=V_free, the available resources of the resource sub-pool are returned to the resource total pool in a certain amount, generally the returned amount is the third resource scheduling amount; c. If the available resource amount in the resource sub-pool is less than 150% of the third resource scheduling amount, no processing is performed.

[0036] Further, the multi-threaded resource management method further includes: determining a total available resource amount of the total resource pool and a resource application amount of the target resource sub-pool; comparing the total available resource amount with the resource application amount, wherein the resource application amount at least includes the first target resource amount, the third target resource amount, and the fourth target resource amount; in response to the resource application amount being less than the total available resource amount, allocating the resource application amount from the total resource pool to the target resource sub-pool; in response to the resource application amount being greater than or equal to the total available resource amount, issuing a resource recovery request from the total resource pool to other resource sub-pools except the target resource sub-pool; in response to the other resource sub-pools receiving the resource recovery request, determining a third available resource amount of the other resource sub-pools and a quantity value of the current resource scheduling amount; determining a schedulable resource amount according to the third available resource amount and the quantity value of the current resource scheduling amount; returning the schedulable resource amount from the other resource sub-pools to the total resource pool; and in response to the total resource pool receiving the schedulable resource amount, allocating the resource application amount from the total resource pool to the target resource sub-pool.

[0037] Specifically, the other resource sub-pools can include one or more resource sub-pools. When the resource application amount is greater than or equal to the total available resource amount, the total resource pool actively recovers resources from the other resource sub-pools, and the recovered resources are re-allocated to the target resource sub-pool for use, thereby improving the efficiency of multi-threaded parallel data processing.

[0038] In a specific implementation, the total resource pool is a global resource scheduling unit, and needs to dynamically adjust resource allocation and use strategies according to real-time resource usage states of the system. When the system load is normal: the current situation at system initialization is maintained, and the system normally operates; when the overall system load is heavy: a. the resource scheduling amount is gradually reduced to speed up the flow of resources in the resource sub-pools; b. when the available resource amount in the total resource pool is insufficient to meet the resource scheduling amount of the resource sub-pools, and the resource scheduling amount is gradually reduced, the total resource pool actively recovers resources from the resource sub-pools for distribution to the application sub-pools; c. when only individual resource sub-pools are in a resource shortage: when the resource sub-pool applies for resources from the total resource pool, the resource scheduling amount thereof is gradually increased, such as 100→200→400, and the frequency of application and release of resources from the resource sub-pool to the total resource pool is used to monitor the resource dynamics in real time.

[0039] It should be understood that, although Figure 1 The steps in the flowchart of FIG. 1 are shown in sequence according to the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, the execution of these steps is not strictly limited in sequence, and these steps can be executed in other orders. Moreover, Figure 1At least one of the steps in the method can comprise a plurality of sub-steps or a plurality of stages, which sub-steps or stages are not necessarily performed at the same time, but can be performed at different times, and the order of the sub-steps or stages is not necessarily sequential, but can be performed alternately or in rotation with other steps or sub-steps or stages of other steps.

[0040] In a second embodiment, as shown in Figure 2 a multi-threaded resource management apparatus is provided, comprising: a first determining module, configured to determine a target resource sub-pool corresponding to a target thread according to a mapping relationship between a plurality of threads and a plurality of resource sub-pools, wherein the plurality of threads and the plurality of resource sub-pools are in one-to-one correspondence; a first applying module, configured to, in response to the target resource sub-pool receiving a first resource application request of the target thread, apply a first target resource amount to the target resource sub-pool from a resource total pool, and apply a second target resource amount to the target thread from the target resource sub-pool; a second applying module, configured to, in response to the target resource sub-pool receiving a non-first resource application request of the target thread, apply the second target resource amount to the target thread from the target resource sub-pool; a second determining module, configured to determine a first available resource amount of the target resource sub-pool; a third applying module, configured to, according to the first available resource amount and a resource re-application mechanism, apply a third target resource amount to the target resource sub-pool from the resource total pool; a third determining module, configured to, in response to the target resource sub-pool receiving a resource return request of the target thread, determine a second available resource amount of the target resource sub-pool; and a returning module, configured to, according to the second available resource amount and a resource return mechanism, return a fourth target resource amount from the target resource sub-pool to the resource total pool.

[0041] The specific limitations of the multi-threaded resource management apparatus can refer to the limitations of the multi-threaded resource management method in the foregoing, which will not be repeated here. Each module in the multi-threaded resource management apparatus described above can be realized by software, hardware and combinations thereof in whole or in part. The above-mentioned modules can be embedded in or independent of the processor in the electronic device in hardware form, or can be stored in the memory in the electronic device in software form, so as to be called and executed by the processor to perform the operations corresponding to each of the above-mentioned modules.

[0042] In a third embodiment, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, the processor implements the following steps when executing the computer program: determining a target resource sub-pool corresponding to a target thread according to a mapping relationship between a plurality of threads and a plurality of resource sub-pools, wherein the plurality of threads and the plurality of resource sub-pools are in one-to-one correspondence; in response to the target resource sub-pool receiving a first resource application request of the target thread, applying a first target resource amount to the target resource sub-pool and a second target resource amount to the target thread from a resource total pool; in response to the target resource sub-pool receiving a non-first resource application request of the target thread, applying the second target resource amount to the target thread from the target resource sub-pool; determining a first available resource amount of the target resource sub-pool, and applying a third target resource amount to the target resource sub-pool from the resource total pool according to the first available resource amount and a resource re-application mechanism; in response to the target resource sub-pool receiving a resource return request of the target thread, determining a second available resource amount of the target resource sub-pool, and returning a fourth target resource amount from the target resource sub-pool to the resource total pool according to the second available resource amount and a resource return mechanism.

[0043] The program instructions, when read and executed by one or more processors, can also perform operations corresponding to each of the steps in the above method embodiments, and the description above can be referred to, which will not be repeated here. Reference Figure 3 An exemplary architecture of the electronic device is shown, which can specifically include a processor 310, a video display adapter 311, a disk drive 312, an input / output interface 313, a network interface 314, and a memory 320. The processor 310, the video display adapter 311, the disk drive 312, the input / output interface 313, the network interface 314, and the memory 320 can be communicatively connected through a communication bus 330.

[0044] The processor 310 can be implemented in a general-purpose central processing unit (CPU), a microprocessor, an application specific integrated circuit (ASIC), or one or more integrated circuits, etc., for executing related programs to implement the technical solutions provided in the present application.

[0045] The memory 320 can be implemented in the form of a Read Only Memory (ROM), a Random Access Memory (RAM), a static storage device, a dynamic storage device, etc. The memory 320 can store an operating system 321 for controlling the operation of the electronic device 300, a basic input / output system (BIOS) 322 for controlling the low-level operation of the electronic device 300. In addition, a web browser 323, a data storage management 324, an icon font processing system 325, etc. can also be stored. The icon font processing system 325 described above can be an application program that specifically implements the operations of the above steps in the embodiments of the present application. In summary, when the technical solutions provided by the present application are implemented by software or firmware, the relevant program codes are stored in the memory 320 and executed by the processor 310.

[0046] The input / output interface 313 is used to connect input / output modules to realize information input and output. The input / output modules can be configured as components in the device (not shown in the figure) or can be externally connected to the device to provide corresponding functions. The input devices can include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output devices can include a display, a speaker, a vibrator, an indicator light, etc.

[0047] The network interface 314 is used to connect a communication module (not shown in the figure) to realize the communication interaction between the device and other devices. The communication module can realize communication through wired means (such as USB, network cable, etc.) or through wireless means (such as mobile network, WIFI, Bluetooth, etc.).

[0048] The bus 330 includes a channel for transmitting information between various components (such as the processor 310, the video display adapter 311, the disk drive 312, the input / output interface 313, the network interface 314, and the memory 320) of the device.

[0049] In addition, the electronic device 300 can also obtain information of the specific obtaining condition from a virtual resource object obtaining condition information database (not shown in the figure) to be used for condition judgment.

[0050] It should be noted that although the above electronic device 300 only shows the processor 310, the video display adapter 311, the disk drive 312, the input / output interface 313, the network interface 314, the memory 320, the bus 330, etc., in the specific implementation process, the electronic device can also include other components necessary for normal operation. In addition, those skilled in the art can understand that the above device can also only contain the components necessary to implement the solutions of the present application, and does not necessarily contain all the components shown in the figure.

[0051] Those skilled in the art can clearly understand the application can be implemented by means of software plus necessary universal hardware platforms from the description of the above embodiments. Based on such understanding, the technical solutions of the application can be embodied in the form of a software product, and the computer software product can be stored in a storage medium, such as a ROM / RAM, a magnetic disk, an optical disk, etc., and includes a plurality of instructions to make an electronic device (which can be a personal computer, a cloud server, or a network device, etc.) execute the methods of the various embodiments or some parts of the embodiments of the application.

[0052] In a fourth embodiment, a computer readable storage medium is provided, and the computer readable storage medium stores a computer program. The computer program is executed by a processor to implement the following steps: determining a target resource sub-pool corresponding to a target thread according to a mapping relationship between a plurality of threads and a plurality of resource sub-pools, wherein the plurality of threads and the plurality of resource sub-pools are in one-to-one correspondence; in response to the target resource sub-pool receiving a first resource application request of the target thread, applying a first target resource amount to the target resource sub-pool from a resource total pool and applying a second target resource amount to the target thread from the target resource sub-pool; in response to the target resource sub-pool receiving a non-first resource application request of the target thread, applying the second target resource amount to the target thread from the target resource sub-pool; determining a first available resource amount of the target resource sub-pool, and applying a third target resource amount to the target resource sub-pool from the resource total pool according to the first available resource amount and a resource re-application mechanism; in response to the target resource sub-pool receiving a resource return request of the target thread, determining a second available resource amount of the target resource sub-pool, and returning a fourth target resource amount from the target resource sub-pool to the resource total pool according to the second available resource amount and a resource return mechanism.

[0053] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when the computer program is executed, the processes of the above-mentioned embodiment methods can be included. Any reference to memory, storage, database, or other medium used in the embodiments provided in the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0054] The technical features of the above embodiments can be combined in any way. In order to make the description simple, all possible combinations of the technical features in the above embodiments are not described, but as long as the combinations of the technical features do not exist, they should be considered as the scope of the present application.

[0055] The above embodiments only express several implementation manners of the present application, and the description is specific and detailed, but it should not be understood as a limitation on the scope of the patent. It should be pointed out that for ordinary skilled in the art, without departing from the concept of the present application, some modifications and improvements can be made, which are all within the protection scope of the present application.

[0056] In a fifth embodiment, a computer program product is provided, and the computer program product stores a computer program. The computer program is executed by a processor to implement the following steps: determining a target resource sub-pool corresponding to a target thread according to a mapping relationship between a plurality of threads and a plurality of resource sub-pools, wherein the plurality of threads and the plurality of resource sub-pools are in one-to-one correspondence; in response to the target resource sub-pool receiving a first resource application request of the target thread, applying a first target resource amount to the target resource sub-pool from a resource total pool and applying a second target resource amount to the target thread from the target resource sub-pool; in response to the target resource sub-pool receiving a non-first resource application request of the target thread, applying the second target resource amount to the target thread from the target resource sub-pool; determining a first available resource amount of the target resource sub-pool, and applying a third target resource amount to the target resource sub-pool from the resource total pool according to the first available resource amount and a resource re-application mechanism; and in response to the target resource sub-pool receiving a resource return request of the target thread, determining a second available resource amount of the target resource sub-pool, and returning a fourth target resource amount from the target resource sub-pool to the resource total pool according to the second available resource amount and a resource return mechanism.

[0057] In the fifth embodiment, a computer program product is also provided, and the computer program product includes a non-volatile computer readable storage medium. The non-volatile computer readable storage medium stores a computer program. The computer program is executed by a processor to implement the following steps: determining a target resource sub-pool corresponding to a target thread according to a mapping relationship between a plurality of threads and a plurality of resource sub-pools, wherein the plurality of threads and the plurality of resource sub-pools are in one-to-one correspondence; in response to the target resource sub-pool receiving a first resource application request of the target thread, applying a first target resource amount to the target resource sub-pool from a resource total pool and applying a second target resource amount to the target thread from the target resource sub-pool; in response to the target resource sub-pool receiving a non-first resource application request of the target thread, applying the second target resource amount to the target thread from the target resource sub-pool; determining a first available resource amount of the target resource sub-pool, and applying a third target resource amount to the target resource sub-pool from the resource total pool according to the first available resource amount and a resource re-application mechanism; and in response to the target resource sub-pool receiving a resource return request of the target thread, determining a second available resource amount of the target resource sub-pool, and returning a fourth target resource amount from the target resource sub-pool to the resource total pool according to the second available resource amount and a resource return mechanism.

[0058] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by a computer program instructing related hardware. The computer program can be stored in a computer program product, and when executed, the computer program can include the processes of the above-mentioned embodiments.

[0059] Any technical features in the above embodiments can be combined, and for the sake of brevity, not all possible combinations are described above, however, as long as the combinations do not conflict with each other, they should be considered to be within the scope of the present disclosure.

[0060] The above embodiments only express several implementation manners of the present application, and the description is relatively specific and detailed, but it should not be understood as a limitation on the scope of the patent. It should be pointed out that for ordinary skilled persons in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are within the scope of the present application.

Claims

1. A method of managing resources in a multi-threaded environment, the method comprising: The method comprises: According to the mapping relationship between a plurality of threads and a plurality of resource sub-pools, a target resource sub-pool corresponding to a target thread is determined, wherein the plurality of threads and the plurality of resource sub-pools correspond one by one; In response to the target resource sub-pool receiving a first resource application request of the target thread, a first target resource amount is applied to the target resource sub-pool from a resource total pool, and a second target resource amount is applied to the target thread from the target resource sub-pool; In response to the target resource sub-pool receiving a non-first resource application request of the target thread, the second target resource amount is applied to the target thread from the target resource sub-pool; A first available resource amount of the target resource sub-pool is determined, and a third target resource amount is applied to the target resource sub-pool from the resource total pool according to the first available resource amount and a resource re-application mechanism; In response to the target resource sub-pool receiving a resource return request of the target thread, a second available resource amount of the target resource sub-pool is determined, and a fourth target resource amount is returned from the target resource sub-pool to the resource total pool according to the second available resource amount and a resource return mechanism; Before applying the first target resource amount to the target resource sub-pool from the resource total pool, the method further comprises: A first load score of the system is determined; According to the size relationship between the first load score and a first preset value, the number value of the first resource scheduling amount is determined, and the first target resource amount is determined according to the number value of the first resource scheduling amount; Before applying the third target resource amount to the target resource sub-pool from the resource total pool according to the first available resource amount and the resource re-application mechanism, the method further comprises: A second load score of the system is determined, and the number value of the second resource scheduling amount is determined according to the size relationship between the second load score and the first preset value and the number value of the first resource scheduling amount; The third target resource amount is applied to the target resource sub-pool from the resource total pool according to the first available resource amount and the resource re-application mechanism, comprising: According to the number value of the second resource scheduling amount and a first preset coefficient, a first resource application threshold is determined; According to the number value of the second resource scheduling amount and a second preset coefficient, a second resource application threshold is determined; According to the size relationship between the first available resource amount and the first resource application threshold and the second resource application threshold, the number value of the third target resource amount is determined; Before returning the fourth target resource amount from the target resource sub-pool to the resource total pool according to the second available resource amount and the resource return mechanism, the method further comprises: A third load score of the system is determined, and the number value of the third resource scheduling amount is determined according to the size relationship between the third load score and the first preset value; The fourth target resource amount is returned from the target resource sub-pool to the resource total pool according to the second available resource amount and the resource return mechanism, comprising: According to the number value of the third resource scheduling amount and a third preset coefficient, a first resource return threshold is determined; determining a second resource return threshold according to the third resource scheduling quantity and a fourth preset coefficient; determining a quantity value of the fourth target resource quantity according to a size relationship between the second available resource quantity and the first resource return threshold and the second resource return threshold.

2. The method of claim 1, wherein, Before applying the first target resource quantity to the target resource sub-pool from the total resource pool, the method further comprises: comparing the first load score with the first preset value; in response to the first load score being less than the first preset value, determining that the quantity value of the first resource scheduling quantity is a second preset value, and determining the first target resource quantity according to the second preset value; in response to the first load score being greater than or equal to the first preset value, determining that the quantity value of the first resource scheduling quantity is a third preset value, and determining the first target resource quantity according to the third preset value; wherein the third preset value is less than the second preset value.

3. The method of claim 2, wherein, Before applying the third target resource quantity to the target resource sub-pool from the total resource pool according to the first available resource quantity and a resource re-application mechanism, the method further comprises: comparing the second load score with the first preset value; in response to the second load score being less than the first preset value and the quantity value of the first resource scheduling quantity being the second preset value, determining that the quantity value of the second resource scheduling quantity is the second preset value; in response to the second load score being less than the first preset value and the quantity value of the first resource scheduling quantity being the third preset value, determining that the quantity value of the second resource scheduling quantity is the second preset value; in response to the second load score being greater than or equal to the first preset value and the quantity value of the first resource scheduling quantity being the second preset value, determining that the quantity value of the second resource scheduling quantity is the third preset value; in response to the second load score being greater than or equal to the first preset value and the quantity value of the first resource scheduling quantity being the third preset value, determining that the quantity value of the second resource scheduling quantity is a fourth preset value; wherein the fourth preset value is less than the third preset value.

4. The method of claim 3, wherein, The first preset coefficient is greater than the second preset coefficient, and the applying the third target resource quantity to the target resource sub-pool from the total resource pool according to the first available resource quantity and the resource re-application mechanism comprises: comparing the first available resource quantity with the first resource application threshold and the second resource application threshold; in response to the first available resource quantity being greater than or equal to the first resource application threshold, applying a resource quantity with a quantity value of a fifth preset value to the target resource sub-pool from the total resource pool; in response to the first available resource quantity being greater than or equal to the second resource application threshold and less than the first resource application threshold, determining a first resource application speed and a first resource return speed of the target resource sub-pool, and determining the quantity value of the third target resource quantity according to the first resource application speed, the first resource return speed and the second resource scheduling quantity; In response to the first available resource quantity being less than the second resource application threshold, determining a quantity value of the third target resource quantity according to the second resource scheduling quantity.

5. The method of claim 4, wherein, The determining the first resource application speed and the first resource return speed of the target resource sub-pool comprises: obtaining a resource application time record of the target resource sub-pool, wherein the resource application time record comprises at least a plurality of resource application times; determining the first resource application speed according to the plurality of resource application times; obtaining a resource return time record of the target resource sub-pool, wherein the resource return time record comprises at least a plurality of resource return times; determining the first resource return speed according to the plurality of resource return times.

6. The method of claim 4, wherein, The determining the quantity value of the third target resource quantity according to the first resource application speed, the first resource return speed and the second resource scheduling quantity comprises: in response to the first resource application speed being less than or equal to the first resource return speed, determining the quantity value of the third target resource quantity according to the second resource scheduling quantity; in response to the first resource application speed being greater than the first resource return speed, determining a resource depletion time of the target resource sub-pool according to the first available resource quantity, the first resource application speed and the first resource return speed; comparing the resource depletion time with a sixth preset value; in response to the resource depletion time being less than the sixth preset value, determining the quantity value of the third target resource quantity according to the second resource scheduling quantity.

7. The method of claim 4 or 6, wherein, The determining the quantity value of the third target resource quantity according to the second resource scheduling quantity comprises: in response to the quantity value of the second resource scheduling quantity being the second preset value, determining the quantity value of the third target resource quantity as the second preset value; in response to the quantity value of the second resource scheduling quantity being the third preset value, determining the quantity value of the third target resource quantity as the third preset value; in response to the quantity value of the second resource scheduling quantity being the fourth preset value, determining the quantity value of the third target resource quantity as the fourth preset value.

8. The method of claim 4, wherein, The quantity value of the third resource scheduling quantity comprises at least the first preset value, the second preset value, the third preset value and the fourth preset value.

9. The method of claim 8, wherein, The third preset coefficient is greater than the fourth preset coefficient, and the returning the fourth target resource quantity from the target resource sub-pool to the resource total pool according to the second available resource quantity and the resource return mechanism comprises: comparing the second available resource quantity with the first resource return threshold and the second resource return threshold; in response to the second available resource quantity being greater than the first resource return threshold, determining the quantity value of the fourth target resource quantity as the quantity value of the third resource scheduling quantity, and returning the fourth target resource quantity from the target resource sub-pool to the resource total pool; determining a second resource application speed and a second resource return speed of the target resource sub-pool in response to the second available resource quantity being greater than the second resource return threshold and less than or equal to the first resource return threshold, and determining a quantity value of the fourth target resource quantity according to the second resource application speed, the second resource return speed, and the third resource scheduling quantity; applying a resource quantity with a quantity value of the fifth preset value from the resource total pool to the target resource sub-pool in response to the second available resource quantity being less than the second resource return threshold.

10. An electronic device, comprising: The method comprises the steps of: a memory for storing a computer program; a processor for executing the computer program to implement the steps of the multi-threaded resource management method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Multi-thread resource scheduling method and device, equipment and medium

    CN116954915A

  • Resource access control method and device, computer equipment and storage medium

    CN118069071A