A method, device, server and medium for sharing resource access

By introducing lease and priority queue mechanisms into the enterprise physical infrastructure management platform, the starvation problem in shared resource access is solved, ensuring that high-priority operations are executed first, thereby improving the reliability and efficiency of resource access.

CN115129455BActive Publication Date: 2026-06-26JINAN INSPUR DATA TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
JINAN INSPUR DATA TECH CO LTD
Filing Date
2022-07-22
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

Enterprise physical infrastructure management platforms suffer from starvation issues in the synchronous control of shared resources, where high-priority operations cannot be executed in a timely manner, and existing database control methods lead to resource access blockage and insufficient priority guarantee mechanisms.

Method used

By setting up a lease and priority queue mechanism, access permissions for shared resources are obtained. Leases have an expiration date, and the system automatically deletes expired leases. Priority queues are established for each operation to ensure that operations with higher priority can obtain resources first.

Benefits of technology

It effectively prevents starvation caused by long waiting times, ensures that high-priority operations can access shared resources in a timely manner, and improves the reliability of synchronous access to the enterprise physical infrastructure management platform.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115129455B_ABST
    Figure CN115129455B_ABST
Patent Text Reader

Abstract

The application discloses a method and device for sharing resource access, a server and a medium, and relates to the field of servers. The method comprises the following steps: when a current resource is in an occupied state and a current operation meets preset requirements, the current operation is added to a priority queue; the waiting time of each operation in the priority queue is obtained; the order of the operation with the waiting time exceeding a waiting threshold in the priority queue is improved, and an updated priority queue is obtained; and when the current resource is in a non-occupied state, the operations access the current resource according to the updated priority queue. In the method, the order of the operation with the waiting time exceeding the threshold in the priority queue is improved, so that the starvation problem of the operation with the waiting time exceeding the threshold when waiting for accessing the current resource is solved; in addition, the operations access the current resource according to the priority queue, so that the operation with a high priority accesses the current resource preferentially, and the reliability of the enterprise physical infrastructure management platform in synchronously accessing the shared resource is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of servers, and in particular to a method, apparatus, server, and medium for accessing shared resources. Background Technology

[0002] The Enterprise Physical Infrastructure Management Platform is a hardware intelligent operation and maintenance management platform for industry data centers. The platform manages devices through various operations. Because different operations have different steps and scopes of impact, when multiple operations access the same device, some need to be synchronized, while others do not. For example, configuring snapshot recovery and BMC firmware version upgrade for the same device's Baseboard Management Controller (BMC) requires synchronized control; these two operations can only be performed sequentially, not simultaneously.

[0003] Currently, enterprise physical infrastructure management platforms mostly control the synchronization of shared resources through databases. These databases record the access status of shared resources. Before performing any operation on a shared resource, the platform checks its access status. If no other operation is accessing the resource, the platform updates the access status in the database to "occupied." If the resource is already occupied, the current operation is blocked until the other operation completes and the resource status is changed to "idle." This database-based shared resource access control method suffers from the problem of operations being blocked due to resource occupancy, leading to prolonged periods without execution and a starvation problem. Furthermore, after the resource is released, one of multiple operations may request and successfully occupy it; there is no priority guarantee mechanism, making it impossible to ensure that higher-priority operations are executed first.

[0004] Therefore, how to solve the starvation problem caused by the platform's synchronous control of shared resources and ensure that higher-priority operations are executed first are technical problems that urgently need to be solved by those skilled in the art. Summary of the Invention

[0005] The purpose of this application is to provide a method, apparatus, server, and medium for accessing shared resources, which can solve the starvation problem caused by the platform's synchronous control of shared resources and ensure that higher-priority operations are executed first.

[0006] To address the aforementioned technical problems, this application provides a method for accessing shared resources, comprising:

[0007] Obtain the current operation of the enterprise physical infrastructure management platform for the lease request of the current resource to be accessed;

[0008] The information of the current resource is queried according to the lease application; wherein, the information of the current resource includes at least the current resource's occupancy status, the current resource's lease, and the priority queue for accessing the current resource;

[0009] If the current resource is occupied and the current operation meets the preset requirements, the current operation is added to the priority queue.

[0010] Obtain the waiting time corresponding to each operation in the priority queue;

[0011] The operation whose waiting time exceeds the waiting threshold is obtained, the operation whose waiting time exceeds the waiting threshold is promoted in the priority queue, and the updated priority queue is obtained;

[0012] When the current resource is not occupied, each operation accesses the current resource according to the updated priority queue control.

[0013] Preferably, before adding the current operation to the priority queue, the method further includes:

[0014] If the current resource is in an occupied state, obtain the first operation of occupying the current resource;

[0015] Determine whether the first operation is the current operation;

[0016] If so, then control the current operation to continue accessing the current resource;

[0017] If not, determine whether the current operation meets the preset requirements. If the current operation meets the preset requirements, proceed to the step of adding the current operation to the priority queue.

[0018] Preferably, when the current resource is in an unoccupied state and the current operation meets the preset requirements, the method further includes:

