Resource management method and device
The resource management method and device dynamically allocate resource indexes using an automatic generator, addressing the long initialization times in network devices by generating indexes on demand, thereby reducing initialization time.
Patent Information
- Application Number
- CN202411001071.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-24
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2044-07-24
Smart Images

Figure CN119071252A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a resource management method and device. Background Art
[0002] In network devices (eg, routing devices, switching devices, etc.), resources such as counters are usually used. Each data flow on the network device may need to be allocated with one or more counters for statistics.
[0003] Currently, all available resource indexes (for example, counter indexes, etc.) corresponding to the same resource in a network device are in a resource pool, and the resource pool needs to be initialized when the network device is started. As a result, when the number of resource indexes is large, it takes a long time to initialize the resource pool, resulting in a long initialization time for the entire network device. Summary of the invention
[0004] In order to overcome the problems existing in the related art, the present application provides a resource management method and device.
[0005] According to a first aspect of an embodiment of the present application, a resource management method is provided, the method being applied to a resource management module in a network device, the method comprising:
[0006] receiving a resource application request for applying for a resource index of a target resource sent by a first client in the network device;
[0007] If the number of available resource indexes in the resource pool corresponding to the target resource is 0, then when the number of resource indexes generated by the resource index automatic generator corresponding to the target resource is less than the number of available resource indexes currently configured in the resource pool, the resource index automatic generator is called to generate a first target resource index for the target resource;
[0008] Sending a resource request response carrying the first target resource index to the first client;
[0009] Wherein, initially, the number of resource indexes generated by the resource index automatic generator is 0;
[0010] When the number of resource indexes generated by the resource index automatic generator is 0, the value of the first target resource index is 0;
[0011] When the number of resource indexes generated by the resource index automatic generator is not 0, the value of the first target resource index is the value of the resource index last generated by the resource index automatic generator plus 1.
[0012] According to a second aspect of an embodiment of the present application, a resource management device is provided, the device being applied to a resource management module in a network device, the device comprising:
[0013] A receiving unit, configured to receive a resource application request for applying for a resource index of a target resource sent by a first client in the network device;
[0014] A processing unit, configured to, if the number of available resource indexes in the resource pool corresponding to the target resource is 0, call the resource index automatic generator to generate a first target resource index for the target resource when the number of resource indexes generated by the resource index automatic generator corresponding to the target resource is less than the number of available resource indexes currently configured in the resource pool; and send a resource request response carrying the first target resource index to the first client;
[0015] Wherein, initially, the number of resource indexes generated by the resource index automatic generator is 0;
[0016] When the number of resource indexes generated by the resource index automatic generator is 0, the value of the first target resource index is 0;
[0017] When the number of resource indexes generated by the resource index automatic generator is not 0, the value of the first target resource index is the value of the resource index last generated by the resource index automatic generator plus 1.
[0018] The technical solution provided by the embodiments of the present application may have the following beneficial effects:
[0019] In an embodiment of the present application, for the resource management module in the network device, the following operation process is performed: receiving a resource application request for applying for a resource index of a target resource sent by a first client in the network device; if the number of available resource indexes in the resource pool corresponding to the target resource is 0, then when the resource index automatic generator corresponding to the target resource has not generated a resource index or the number of resource indexes generated by the resource index automatic generator is less than the number of available resource indexes currently configured in the resource pool, calling the resource index automatic generator to generate a first target resource index for the target resource; and sending a resource application response carrying the first target resource index to the first client.
[0020] In this way, the network device does not need to initialize the relevant resource pool, which can effectively shorten the initialization time of the network device when the number of resource indexes is large.
[0021] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The accompanying drawings, which are incorporated in the specification and constitute a part of this application, illustrate embodiments consistent with the application and, together with the description, serve to explain the principles of the application.
[0023] Figure 1 A schematic diagram of a resource management method provided in an embodiment of the present application;
[0024] Figure 2 One of the schematic diagrams of the resource management module managing the resource pool provided in the embodiment of the present application;
[0025] Figure 3 A second schematic diagram of a resource management module managing a resource pool provided in an embodiment of the present application;
[0026] Figure 4 The third schematic diagram of the resource management module managing the resource pool provided in the embodiment of the present application;
[0027] Figure 5 A fourth schematic diagram of a resource management module managing a resource pool provided in an embodiment of the present application;
[0028] Figure 6 A schematic diagram of the structure of a resource management device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0029] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0030] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. The singular forms of "a", "said" and "the" used in this application and the appended claims are also intended to include plural forms unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0031] It should be understood that, although the terms first, second, third, etc. may be used in the present application to describe various information, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" or "if" as used herein may be interpreted as "at the time of" or "when...".
[0032] Next, the embodiments of the present application are described in detail.
[0033] The present application embodiment provides a resource management method, which is applied to a resource management module in a network device, such as Figure 1 As shown, the method may include the following steps:
[0034] S11. Receive a resource application request for applying for a resource index of a target resource sent by a first client in a network device.
[0035] In this step, the target resource may be a counter resource or the like.
[0036] S12. If the number of available resource indexes in the resource pool corresponding to the target resource is 0, when the number of resource indexes generated by the resource index automatic generator corresponding to the target resource is less than the number of available resource indexes currently configured in the resource pool, the resource index automatic generator is called to generate a first target resource index for the target resource.
[0037] In this step, initially, the number of resource indexes generated by the resource index automatic generator is 0.
[0038] When the number of resource indexes generated by the resource index automatic generator is 0, the value of the first target resource index is 0.
[0039] When the number of resource indexes generated by the resource index automatic generator is not 0, the value of the first target resource index is the value of the resource index last generated by the resource index automatic generator plus 1.
[0040] S13. Send a resource request response carrying a first target resource index to the first client.
[0041] It should be noted that in the above step S12, when the number of available resource indexes in the resource pool corresponding to the target resource is 0, if the resource index automatic generator corresponding to the target resource has not generated a resource index, this means that the above resource application request is received by the resource management module for the first time. At this time, the resource management module directly calls the resource index automatic generator to generate a first target resource index for the target resource, and then executes the above step S13.
[0042] If the number of resource indexes generated by the resource index automatic generator is less than the number of available resource indexes currently configured in the resource pool, this means that the above resource application request is not the first time received by the resource management module, and there have been available resource indexes in the resource pool but they have been read out (which can also be understood as allocated). At this time, the resource management module can also directly call the resource index automatic generator to generate a first target resource index for the target resource, and then execute the above step S13.
[0043] In this way, the resource index application and usage requirements can be met without initializing the resource pool.
[0044] Furthermore, in the embodiment of the present application, in order to facilitate the administrator to flexibly manage the resource pool, the resource management module may also perform the following operations:
[0045] If a resource modification instruction input by an administrator for modifying the number of available resource indexes currently configured in the resource pool is received, the number of available resource indexes currently configured in the resource pool is modified to the new number of available resource indexes indicated by the resource modification instruction.
[0046] Here, the new available resource index number indicated by the resource modification instruction may be carried in the resource modification instruction. Moreover, the modified available resource index number may be greater than the available resource index number before the modification, or may be less than the available resource index number before the modification.
[0047] That is, the administrator can flexibly increase or decrease the number of available resource indexes configured for the resource pool according to resource requirements.
[0048] For example, assuming that the number of available resource indexes currently configured in the resource pool corresponding to the target resource is 100, if the resource management module receives a resource modification instruction input by the administrator carrying a new number of available resource indexes (for example, 110), then the resource management module will modify the number of available resource indexes currently configured in the resource pool to 110.
[0049] For another example, assuming that the number of available resource indexes currently configured in the resource pool corresponding to the target resource is 100, if the resource management module receives a resource modification instruction input by the administrator containing a new number of available resource indexes (for example, 80), then the resource management module will modify the number of available resource indexes currently configured in the resource pool to 80.
[0050] Furthermore, in the embodiment of the present application, the resource management module may also perform the following operations:
[0051] If a first resource release request for releasing a second target resource index of a target resource sent by a first client is received, determining whether a value of the second target resource index is not less than a value of the number of resource indexes available in the resource pool;
[0052] When the judgment result is yes, discard the second target resource index;
[0053] When the judgment result is no, the second target resource index is written into the sub-memory area in the memory area corresponding to the resource pool pointed to by the head pointer of the resource pool, and the head pointer of the resource pool is pointed to the next sub-memory area corresponding to the sub-memory area, and the number of available resource indexes in the resource pool is increased by 1;
[0054] Initially, the number of available resource indexes in the resource pool is 0, and the head pointer and the tail pointer of the resource pool both point to the first sub-memory area in the memory area whose content is empty;
[0055] When the sub-memory area pointed to by the head pointer is the last sub-memory area in the memory area, the corresponding next sub-memory area is the first sub-memory area in the memory area.
[0056] It should be noted that in this operation process, the reason why the judgment result is yes is mainly because the number of available resource indexes configured for the resource pool is reduced.
[0057] It should be further explained that, in an embodiment of the present application, the resource management module uses the sub-memory area pointed to by the head pointer of the resource pool to store the resource index released by the client, and provides the resource index in the sub-memory area pointed to by the tail pointer of the resource pool to the client for use.
[0058] In addition, in the embodiment of the present application, after receiving the resource application request, the resource management module may perform the following operations:
[0059] The first operation: if the number of available resource indexes in the resource pool corresponding to the target resource is 0, and the number of resource indexes generated by the resource index automatic generator is not less than the number of available resource indexes currently configured in the resource pool, an error identifier representing resource exhaustion is sent to the first client.
[0060] The second operation: if the number of available resource indexes in the resource pool corresponding to the target resource is greater than 0, then read the value of the resource index currently pointed to by the tail pointer corresponding to the resource pool;
[0061] If the read value is not greater than the value of the number of available resource indexes currently configured in the resource pool, a resource request response carrying the resource index currently pointed to by the tail pointer is sent to the first client, and the tail pointer is pointed to the next resource index of the resource index corresponding to the value read in the resource pool, and the number of available resource indexes in the resource pool is reduced by 1;
[0062] If the read value is greater than the value of the number of available resource indexes currently configured in the resource pool, the read value is discarded, the number of available resource indexes in the resource pool is reduced by 1, and when the number of available resource indexes in the current resource pool is 0, an error mark indicating resource exhaustion is sent to the first client; or,
[0063] When the number of available resource indexes in the current resource pool is greater than 0, the tail pointer is pointed to the next resource index of the resource index corresponding to the value read from the resource pool, and the step of reading the value of the resource index currently pointed to by the tail pointer corresponding to the resource pool is continued;
[0064] Wherein, initially, the tail pointer points to the first sub-memory area in the memory area corresponding to the resource pool, and the resource index in the first sub-memory area is written by the resource management module when the resource management module receives a second resource release request sent by a second client in the network device and carrying the resource index in the first sub-memory area, and the head pointer of the resource pool points to the first sub-memory area with empty content;
[0065] When the resource index currently pointed to by the tail pointer corresponding to the resource pool is the resource index in the last sub-memory area in the memory area, the corresponding next resource index is the resource index in the first sub-memory area in the memory area.
[0066] It should be noted that after the resource management module receives the resource application request, if the number of available resource indexes in the resource pool corresponding to the target resource is 0 and the number of resource indexes generated by the resource index automatic generator is not less than the number of available resource indexes currently configured in the resource pool, this means that there are no available resource indexes in the resource pool, and the number of resource indexes generated by the resource index automatic generator has reached the number of available resource indexes currently configured in the resource pool or has exceeded the number of available resource indexes currently configured in the resource pool (the situation that occurs after the number of available resource indexes currently configured is reduced). In this case, resource indexes can no longer be allocated to the target resource, and an error identifier used to indicate resource exhaustion is sent to the first client.
[0067] For example, initially, Figure 2 As shown, on the resource manager module side in the network device 1, it is assumed that the resource pool corresponding to the counter resource corresponds to the memory area 1, and there are 2N – 1 sub-memory area, one sub-memory area stores 1 resource index, which can also be understood as the maximum number of resource indexes corresponding to the Resource Pool (recorded as Mask) is 2 N –1 (denoted as SIZE-1); the number of available resource indexes currently configured in the Resource Pool (denoted as Capacity, for example, Capacity is MAX) is 100; the number of available resource indexes in the Resource Pool (denoted as Count) is 0; the head pointer (denoted as Head) and tail pointer (denoted as Tail) corresponding to the Resource Pool point to the first sub-memory area corresponding to the Resource Pool, and the values of Head and Tail can be denoted as 0; the starting address of the first sub-memory area is the base address (Base) corresponding to the Resource Pool; the number of resource indexes generated by the resource index automatic generator corresponding to the counter resource (denoted as Auto Generator) is 0.
[0068] Assume that at time 1, the Resource Manager module receives a resource application request 1 for a resource index of a counter resource sent by client 1 in network device 1. The Resource Manager module finds that the number of available resource indexes in the resource pool corresponding to the counter resource is 0, and the resource index automatic generator corresponding to the counter resource has not generated a resource index. At this time, the Resource Manager module calls the resource index automatic generator to generate a resource index 1 (the corresponding value is 0) for the counter resource. And send a resource request response 1 carrying resource index 1 to client 1, and add 1 to the number of resource indexes generated by the resource index automatic generator, such as Figure 3 shown.
[0069] Assume that at time 2, the Resource Manager module receives a resource release request 1 sent by client 1 for releasing resource index 1. The Resource Manager module determines whether the value of resource index 1 is not less than the value of the number of resource indexes available in the resource pool; assuming that the number of resource indexes available in the resource pool is 0, and assuming that the head pointer of the resource pool points to the first sub-memory area, then the judgment result is no. At this time, the Resource Manager module writes resource index 1 into the first sub-memory area pointed to by the head pointer of the resource pool, and points the head pointer of the resource pool to the second sub-memory area corresponding to the resource pool, that is, the value of the head pointer is increased by 1, and the number of resource indexes available in the resource pool is increased by 1, such as Figure 4 shown.
[0070] Assume that at time 3, all available resource indexes in the resource pool have been allocated, the values of the head pointer and the tail pointer are N, and the number of resource indexes generated by the resource index automatic generator is MAX. At this time, the Resource Manager module receives a resource modification instruction 1 input by the administrator to modify the number of available resource indexes currently configured in the resource pool, wherein the resource modification instruction 1 carries a new number of available resource indexes (for example, MAX'). In this case, the ResourceManager module modifies the number of available resource indexes currently configured in the resource pool (that is, MAX) to MAX', as shown in FIG. Figure 5 Here, MAX' is greater than MAX.
[0071] Next, assume that the Resource Manager module receives a resource application request 2 sent by client 1 for a resource index of a counter resource. The Resource Manager module finds that the number of available resource indexes in the resource pool corresponding to the counter resource is 0, and the number of resource indexes generated by the resource index automatic generator corresponding to the counter resource (i.e., MAX) is less than the number of available resource indexes currently configured in the resource pool (i.e., MAX'). At this time, the ResourceManager module calls the resource index automatic generator to generate a resource index 2 for the counter resource (the corresponding value is MAX+1). It also sends a resource application response 2 carrying resource index 2 to client 1, and adds 1 to the number of resource indexes generated by the resource index automatic generator.
[0072] It can be seen from the above technical scheme that in an embodiment of the present application, for the resource management module in the network device, the following operation process is performed: receiving a resource application request for applying for a resource index of a target resource sent by a first client in the network device; if the number of available resource indexes in the resource pool corresponding to the target resource is 0, then when the resource index automatic generator corresponding to the target resource has not generated a resource index or the number of resource indexes generated by the resource index automatic generator is less than the number of available resource indexes currently configured in the resource pool, calling the resource index automatic generator to generate a first target resource index for the target resource; and sending a resource application response carrying the first target resource index to the first client.
[0073] In this way, the network device does not need to initialize the relevant resource pool, which can effectively shorten the initialization time of the network device when the number of resource indexes is large.
[0074] Based on the same inventive concept, the present application also provides a resource management device, which is applied to a resource management module in a network device. Figure 6 As shown, specifically including:
[0075] The receiving unit 61 is configured to receive a resource application request for applying for a resource index of a target resource sent by a first client in the network device;
[0076] Processing unit 62 is used for, if the number of available resource indexes in the resource pool corresponding to the target resource is 0, then when the number of resource indexes generated by the resource index automatic generator corresponding to the target resource is less than the number of available resource indexes currently configured in the resource pool, calling the resource index automatic generator to generate a first target resource index for the target resource; and sending a resource request response carrying the first target resource index to the first client;
[0077] Wherein, initially, the number of resource indexes generated by the resource index automatic generator is 0;
[0078] When the number of resource indexes generated by the resource index automatic generator is 0, the value of the first target resource index is 0;
[0079] When the number of resource indexes generated by the resource index automatic generator is not 0, the value of the first target resource index is the value of the resource index last generated by the resource index automatic generator plus 1.
[0080] Preferably, the device further comprises:
[0081] Modify the unit ( Figure 6 (not shown) is used to modify the number of available resource indexes currently configured in the resource pool to the new number of available resource indexes indicated by the resource modification instruction if a resource modification instruction input by an administrator is received to modify the number of available resource indexes currently configured in the resource pool.
[0082] Preferably, the processing unit 62 is further used for:
[0083] If a first resource release request for releasing a second target resource index of the target resource sent by the first client is received, determining whether the value of the second target resource index is not less than the value of the number of resource indexes available in the resource pool;
[0084] When the judgment result is yes, discard the second target resource index;
[0085] When the judgment result is no, writing the second target resource index into the sub-memory area in the memory area corresponding to the resource pool pointed to by the head pointer of the resource pool, and pointing the head pointer of the resource pool to the next sub-memory area corresponding to the sub-memory area, and increasing the number of available resource indexes in the resource pool by 1;
[0086] Wherein, initially, the number of available resource indexes in the resource pool is 0, and the head pointer and the tail pointer of the resource pool both point to the first sub-memory area in the memory area whose content is empty;
[0087] When the sub-memory area pointed to by the head pointer is the last sub-memory area in the memory area, the corresponding next sub-memory area is the first sub-memory area in the memory area.
[0088] Preferably, the processing unit 62 is further used for:
[0089] After the receiving unit 61 receives the resource application request, if the number of available resource indexes in the resource pool corresponding to the target resource is 0, and the number of resource indexes generated by the resource index automatic generator is not less than the number of available resource indexes currently configured in the resource pool, an error identifier for indicating resource exhaustion is sent to the first client.
[0090] Preferably, the management module 62 is further used for:
[0091] After the receiving unit 61 receives the resource application request, if the number of available resource indexes in the resource pool corresponding to the target resource is greater than 0, read the value of the resource index currently pointed to by the tail pointer corresponding to the resource pool;
[0092] If the read value is not greater than the value of the number of available resource indexes currently configured in the resource pool, a resource request response carrying the resource index currently pointed to by the tail pointer is sent to the first client, and the tail pointer is pointed to the next resource index of the resource index corresponding to the value read in the resource pool, and the number of available resource indexes in the resource pool is reduced by 1;
[0093] If the read value is greater than the value of the number of available resource indexes currently configured in the resource pool, the read value is discarded, the number of available resource indexes in the resource pool is reduced by 1, and when the number of available resource indexes in the resource pool is currently 0, an error mark indicating resource exhaustion is sent to the first client; or,
[0094] When the number of available resource indexes in the current resource pool is greater than 0, the tail pointer is pointed to the next resource index of the resource index corresponding to the value read from the resource pool, and the step of reading the value of the resource index currently pointed to by the tail pointer corresponding to the resource pool is continued;
[0095] Wherein, initially, the tail pointer points to the first sub-memory area in the memory area corresponding to the resource pool, and the resource index in the first sub-memory area is written by the resource management module when receiving a second resource release request sent by a second client in the network device and carrying the resource index in the first sub-memory area, and the head pointer of the resource pool points to the first sub-memory area whose content is empty;
[0096] When the resource index currently pointed to by the tail pointer corresponding to the resource pool is the resource index in the last sub-memory area in the memory area, the corresponding next resource index is the resource index in the first sub-memory area in the memory area.
[0097] It can be seen from the above technical scheme that in an embodiment of the present application, for the resource management module in the network device, the following operation process is performed: receiving a resource application request for applying for a resource index of a target resource sent by a first client in the network device; if the number of available resource indexes in the resource pool corresponding to the target resource is 0, then when the resource index automatic generator corresponding to the target resource has not generated a resource index or the number of resource indexes generated by the resource index automatic generator is less than the number of available resource indexes currently configured in the resource pool, calling the resource index automatic generator to generate a first target resource index for the target resource; and sending a resource application response carrying the first target resource index to the first client.
[0098] In this way, the network device does not need to initialize the relevant resource pool, which can effectively shorten the initialization time of the network device when the number of resource indexes is large.
[0099] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A resource management method, characterized in that: The method is applied to a resource management module in a network device, and the method comprises: receiving a resource application request for applying for a resource index of a target resource sent by a first client in the network device; If the number of available resource indexes in the resource pool corresponding to the target resource is 0, then when the number of resource indexes generated by the resource index automatic generator corresponding to the target resource is less than the number of available resource indexes currently configured in the resource pool, the resource index automatic generator is called to generate a first target resource index for the target resource; Sending a resource request response carrying the first target resource index to the first client; Wherein, initially, the number of resource indexes generated by the resource index automatic generator is 0; When the number of resource indexes generated by the resource index automatic generator is 0, the value of the first target resource index is 0; When the number of resource indexes generated by the resource index automatic generator is not 0, the value of the first target resource index is the value of the resource index last generated by the resource index automatic generator plus 1.
2. The method according to claim 1, characterized in that The method further comprises: If a resource modification instruction input by an administrator for modifying the number of available resource indexes currently configured in the resource pool is received, the number of available resource indexes currently configured in the resource pool is modified to the new number of available resource indexes indicated by the resource modification instruction.
3. The method according to claim 1, characterized in that: The method further comprises: If a first resource release request for releasing a second target resource index of the target resource sent by the first client is received, determining whether the value of the second target resource index is not less than the value of the number of resource indexes available in the resource pool; When the judgment result is yes, discard the second target resource index; When the judgment result is no, writing the second target resource index into the sub-memory area in the memory area corresponding to the resource pool pointed to by the head pointer of the resource pool, and pointing the head pointer of the resource pool to the next sub-memory area corresponding to the sub-memory area, and increasing the number of available resource indexes in the resource pool by 1; Wherein, initially, the number of available resource indexes in the resource pool is 0, and the head pointer and the tail pointer of the resource pool both point to the first sub-memory area in the memory area whose content is empty; When the sub-memory area pointed to by the head pointer is the last sub-memory area in the memory area, the corresponding next sub-memory area is the first sub-memory area in the memory area.
4. The method according to claim 1, characterized in that: The method further comprises: After receiving the resource application request, if the number of available resource indexes in the resource pool corresponding to the target resource is 0, and the number of resource indexes generated by the resource index automatic generator is not less than the number of available resource indexes currently configured in the resource pool, an error identifier used to indicate resource exhaustion is sent to the first client.
5. The method according to claim 1, characterized in that The method further comprises: After receiving the resource application request, if the number of available resource indexes in the resource pool corresponding to the target resource is greater than 0, reading the value of the resource index currently pointed to by the tail pointer corresponding to the resource pool; If the read value is not greater than the value of the number of available resource indexes currently configured in the resource pool, a resource request response carrying the resource index currently pointed to by the tail pointer is sent to the first client, and the tail pointer is pointed to the next resource index of the resource index corresponding to the value read in the resource pool, and the number of available resource indexes in the resource pool is reduced by 1; If the read value is greater than the value of the number of available resource indexes currently configured in the resource pool, the read value is discarded, the number of available resource indexes in the resource pool is reduced by 1, and when the number of available resource indexes in the resource pool is currently 0, an error mark indicating resource exhaustion is sent to the first client; or, When the number of available resource indexes in the current resource pool is greater than 0, the tail pointer is pointed to the next resource index of the resource index corresponding to the value read from the resource pool, and the step of reading the value of the resource index currently pointed to by the tail pointer corresponding to the resource pool is continued; Wherein, initially, the tail pointer points to the first sub-memory area in the memory area corresponding to the resource pool, and the resource index in the first sub-memory area is written by the resource management module when receiving a second resource release request sent by a second client in the network device and carrying the resource index in the first sub-memory area, and the head pointer of the resource pool points to the first sub-memory area whose content is empty; When the resource index currently pointed to by the tail pointer corresponding to the resource pool is the resource index in the last sub-memory area in the memory area, the corresponding next resource index is the resource index in the first sub-memory area in the memory area.
6. A resource management device, characterized in that: The device is applied to a resource management module in a network device, and the device comprises: A receiving unit, configured to receive a resource application request for applying for a resource index of a target resource sent by a first client in the network device; A processing unit, configured to, if the number of available resource indexes in the resource pool corresponding to the target resource is 0, call the resource index automatic generator to generate a first target resource index for the target resource when the number of resource indexes generated by the resource index automatic generator corresponding to the target resource is less than the number of available resource indexes currently configured in the resource pool; and send a resource request response carrying the first target resource index to the first client; Wherein, initially, the number of resource indexes generated by the resource index automatic generator is 0; When the number of resource indexes generated by the resource index automatic generator is 0, the value of the first target resource index is 0; When the number of resource indexes generated by the resource index automatic generator is not 0, the value of the first target resource index is the value of the resource index last generated by the resource index automatic generator plus 1.
7. The device according to claim 6, characterized in that The device also includes: The modification unit is used to modify the number of available resource indexes currently configured in the resource pool to a new number of available resource indexes indicated by the resource modification instruction if a resource modification instruction input by an administrator to modify the number of available resource indexes currently configured in the resource pool is received.
8. The device according to claim 6, characterized in that The processing unit is further used for: If a first resource release request for releasing a second target resource index of the target resource sent by the first client is received, determining whether the value of the second target resource index is not less than the value of the number of resource indexes available in the resource pool; When the judgment result is yes, discard the second target resource index; When the judgment result is no, writing the second target resource index into the sub-memory area in the memory area corresponding to the resource pool pointed to by the head pointer of the resource pool, and pointing the head pointer of the resource pool to the next sub-memory area corresponding to the sub-memory area, and increasing the number of available resource indexes in the resource pool by 1; Wherein, initially, the number of available resource indexes in the resource pool is 0, and the head pointer and the tail pointer of the resource pool both point to the first sub-memory area in the memory area whose content is empty; When the sub-memory area pointed to by the head pointer is the last sub-memory area in the memory area, the corresponding next sub-memory area is the first sub-memory area in the memory area.
9. The device according to claim 6, characterized in that The processing unit is further used for: After the receiving unit receives the resource application request, if the number of available resource indexes in the resource pool corresponding to the target resource is 0, and the number of resource indexes generated by the resource index automatic generator is not less than the number of available resource indexes currently configured in the resource pool, an error identifier for indicating resource exhaustion is sent to the first client.
10. The device according to claim 6, characterized in that The processing unit is further used for: After the receiving unit receives the resource application request, if the number of available resource indexes in the resource pool corresponding to the target resource is greater than 0, read the value of the resource index currently pointed to by the tail pointer corresponding to the resource pool; If the read value is not greater than the value of the number of available resource indexes currently configured in the resource pool, a resource request response carrying the resource index currently pointed to by the tail pointer is sent to the first client, and the tail pointer is pointed to the next resource index of the resource index corresponding to the value read in the resource pool, and the number of available resource indexes in the resource pool is reduced by 1; If the read value is greater than the value of the number of available resource indexes currently configured in the resource pool, the read value is discarded, the number of available resource indexes in the resource pool is reduced by 1, and when the number of available resource indexes in the resource pool is currently 0, an error mark indicating resource exhaustion is sent to the first client; or, When the number of available resource indexes in the current resource pool is greater than 0, the tail pointer is pointed to the next resource index of the resource index corresponding to the value read from the resource pool, and the step of reading the value of the resource index currently pointed to by the tail pointer corresponding to the resource pool is continued; Wherein, initially, the tail pointer points to the first sub-memory area in the memory area corresponding to the resource pool, and the resource index in the first sub-memory area is written by the resource management module when receiving a second resource release request sent by a second client in the network device and carrying the resource index in the first sub-memory area, and the head pointer of the resource pool points to the first sub-memory area whose content is empty; When the resource index currently pointed to by the tail pointer corresponding to the resource pool is the resource index in the last sub-memory area in the memory area, the corresponding next resource index is the resource index in the first sub-memory area in the memory area.
Citation Information
Patent Citations
Resource pool generation method and device
CN104331330A
Resource management method and system, electronic equipment and storage medium
CN112269659A
Information transmission method and device
CN115334654A
Memory allocation device and method, equipment and medium
CN115344387A
Resource query method and device, electronic equipment and storage medium
CN117076753A