[0019] Determine whether the operation to access the current resource exists in the priority queue;

[0020] If so, proceed to the step of adding the current operation to the priority queue;

[0021] If not, then control the current operation to access the current resource.

[0022] Preferably, after the operation ends and access to the current resource is completed, the method further includes:

[0023] Receive a request to return the current resource;

[0024] The second operation to acquire the currently occupied resource;

[0025] Determine whether the second operation is the currently described operation;

[0026] If so, the lease application is allowed to be removed; operations in the priority queue are processed sequentially according to their order in the priority queue.

[0027] Preferably, the method further includes:

[0028] Starting from the time the current operation accesses the current resource, obtain the duration of the current operation accessing the current resource;

[0029] If the duration of the current operation accessing the current resource exceeds the lease duration in the lease application and the lease is renewed, record the number of renewals;

[0030] If the duration of the current operation's access to the current resource exceeds the lease duration in the lease application and the lease is not renewed, the current operation's occupation of the current resource is reclaimed, and an interruption request is sent to the current operation; it is determined whether there is an operation in the priority queue. If there is, if the current operation completely exits its occupation of the current resource, the current resource is allocated to the operation with the highest priority in the priority queue.

[0031] Preferably, the step of querying the current resource information based on the lease application includes:

[0032] Obtain a resource list; wherein the resource list includes at least the ID corresponding to each resource, the occupancy status of each resource, the lease of each resource, and the priority queue for accessing each resource;

[0033] Based on the lease application, retrieve information about the current resource from the resource list.

[0034] Preferably, the method further includes:

[0035] Lock the resource list.

[0036] To address the aforementioned technical problems, this application also provides a shared resource access device, comprising:

[0037] The first acquisition module is used to acquire the current operation of the enterprise physical infrastructure management platform and the lease application for the current resource to be accessed.

[0038] The query module is used to query information about the current resource based on the lease application; wherein, the information about the current resource includes at least the current resource's occupancy status, the current resource's lease, and the priority queue for accessing the current resource;

[0039] The addition module is used to add the current operation to the priority queue if the current resource is occupied and the current operation meets the preset requirements.

[0040] The second acquisition module is used to acquire the waiting time corresponding to each operation in the priority queue;

[0041] The third acquisition module is used to acquire the operations whose waiting time exceeds the waiting threshold, promote the order of the operations whose waiting time exceeds the waiting threshold in the priority queue, and acquire the updated priority queue.

[0042] The control module is used to control each operation to access the current resource according to the updated priority queue when the current resource is in an unoccupied state.

[0043] To address the aforementioned technical problems, this application also provides a server, comprising:

[0044] Memory, used to store computer programs;

[0045] A processor, used to implement the steps of the above-described method for accessing shared resources when executing the computer program.

[0046] To address the aforementioned technical problems, this application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the aforementioned method for accessing shared resources.

[0047] This application provides a method for accessing shared resources, comprising: obtaining lease applications for current resources to be accessed from the current operation of an enterprise physical infrastructure management platform; querying information about the current resource based on the lease applications; if the current resource is occupied and the current operation meets preset requirements, adding the current operation to a priority queue; obtaining the waiting time corresponding to each operation in the priority queue; obtaining operations whose waiting time exceeds a waiting threshold and improving their order in the priority queue, and obtaining an updated priority queue; if the current resource is not occupied, controlling each operation to access the current resource according to the updated priority queue. Therefore, this method improves the order of operations whose waiting time exceeds a threshold in the priority queue, preventing starvation caused by prolonged waiting times; and controls each operation to access the current resource according to the updated priority queue, ensuring that higher-priority operations can access the current resource first, thus improving the reliability of the enterprise physical infrastructure management platform's synchronous access to shared resources.

[0048] In addition, this application also provides a device, server, and computer-readable storage medium for accessing shared resources, which have the same or corresponding technical features as the methods for accessing shared resources mentioned above, and have the same effects. Attached Figure Description

[0049] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0050] Figure 1 A flowchart illustrating a method for accessing shared resources provided in an embodiment of this application;

[0051] Figure 2 A structural diagram of a shared resource access apparatus provided in an embodiment of this application;

[0052] Figure 3 A structural diagram of a server provided in another embodiment of this application;

[0053] Figure 4 This application provides a shared resource access system. Detailed Implementation

[0054] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.

[0055] The core of this application is to provide a method, apparatus, server, and medium for accessing shared resources, which is used to solve the starvation problem caused by the platform's synchronous control of shared resources and to ensure that higher-priority operations are executed first.

[0056] The Enterprise Physical Infrastructure Management Platform is a hardware intelligent operation and maintenance management platform for industry data centers. Currently, the synchronization control of shared resources by the Enterprise Physical Infrastructure Management Platform is mostly accomplished through a database. The database records the access status of shared resources. Before performing any operation on a shared resource, the platform checks the access status of the shared resource. If no other operation is accessing the current shared resource, the platform updates the access status of the shared resource in the database to "occupied". If the current shared resource is already occupied by another operation, the current operation will be blocked until the other operation is completed and the resource status is changed to "idle". This database-based shared resource access control method has the following problems: A single access requires two database operations: querying and modifying. If both accesses read the currently idle access state sequentially, they will both assume the shared resource is not yet occupied, update the database record to occupied, and begin accessing the shared resource, causing access control to fail. The access state is saved on an external persistent device. If the program exits abnormally, or if the operation fails to release the resource after the shared resource access ends, updating the resource state to idle will cause a state lock, leading to the failure of all subsequent accesses. Operations can be blocked due to resource occupation. When the resource is released, if a new operation requests and occupies the resource before the blocked operation, the blocked operation will continue to be blocked, resulting in a long delay and starvation. When multiple operations are waiting for the same resource to be released, these blocked operations have different importance and priorities. After the resource is released, one of the multiple operations will request and successfully occupy the resource. There is no mechanism to guarantee priority, and it is impossible to guarantee that higher-priority operations will be executed first. Therefore, in this embodiment, a lease is set for shared resources to obtain access to the shared resources. The lease has a certain time limit, and the system will automatically delete it after the lease expires. Client operations that have obtained a lease for shared resources can end the lease early after the operation is completed, or they can choose to renew the lease when the operation is not completed but the lease expires. Furthermore, a priority queue is established for each operation that applies for the same shared resource to ensure that higher priority operations obtain leases first, improve the priority of operations that have been waiting for a long time, and avoid the starvation problem caused by an operation not being able to obtain access to the shared resources for a long time.

[0057] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments. Figure 1 A flowchart illustrating a method for accessing shared resources provided in an embodiment of this application is shown below. Figure 1 As shown, the method includes:

[0058] S10: Obtain the current operation of the enterprise physical infrastructure management platform for the lease request of the current resource to be accessed.

[0059] When accessing shared resources is required for the current operation, a lease request must be submitted first. The lease request includes information such as resource user information, lease start time, lease end time, and number of extensions.

[0060] S11: Query the information of the current resource based on the lease application; wherein the information of the current resource includes at least the current resource occupancy status, the current resource lease, and the priority queue for accessing the current resource.

[0061] If a lease request is not processed promptly upon receipt, it may result in a prolonged wait before accessing the shared resource, or even if access is granted after a long wait, the shared resource may still be inaccessible. Therefore, in practice, upon receiving a lease request, the system first queries the information of the current shared resource to promptly analyze whether the current operation is permitted to access the resource.

[0062] S12: If the current resource is occupied and the current operation meets the preset requirements, add the current operation to the priority queue.

[0063] In practice, after a current operation requests a resource, the resource may be in a occupied state or an unoccupied state, i.e., idle. The current operation may need to access the resource immediately or it may not; that is, the current operation can wait for a period of time as long as it can access the resource. The preset requirement in this embodiment refers to the current operation not needing to access the resource immediately. If the current operation is added to the priority queue when the resource is occupied and it needs to access it immediately, it will affect the progress of the current operation. Therefore, in this embodiment, the current operation is only added to the priority queue when the resource is occupied and it does not need to access it immediately.

[0064] S13: Get the waiting time for each operation in the priority queue;

[0065] S14: Retrieve operations whose waiting time exceeds the waiting threshold, promote the order of operations whose waiting time exceeds the waiting threshold in the priority queue, and retrieve the updated priority queue;

[0066] S15: When the current resource is not occupied, control each operation to access the current resource according to the updated priority queue.

[0067] From the moment an operation is added to the priority queue, the duration of each operation in the priority queue is recorded; this is the waiting time for each operation. In implementation, the priority queue can be scanned at a fixed frequency to obtain the waiting time of each operation. The obtained waiting time for each operation is then compared with a threshold. It should be noted that the threshold for the waiting times of multiple operations can be set to the same threshold, or separate thresholds can be set for each operation; there is no limitation on this. When using the same threshold, the average waiting time in the priority queue can be selected as the threshold based on experience. When each operation corresponds to a different threshold, a corresponding threshold can be set based on the importance of each operation. When the waiting time exceeds the threshold, the priority of operations exceeding the threshold in the priority queue can be increased, allowing operations with waiting times exceeding the threshold to access the current resource as quickly as possible, avoiding starvation problems caused by long waiting times.

[0068] The method for accessing shared resources provided in this embodiment includes: obtaining lease applications for current resources to be accessed from the current operation of the enterprise physical infrastructure management platform; querying information about the current resource based on the lease applications; adding the current operation to a priority queue if the current resource is occupied and the current operation meets preset requirements; obtaining the waiting time corresponding to each operation in the priority queue; obtaining operations whose waiting time exceeds a waiting threshold and improving their order in the priority queue, and obtaining an updated priority queue; and controlling each operation to access the current resource according to the updated priority queue if the current resource is not occupied. Therefore, this method improves the order of operations whose waiting time exceeds a threshold in the priority queue, preventing starvation caused by prolonged waiting times. Furthermore, controlling each operation to access the current resource according to the updated priority queue ensures that higher-priority operations can access the current resource first, improving the reliability of the enterprise physical infrastructure management platform's synchronous access to shared resources.

[0069] In implementation, the operation occupying the current resource may or may not be the current operation. To improve the efficiency of the current operation accessing the current resource, a preferred implementation method further includes, before adding the current operation to the priority queue, the shared resource access method:

[0070] If the current resource is occupied, retrieve the first operation that occupies the current resource;

[0071] Determine if the first operation is the current operation;

[0072] If so, then control the current operation to continue accessing the current resource;

[0073] If not, determine whether the current operation meets the preset requirements. If the current operation meets the preset requirements, proceed to the step of adding the current operation to the priority queue.

[0074] If the requester of the first operation is the holder of the current operation, then return a message allowing continued access to the current resource. If the requester of the first operation is not the holder of the current operation, and the current operation does not need to access the current resource immediately, then the current operation can be added to the priority queue. If the current operation needs to access the current resource immediately, then return a message indicating that the resource is already in use.

[0075] This embodiment first determines whether the operation occupying the current resource is the current operation before adding it to the priority queue. If it is the current operation, access to the current resource is allowed; otherwise, the current operation is added to the priority queue. Compared to directly adding the current operation to the priority queue when the current resource is already occupied, this embodiment improves the efficiency of the current operation accessing the current resource.

[0076] In practice, the current resource may be in an unoccupied state. To improve the efficiency of the current operation accessing the current resource, a preferred implementation method, when the current resource is in an unoccupied state and the current operation meets preset requirements, further includes:

[0077] Determine if there are any operations in the priority queue that need to access the current resource;

[0078] If so, proceed to the step of adding the current operation to the priority queue;

[0079] If not, then control the current operation to access the current resource.

[0080] If the current resource is not occupied, first check if there are any operations waiting to access the current resource in the priority queue. If there are, add the current operation to the priority queue and process the operations in the order of the priority queue. If not, directly allocate the current resource to the current operation.

[0081] This embodiment provides a method for determining the processing of a current operation based on the operations in the priority queue when the current resource is not currently occupied. If it is determined that there are no operations in the priority queue, the current resource is directly allocated to the current operation. Compared to a method that does not pre-determine whether the priority queue contains an operation seeking to access the current resource, but instead adds the current operation to the priority queue and then retrieves the current operation from the priority queue and allocates the current resource, this embodiment improves the efficiency of the current operation accessing the current resource.

[0082] In this application, a lease is set for shared resources to obtain access permissions. In implementation, if the current operation continuously sends lease requests, it may prevent other operations from accessing the current resource. Therefore, in addition to lease requests, a return request is also required for the current resource. A preferred embodiment is that, after an operation finishes accessing the current resource, the method for accessing the shared resource further includes:

[0083] Receive requests to return current resources;

[0084] Acquire the second operation that is currently using the resource;

[0085] Determine if the second operation is the current operation;

[0086] If so, the lease request can be removed; operations in the priority queue are processed sequentially according to their order in the priority queue.

[0087] When a return request is received, the system first retrieves the second operation currently occupying the resource. If the second operation is the current operation, it means the current operation is currently accessing the resource. If removing the current operation is allowed, the current operation's access to the resource will be interrupted, preventing it from fully acquiring the resource. If the second operation is not the current operation, it means the current operation is not currently accessing the resource. Therefore, upon receiving the return request, the current operation's lease request can be removed, and operations will be processed sequentially according to the priority queue. It should be noted that the return request is generally issued after the current operation has finished accessing the resource.

[0088] The return application provided in this embodiment avoids the situation where the current resources are occupied for a long time due to the failure to return the lease for an extended period, which would affect subsequent operations.

[0089] When the current operation is sharing resources under a lease, the duration of the current operation's access to the current resource may exceed the lease duration specified in the lease application. After the lease duration has expired, the current operation may choose to renew or not. Different handling methods can be applied to different situations. In practice, a preferred implementation method further includes:

[0090] Get the duration of the current operation accessing the current resource, starting from the time the current operation started accessing the current resource.

[0091] If the duration of the current operation accessing the current resource exceeds the lease duration in the lease application and the lease is renewed, record the number of renewals;

[0092] If the duration of the current operation accessing the current resource exceeds the lease duration in the lease application and the lease is not renewed, the current operation's occupation of the current resource is reclaimed, and an interruption request is sent to the current operation; it is determined whether there is an operation in the priority queue. If there is, the current resource is allocated to the highest priority operation in the priority queue after the current operation completely exits its occupation of the current resource.

[0093] If the duration of access to the current resource exceeds the lease duration specified in the lease request, the number of renewals can be recorded if renewal is attempted. In practice, a high number of renewals may cause other operations to wait for extended periods, impacting their execution. Therefore, a renewal threshold can be set for the current operation; once this threshold is exceeded, renewal is not permitted. To improve the efficiency of accessing the current resource, some fixed attribute information for the current operation can be recorded in the database only when the lease is first requested. During renewals, this information can be directly retrieved from the database, eliminating the need to record this fixed attribute information for each renewal.

[0094] If the duration of a current operation's access to a current resource exceeds the lease duration specified in the lease request, the current operation's use of the current resource can be interrupted if the lease is not renewed. After the current operation's access to the current resource is interrupted, if there are operations in the priority queue, the current resource can be allocated to the highest priority operation in the priority queue after the current operation has completely exited its use of the current resource.

[0095] This embodiment provides different processing methods for renewal and non-renewal operations, which enables the current resource allocation to be adjusted according to the renewal status, so that the current operation or the operation in the priority queue can access the current resource.

[0096] In implementation, there may be situations where multiple operations need to access the current resource, or multiple operations access multiple shared resources. If the information of each shared resource cannot be organized, the current resource status cannot be understood in a timely manner. Therefore, the preferred implementation method is to query the current resource information based on the lease application, including:

[0097] Get the resource list; the resource list should at least include the ID of each resource, the occupancy status of each resource, the lease of each resource, and the priority queue for accessing each resource.

[0098] Retrieve information about current resources from the resource list based on the lease application.

[0099] Resource information is described through a resource list, which can be read from a specified location or initially empty, added when an operation first requests a resource. Each resource corresponds to a record in the resource list, containing the following basic information: Resource Identity Document (ID), a unique identifier for a resource; Status, determining whether the resource is occupied, distinguishing between read and write states; Priority queue, added to the priority queue if the current resource is occupied and a new operation requests it; Lease, indicating the resource user information, lease start time, lease end time, and number of extensions if the resource is currently occupied. When a lease request is received, the resource information can be viewed by querying the resource list.

[0100] This embodiment records resource information in a resource list, making it convenient for users to view information about each shared resource.

[0101] In the processes of lease application, lease return, and priority queue adjustment, modifications to the resource list are involved, thus requiring synchronization control for these methods. However, setting these methods as synchronous methods would severely impact the allocation efficiency of shared resources. Therefore, in implementation, a preferred approach is that the shared resource access method further includes:

[0102] Lock the resource list.

[0103] By setting locks on the resource list and applying locks in segments, only one method can access the same shared resource at a time. Locking allows for atomic modification of the access status of shared resources in the list, avoiding issues caused by multiple database accesses.

[0104] The above embodiments have described a method for accessing shared resources in detail. This application also provides embodiments of an apparatus and a server for accessing shared resources. It should be noted that this application describes the embodiments of the apparatus from two perspectives: one based on functional modules and the other based on hardware.

[0105] Figure 2 A structural diagram of a shared resource access apparatus provided according to an embodiment of this application. This embodiment, based on functional modules, includes:

[0106] The first acquisition module 10 is used to acquire the current operation of the enterprise physical infrastructure management platform and the lease application of the current resource to be accessed.

[0107] The query module 11 is used to query the information of the current resource based on the lease application; wherein the information of the current resource includes at least the current resource occupancy status, the current resource lease, and the priority queue for accessing the current resource;

[0108] Add module 12 to add the current operation to the priority queue if the current resource is occupied and the current operation meets the preset requirements;

[0109] The second acquisition module 13 is used to acquire the waiting time corresponding to each operation in the priority queue;

[0110] The third acquisition module 14 is used to acquire operations whose waiting time exceeds the waiting threshold, improve the order of operations whose waiting time exceeds the waiting threshold in the priority queue, and acquire the updated priority queue.

[0111] The control module 15 is used to control each operation to access the current resource according to the updated priority queue when the current resource is not occupied.

[0112] Since the embodiments of the apparatus and the embodiments of the method correspond to each other, please refer to the description of the embodiments of the method for the embodiments of the apparatus, which will not be repeated here.

[0113] The shared resource access device provided in this embodiment obtains the lease application for the current resource to be accessed from the current operation of the enterprise physical infrastructure management platform through a first acquisition module; queries the information of the current resource based on the lease application through a query module; wherein, the information of the current resource includes at least the current resource occupancy status, the current resource lease, and the priority queue for accessing the current resource; through an addition module, if the current resource is occupied and the current operation meets the preset requirements, the current operation is added to the priority queue; the second acquisition module obtains the waiting time corresponding to each operation in the priority queue; the third acquisition module obtains the operations whose waiting time exceeds the waiting threshold, improves the order of the operations whose waiting time exceeds the waiting threshold in the priority queue, and obtains the updated priority queue; and the control module controls each operation to access the current resource according to the updated priority queue when the current resource is not occupied. Therefore, this device improves the order of operations in the priority queue that have a waiting time exceeding the threshold, preventing starvation caused by these operations being unable to access the current resource due to long waiting times. Secondly, it controls the access of each operation to the current resource according to the updated priority queue, so that higher-priority operations can access the current resource first, improving the reliability of the enterprise physical infrastructure management platform's synchronous access to shared resources.

[0114] Figure 3 A structural diagram of a server provided for another embodiment of this application. This embodiment is based on a hardware perspective, such as... Figure 3 As shown, the server includes:

[0115] Memory 20 is used to store computer programs;

[0116] Processor 21 is configured to implement the steps of the shared resource access method as described in the above embodiments when executing a computer program.

[0117] The server provided in this embodiment may include, but is not limited to, smartphones, tablets, laptops, or desktop computers.

[0118] The processor 21 may include one or more processing cores, such as a quad-core processor or an octa-core processor. The processor 21 may be implemented using at least one of the following hardware forms: Digital Signal Processor (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 21 may also include a main processor and a coprocessor. The main processor, also known as the Central Processing Unit (CPU), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 21 may integrate a Graphics Processing Unit (GPU), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, the processor 21 may also include an Artificial Intelligence (AI) processor, which is used to handle computational operations related to machine learning.

[0119] The memory 20 may include one or more computer-readable storage media, which may be non-transitory. The memory 20 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In this embodiment, the memory 20 is used to store at least the following computer program 201, which, after being loaded and executed by the processor 21, is capable of implementing the relevant steps of the shared resource access method disclosed in any of the foregoing embodiments. In addition, the resources stored in the memory 20 may also include an operating system 202 and data 203, and the storage method may be temporary or permanent storage. The operating system 202 may include Windows, Unix, Linux, etc. The data 203 may include, but is not limited to, the data involved in the shared resource access method mentioned above.

[0120] In some embodiments, the server may further include a display screen 22, an input / output interface 23, a communication interface 24, a power supply 25, and a communication bus 26.

[0121] Those skilled in the art will understand that Figure 3 The structure shown does not constitute a limitation on the server and may include more or fewer components than illustrated.

[0122] The server provided in this application embodiment includes a memory and a processor. When the processor executes a program stored in the memory, it can implement the following method: a method for accessing shared resources, with the same effect as above.

[0123] Finally, this application also provides an embodiment corresponding to a computer-readable storage medium. The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps described in the above method embodiments.

[0124] It is understood that if the methods in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and executes all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0125] The computer-readable storage medium provided in this application includes the aforementioned method for accessing shared resources, with the same effect.

[0126] To enable those skilled in the art to better understand the technical solution of this application, the following description is provided in conjunction with the appendix. Figure 4 This application will now provide a more detailed description of the above. Figure 4 This application provides a shared resource access system. The system includes a lease server 1, a lease client 2, a priority queue processor 3, and a lease processor 4.

[0127] Specifically, lease server 1 is responsible for controlling synchronous access to a certain type of resource, and the resource information is described through a resource list. When lease server 1 receives a lease request from lease client 2, it queries its own resource list and processes it according to the current resource status: if the resource status is idle, it obtains a new lease from lease processor 4 and updates the resource record; if the resource status is occupied, it processes it according to the information of lease client 2. If the applicant is the current occupant, it directly returns permission; if the applicant is not the current occupant, it determines whether to further call priority queue processor 3 for processing based on the blocking information of this request. If it is a blocking request, priority queue processor 3 needs to be called to add the client to the resource's priority queue; otherwise, it directly returns the information that the resource is already occupied. When lease server 1 receives a return request from lease client 2, it first checks the current lease information and status. If it determines that the request operation is from the current resource occupant, it allows it, removes the current lease, and calls priority queue processor 3 to obtain the lease client 2 waiting for the resource; otherwise, it rejects it.

[0128] The lease server 1 also runs a lease maintenance thread, responsible for periodically maintaining the lease information of the resource list and the priority queue of occupied resources. For each resource currently in an occupied state, the lease processor 4 is invoked to maintain lease information: expired leases are renewed, and the number of renewals is recorded; for expired leases that cannot be extended, the occupyer's occupation of the resource is revoked, and an interruption request is sent to the occupyer. If there are other resource applicants in the current priority queue, the lease server 1 will allocate the resource to the highest-priority lease client 2 in the priority queue after detecting that the occupyer has completely exited. For each occupied resource, the priority queue processor 3 is invoked to maintain the priority queue of the resource: the priority queue is scanned, and the priority of lease client 2 whose waiting time exceeds the threshold is increased; for lease client 2 that has exceeded the set waiting time, it is removed from the priority queue, and then the corresponding lease client is woken up.

[0129] Lease client 2 is responsible for requesting access permissions to shared resources from lease server 1 on behalf of various operations of the enterprise physical infrastructure management platform. Each time a resource is requested, a new lease client 2 needs to be created. Lease client 2 needs to pass a reference to lease server 1 during initialization, and it has unique identification information indicating a specific access by a particular operation. This identification information needs to be submitted to lease server 1 when requesting shared resources, so that lease server 1 can construct lease information or priority queue information for the shared resources. In addition to the identification information, lease client 2 also needs to store operation type information. This type information is used by lease client 2 to determine the order of the current request in the priority queue when requesting resources and submitting it to lease server 1.

[0130] Lease client 2 supports lease application and return operations. When an operation needs to access a shared resource, it first constructs a Lease client 2 instance, fills in the necessary client information, and then calls the application operation of Lease client 2. Lease client 2 then sends a lease application to lease server 1. If the lease is successfully obtained, the operation is allowed to access the shared resource and continue to execute subsequent instructions. If the lease application is rejected, the operation behaves differently depending on the application method type of Lease client 2 called by the operation. For blocking applications, regardless of whether there is a limited waiting time, this application will be added to the priority queue of lease server 1, and the operation will be blocked. For non-blocking applications, the operation immediately receives the rejection information. At this time, the operation can choose to directly return the resource being occupied information to the enterprise physical infrastructure management platform and interrupt the operation or execute other instructions. After the shared resource access is completed, the operation needs to return the lease through Lease client 2 and wait for lease server 1 to remove the lease information of Lease client 2. Failure to return the lease will result in the resource being occupied for a long time and affect subsequent operations.

[0131] When accessing shared resources, such as servers, the enterprise physical infrastructure management platform needs to first create a lease client 2 to apply for access permissions to the resources before actually operating the server. Only after obtaining access permissions can the operation be actually performed. Furthermore, the lease return method of lease client 2 should be called in a timely manner to return the lease after the access ends or when the operation is abnormally terminated.

[0132] To ensure scalability, a priority queue processor 3 is designed for the lease-based shared resource access scheme. Users of this scheme can customize the priority queue processor 3 to suit their specific application scenarios, as long as it updates the priority queue of lease server 1 based on the incoming client operation type and is maintained by the maintenance thread of lease server 1. The priority queue processor 3 is created during the initialization of lease server 1 and is used by lease server 1 when the resource is already occupied, and the lease client 2 is blocking the request and the maintenance thread of lease server 1 is maintaining the priority queue of the resource.

[0133] Lease server 1 controls access to a certain type of shared resource. The operation types for accessing this type of resource may differ. The default priority queue processor 3 uses a built-in list to indicate the order of different operation types. If there is only one operation type, it appears externally that the lease client 2 that requested the resource first acquires access rights first. Starvation is handled by the lease maintenance thread of lease server 1 while maintaining the resource priority queue: a waiting time threshold is set, and operations exceeding a certain time are prioritized one level higher. Priority queue processor 3 scans the resource priority queue and adjusts the order of lease clients 2 in the queue. For blocking requests with limited waiting time, lease clients 2 should be promptly removed from the priority queue and woken up after the waiting time is reached.

[0134] For scalability, a lease processor 4 is designed for the entire lease-based shared resource access system. Users can customize the lease processor 4 to suit their application scenarios, as long as it can operate based on the resource's lease information and the lease client 2 information. The lease processor 4 is created when the lease server 1 is initialized and is accessed by the lease server 1 when creating new leases and when the lease server 1's maintenance thread maintains leases.

[0135] The default lease processor 4 allows specifying the lease duration, number of renewals, and automatic renewal upon expiration (users can also renew the lease a certain time before its expiration). When lease client 2 requests a shared resource that is not yet occupied, lease server 1 calls lease processor 4 to create a new lease for the shared resource based on lease client 2, the current time, and other information, and records it in lease server 1's resource list. Lease server 1's maintenance thread also periodically scans the lease information of occupied resources, automatically extends expired leases, and records the number of extensions. When the number of extensions exceeds a set limit, the resource occupied by lease client 2 needs to be reclaimed, and an interruption message is sent. After detecting that the lease client 2 has exited (in the scenario where the lease client 2 is implemented using a thread pool, sending an interrupt message will cause the corresponding lease client 2 thread to receive an interruption exception message, and the thread pool will remove the abnormal thread. The maintenance thread can determine whether the lease client 2 has exited by checking whether the corresponding thread information still exists in the thread pool), if there are other resource applicants in the priority queue, the resource will be allocated to the lease client 2 with the highest priority in the priority queue.

[0136] Therefore, in this system, the lease server queries the built-in resource list to determine the lease information of the requested resource and calls the lease processor to process the lease. The lease server also runs a lease maintenance thread responsible for maintaining the lease information on the resource list. The lease processor determines the lease processing plan based on the lease client information and the current resource lease information. When multiple lease clients request the same resource, or when the lease maintenance thread updates the resource list, the lease server calls the priority queue processor to queue the multiple lease clients. This system embodiment improves the reliability of synchronous access to shared resources by the enterprise physical infrastructure management platform, preventing abnormal resource status caused by multiple operations simultaneously modifying the same resource. By setting priority queues for multiple blocked operations and gradually increasing the priority of long-waiting tasks, orderly access to resources is achieved, ensuring that high-priority operations access resources first while avoiding starvation problems.

[0137] The foregoing has provided a detailed description of a method, apparatus, server, and medium for accessing shared resources provided in this application. The various embodiments in the specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section. It should be noted that those skilled in the art can make several improvements and modifications to this application without departing from the principles of this application, and these improvements and modifications also fall within the protection scope of the claims of this application.

[0138] It should also be noted that, in this specification, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

Claims

1. A method for accessing shared resources, characterized in that, include: The system retrieves the current operation of the enterprise physical infrastructure management platform and the lease application for the currently accessed resource; the lease application includes resource user information, lease start time, lease end time, and number of extensions. The information of the current resource is queried according to the lease application; wherein, the information of the current resource includes at least the current resource's occupancy status, the current resource's lease, and the priority queue for accessing the current resource; If the current resource is occupied and the current operation meets the preset requirements, the current operation is added to the priority queue. Obtain the waiting time corresponding to each operation in the priority queue; The operation whose waiting time exceeds the waiting threshold is obtained, the operation whose waiting time exceeds the waiting threshold is promoted in the priority queue, and the updated priority queue is obtained; When the current resource is not occupied, each operation accesses the current resource according to the updated priority queue control. After the operation ends and the current resource is accessed, the method further includes: Receive a request to return the current resource; The second operation to acquire the currently occupied resource; Determine whether the second operation is the currently described operation; If not, then the lease application can be removed; operations in the priority queue are processed sequentially according to their order in the priority queue. The method further includes: Starting from the time the current operation accesses the current resource, obtain the duration of the current operation accessing the current resource; If the duration of the current operation accessing the current resource exceeds the lease duration in the lease application and the lease is renewed, record the number of renewals; If the duration of the current operation's access to the current resource exceeds the lease duration in the lease application and the lease is not renewed, the current operation's occupation of the current resource is reclaimed, and an interruption request is sent to the current operation; it is determined whether there is an operation in the priority queue. If there is, if the current operation completely exits its occupation of the current resource, the current resource is allocated to the operation with the highest priority in the priority queue. The step of querying the current resource information based on the lease application includes: Obtain a resource list; wherein the resource list includes at least the ID corresponding to each resource, the occupancy status of each resource, the lease of each resource, and the priority queue for accessing each resource; Based on the lease application, retrieve information about the current resource from the resource list; The method further includes: Lock the resource list.

2. The method for accessing shared resources according to claim 1, characterized in that, Before adding the current operation to the priority queue, the method further includes: If the current resource is in an occupied state, obtain the first operation of occupying the current resource; Determine whether the first operation is the current operation; If so, then control the current operation to continue accessing the current resource; If not, determine whether the current operation meets the preset requirements. If the current operation meets the preset requirements, proceed to the step of adding the current operation to the priority queue.

3. The method for accessing shared resources according to claim 1, characterized in that, When the current resource is in an unoccupied state and the current operation meets the preset requirements, the method further includes: Determine whether the operation to access the current resource exists in the priority queue; If so, proceed to the step of adding the current operation to the priority queue; If not, then control the current operation to access the current resource.

4. A device for accessing shared resources, characterized in that, include: The first acquisition module is used to acquire the current operation of the enterprise physical infrastructure management platform for the lease application of the current resource to be accessed; the lease application includes resource user information, lease start time, lease end time, and number of extensions. The query module is used to query information about the current resource based on the lease application; wherein, the information about the current resource includes at least the current resource's occupancy status, the current resource's lease, and the priority queue for accessing the current resource; The addition module is used to add the current operation to the priority queue if the current resource is occupied and the current operation meets the preset requirements. The second acquisition module is used to acquire the waiting time corresponding to each operation in the priority queue; The third acquisition module is used to acquire the operations whose waiting time exceeds the waiting threshold, promote the order of the operations whose waiting time exceeds the waiting threshold in the priority queue, and acquire the updated priority queue. The control module is used to control each operation to access the current resource according to the updated priority queue when the current resource is in an unoccupied state. After the operation ends and access to the current resource is completed, the following is also included: Receive a request to return the current resource; The second operation to acquire the currently occupied resource; Determine whether the second operation is the currently described operation; If not, then the lease application can be removed; operations in the priority queue are processed sequentially according to their order in the priority queue. Also includes: Starting from the time the current operation accesses the current resource, obtain the duration of the current operation accessing the current resource; If the duration of the current operation accessing the current resource exceeds the lease duration in the lease application and the lease is renewed, record the number of renewals; If the duration of the current operation's access to the current resource exceeds the lease duration in the lease application and the lease is not renewed, the current operation's occupation of the current resource is reclaimed, and an interruption request is sent to the current operation; it is determined whether there is an operation in the priority queue. If there is, if the current operation completely exits its occupation of the current resource, the current resource is allocated to the operation with the highest priority in the priority queue. The query module specifically includes: Obtain a resource list; wherein the resource list includes at least the ID corresponding to each resource, the occupancy status of each resource, the lease of each resource, and the priority queue for accessing each resource; Based on the lease application, retrieve information about the current resource from the resource list; Also includes: Lock the resource list.

5. A server, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the method for accessing shared resources as described in any one of claims 1 to 3 when executing the computer program.

6. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the method for accessing shared resources as described in any one of claims 1 to 3.