Distributed lock processing method, device and system, storage medium and program product

By introducing a shared memory bus protocol into a distributed system, the client process and the lock resource management object perform read and write operations on the lock-marked area through the shared memory module, solving the problems of high latency and poor performance of distributed locks, achieving more efficient lock application and release, and improving system performance and stability.

CN120723490APending Publication Date: 2025-09-30HANGZHOU ALICLOUD FEITIAN INFORMATION TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202410371758.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-03-28
Publication Date
2025-09-30

AI Technical Summary

Technical Problem

Existing distributed locks have problems with long latency and poor performance during application, especially when there is network congestion or packet loss, which can easily lead to long-tail requests and affect system performance.

Method used

By introducing the shared memory bus protocol, servers in the distributed system are interconnected through the shared memory module. Client processes and lock resource management objects perform read and write operations through the lock mark area in the shared memory module, realizing the application and release of distributed locks, avoiding Ethernet interaction, and leveraging the advantages of bus transmission to improve efficiency and reduce latency.

Benefits of technology

It improves the efficiency of distributed lock application, reduces latency, improves the performance of distributed systems that rely on distributed locks, reduces system performance jitter and communication protocol overhead, and avoids problems caused by network packet loss.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120723490A_ABST
    Figure CN120723490A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a distributed lock processing method, device and system, a storage medium and a program product. In the embodiment of the invention, in the application and release process of introducing a bus protocol capable of providing a shared memory and the shared memory provided by the bus protocol into a distributed lock, a plurality of servers bearing client processes in a distributed system are interconnected with a shared memory module through an interconnection bus corresponding to the bus protocol capable of providing the shared memory; a lock mark area corresponding to each client process is maintained in a shared memory module, the client processes and a lock resource management object perform read-write operation on the lock mark areas in the shared memory module to realize application and release of a distributed lock, and the whole application process of the distributed lock does not interact through the Ethernet any more. Compared with the prior art, interaction is carried out through the interconnection bus supporting the shared memory, and by means of the advantages of bus transmission, the application efficiency of the distributed lock can be improved, time delay can be reduced, and the performance of a distributed system depending on the distributed lock can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of cloud computing technology, and in particular to a distributed lock processing method, device, system, storage medium, and program product. Background Art

[0002] With the rapid expansion of application scale, single-machine deployment can no longer meet the increasingly diverse application needs. Multi-machine distributed cluster deployment has become the mainstream architecture. Similar to traditional single-machine deployment, distributed architecture also faces the problem of concurrency control when different processes on multiple machines access the same shared resources.

[0003] Distributed locks are a mainstream solution for concurrency control when different processes on multiple machines access the same shared resource. They are widely used in distributed systems such as databases, Redis (Remote Dictionary Server), and Zookeeper. Distributed locks ensure that only the locked process can access the shared resource at a time, preventing data corruption caused by simultaneous access by different processes.

[0004] However, there are currently problems in the application of distributed locks, such as long latency and poor performance, so there is an urgent need to provide a new distributed lock implementation solution. Summary of the Invention

[0005] Various aspects of the present application provide a distributed lock processing method, device, system, storage medium, and program product to improve the efficiency of distributed lock application, reduce latency, and improve the performance of distributed systems that rely on distributed locks.

[0006] An embodiment of the present application provides a distributed lock processing method, which is applied to any client process on any server in a distributed system, wherein multiple servers in the distributed system are interconnected to a shared memory module via a target interconnection bus, and the shared memory module maintains lock mark areas corresponding to multiple client processes on the multiple servers that need to share a target resource object. The method includes: performing a write operation on the lock mark area corresponding to any client process in the shared memory module through the target interconnection bus to apply for a target lock from a lock resource management object; wherein the lock resource management object is responsible for allocating the target lock and rewriting the lock mark area corresponding to the client process allocated to the target lock; performing a read operation on the lock mark area corresponding to any client process in the shared memory module through the target interconnection bus to query whether the target lock is applied for; if the target lock is applied for, accessing the target resource object, and the target lock corresponds to the target resource object.

[0007] Optionally, a write operation is performed on the lock mark area corresponding to the any client process in the shared memory module through the target interconnect bus to apply for a target lock from the lock resource management object, including: writing a first value into the lock mark area corresponding to the any client process in the shared memory module through the target interconnect bus to apply for a target lock from the lock resource management object; accordingly, a read operation is performed on the lock mark area corresponding to the any client process in the shared memory module through the target interconnect bus to query whether the target lock is applied for, including: performing a read operation on the lock mark area corresponding to the any client process in the shared memory module through the target interconnect bus to determine whether a third value exists in the lock mark area; if the third value exists, it is determined that the target lock is applied for; if the third value does not exist, it is determined that the target lock is not applied for.

[0008] Optionally, the lock mark area corresponding to any client process includes: an application mark bit and a status mark bit; wherein, writing a first value into the lock mark area corresponding to any client process in the shared memory module through the target interconnection bus to apply for a target lock from the lock resource management object includes: setting the application mark position corresponding to any client process in the shared memory module to the first value through the target interconnection bus to apply for a target lock from the lock resource management object; wherein, performing a read operation on the lock mark area corresponding to any client process in the shared memory module through the target interconnection bus to determine whether a third value exists in the lock mark area, includes: reading the status mark bit corresponding to any client process in the shared memory module through the target interconnection bus to determine whether the status mark bit is the third value.

[0009] Optionally, before the application mark position corresponding to any one of the client processes in the shared memory module is set to the first value through the target interconnection bus, the method further includes: reading the status mark bit corresponding to any one of the client processes in the shared memory module through the target interconnection bus to determine whether the status mark bit is the third value; if the status mark bit is the fourth value, executing the operation of setting the application mark position corresponding to any one of the client processes in the shared memory module to the first value through the target interconnection bus; if the status mark bit is the third value, continuously reading the status mark bit through the target interconnection bus until the status mark bit is set to the fourth value.

[0010] Optionally, the lock mark area corresponding to any client process also includes: a release mark bit; when the target lock is applied for, the method further includes: setting the release mark position corresponding to any client process in the shared memory module to a fifth value through the target interconnection bus to release the target lock; wherein, when the target lock is released, the application mark bit corresponding to any client process is set to a second value.

[0011] Optionally, in the process of releasing the target lock, the method further includes: setting the application mark position corresponding to any client process in the shared memory module to the second value through the target interconnection bus to release the target lock.

[0012] Optionally, it also includes: sending an application for sharing the target lock to the lock resource management object, so that the lock resource management object creates a lock mark area corresponding to any client process in the shared memory module and returns the location information of the lock mark area; receiving the location information of the lock mark area returned by the lock resource management object, so as to perform read and write operations on the lock mark area according to the location information of the lock mark area.

[0013] An embodiment of the present application also provides a distributed lock processing method, which is applied to a lock resource management object in a distributed system, wherein multiple servers in the distributed system are interconnected through a target interconnection bus to share a memory module, and the shared memory module maintains lock mark areas corresponding to multiple client processes on the multiple servers that need to share a target resource object. The method includes: performing a read operation on the lock mark areas corresponding to the multiple client processes in the shared memory module to query whether there is a client process applying for a target lock, and the target lock corresponds to the target resource object; if there is a client process applying for the target lock, determining the target client process from the client processes applying for the target lock; and rewriting the lock mark area corresponding to the target client process in the shared memory module to assign the target lock to the target client process.

[0014] Optionally, a read operation is performed on the lock mark areas corresponding to the multiple client processes in the shared memory module to query whether there is a client process that applies for the target lock, including: a read operation is performed on the lock mark areas corresponding to the multiple client processes in the shared memory module to determine whether there is a lock mark area containing a first value; if there is a lock mark area containing the first value, it is determined that there is a client process that applies for the target lock; if there is no lock mark area containing the first value, it is determined that there is no client process that applies for the target lock; accordingly, the lock mark area corresponding to the target client process in the shared memory module is rewritten to assign the target lock to the target client process, including: writing a third value into the lock mark area corresponding to the target client process in the shared memory module to assign the target lock to the target client process.

[0015] Optionally, the lock mark area includes: an application mark bit and a status mark bit; wherein, a read operation is performed on the lock mark area corresponding to the multiple client processes in the shared memory module to determine whether there is a lock mark area containing a first value, including: reading the application mark bits corresponding to the multiple client processes in the shared memory module to determine whether there is an application mark bit with the first value; wherein, a third value is written into the lock mark area corresponding to the target client process in the shared memory module to assign the target lock to the target client process, including: setting the status mark position corresponding to the target client process in the shared memory module to the third value to assign the target lock to the target client process.

[0016] Optionally, the lock mark area also includes: a release mark bit; the method also includes: reading the release mark bit corresponding to the target client process in the shared memory module, and when the release mark bit is a fifth value, setting the status mark position corresponding to the target client process to a fourth value to reclaim the target lock; wherein, the release mark bit is set to the fifth value when the target client process releases the target lock.

[0017] Optionally, during the process of reclaiming the target lock, the method further includes: setting the application mark position corresponding to the target client process to a second value, so that the target client process can apply for the target lock again.

[0018] Optionally, determining the target client process from the client processes that apply for the target lock includes: randomly selecting a client process from the client processes that apply for the target lock as the target client process; or selecting the target client process based on at least one of the waiting time for the lock, the number of lock applications, and the priority of the client process that applies for the target lock.

[0019] An embodiment of the present application also provides a distributed system, comprising: multiple servers, a lock resource management object, and a shared memory module interconnected with the multiple servers through a target interconnection bus; multiple client processes that need to share a target resource object are running on the multiple servers, and the shared memory module maintains lock mark areas corresponding to each of the multiple client processes; any client process is used to perform read and write operations on the lock mark area corresponding to it in the shared memory module through the target interconnection bus to apply for a target lock from the lock resource management object, and access the target resource object if the target lock is applied for; the lock resource management object is used to perform read operations on the lock mark areas corresponding to the multiple client processes in the shared memory module to allocate the target lock, and rewrite the lock mark area corresponding to the client process allocated to the target lock.

[0020] Optionally, the lock mark area corresponding to any client process includes: an application mark bit and a status mark bit; any client process is specifically used to: set the application mark bit corresponding to it in the shared memory module to the first value through the target interconnection bus to apply for the target lock, and read the status mark bit corresponding to it, and determine that the target lock is applied for when the status mark bit is a third value; the resource management object is specifically used to: read the application mark bits corresponding to the multiple client processes in the shared memory module to determine whether there is a client process that applies for the target lock, and if so, determine the target client process from the client processes that apply for the target lock, and set the status mark bit corresponding to the target client process to the third value to allocate the target lock to the client process.

[0021] Optionally, the lock mark area corresponding to any client process also includes: a release mark bit; any client process is also used to: when implemented as the target client process, set the release mark position corresponding to it in the shared memory module to the fifth value through the target interconnection bus to release the target lock; the lock resource management object is also used to: read the release mark bit corresponding to the target client process in the shared memory module, and when the release mark bit is the fifth value, set the status mark position corresponding to the target client process to the fourth value to reclaim the target lock.

[0022] Optionally, the lock resource management object is a central service process running on a control device, and the control device is interconnected with the shared memory module through a target interconnection bus; or, the lock resource management object is a central service process running on the electronic device to which the shared memory module belongs; or, the lock resource management object is located on the electronic device to which the shared memory module belongs, and is a lock resource management module implemented based on hardware.

[0023] An embodiment of the present application also provides an electronic device, comprising: a shared memory module and a lock resource management module; the shared memory module is interconnected with multiple servers through a target interconnection bus, and maintains lock mark areas corresponding to multiple client processes on the multiple servers that need to share a target resource object; wherein the lock resource management module comprises: a read unit, a determination unit and a write unit implemented based on hardware; the read unit is responsible for performing a read operation on the lock mark areas corresponding to the multiple client processes in the shared memory module to query whether there is a client process that applies for a target lock, the target lock corresponding to the target resource object, and providing the query result to the determination unit; the determination unit determines the target client process from the client processes that apply for the target lock when the query result provided by the read unit indicates that there is a client process that applies for the target lock, and notifies the write unit; the write unit rewrites the lock mark area corresponding to the target client process in the shared memory module according to the notification of the determination unit to allocate the target lock to the target client process.

[0024] An embodiment of the present application also provides an electronic device, comprising: a memory and a processor; the memory is used to store a computer program, and the processor is coupled to the memory and is used to execute the computer program to implement the steps in the method provided in the embodiment of the present application.

[0025] An embodiment of the present application further provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the processor is enabled to implement the steps in the method provided in the embodiment of the present application.

[0026] An embodiment of the present application also provides a program product comprising a computer program / instructions, which, when executed by a processor, enables the processor to implement the steps of the method provided in the embodiment of the present application.

[0027] In this embodiment, a bus protocol that can provide shared memory and the shared memory it provides are introduced into the application and release process of distributed locks. Multiple servers that host client processes in a distributed system are interconnected with a shared memory module through an interconnection bus corresponding to the bus protocol that can provide shared memory. A lock mark area corresponding to each client process is maintained in the shared memory module. The client process and the lock resource management object implement the application and release of distributed locks by performing read and write operations on the lock mark area in the shared memory module. The entire distributed lock application process no longer interacts through Ethernet, but interacts through an interconnection bus that supports shared memory. With the advantages of bus transmission, the application efficiency of distributed locks can be improved, the delay can be reduced, and the performance of distributed systems that rely on distributed locks can be improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0029] Figure 1 A schematic diagram of the structure of a distributed system provided by an exemplary embodiment of the present application;

[0030] Figure 2a A schematic diagram of a deployment implementation method of a lock resource management object provided by an exemplary embodiment of the present application;

[0031] Figure 2b A schematic diagram of a deployment implementation method of a lock resource management object provided by another exemplary embodiment of the present application;

[0032] Figure 2c A schematic diagram of a deployment implementation method of a lock resource management object provided by another exemplary embodiment of the present application;

[0033] Figure 3 A schematic diagram of multiple lock flags corresponding to multiple client processes provided in an exemplary embodiment of the present application;

[0034] Figure 4a A schematic diagram of the process from applying for a lock resource to releasing the lock resource by any client process provided in an embodiment of the present application;

[0035] Figure 4b A schematic diagram of the process flow from receiving a lock resource application to releasing a lock resource provided by the central service process in an embodiment of the present application;

[0036] Figure 5a A schematic diagram of a state machine for three lock flag bits of a client process provided in an embodiment of the present application;

[0037] Figure 5bA schematic diagram of valid state transition conditions of a state machine for a lock flag provided in an embodiment of the present application;

[0038] Figure 6a 、 Figure 6b 、 Figure 6c 、 Figure 6d 、 Figure 6e 、 Figure 6f A flowchart of two client processes grabbing locks;

[0039] Figure 7a A schematic diagram of a distributed lock processing method provided in an embodiment of the present application;

[0040] Figure 7b A flow chart of another distributed lock processing method provided in an embodiment of the present application;

[0041] Figure 8a A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;

[0042] Figure 8b A schematic structural diagram of another electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0043] To make the purpose, technical solutions, and advantages of this application more clear, the technical solutions of this application will be clearly and completely described below in conjunction with the specific embodiments of this application and the corresponding drawings. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0044] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation portals for users to choose to authorize or refuse. In addition, the various models involved in this application (including but not limited to language models or large models) are in compliance with relevant laws and standards.

[0045] Distributed locks are a mainstream solution for concurrency control when different processes on multiple machines access the same shared resource. They are widely used in distributed systems such as databases, Redis, and Zookeeper. This article uses the distributed lock solutions used in the distributed systems Redis (referred to as Redis distributed locks) and Zookeeper (referred to as Zookeeper distributed locks) to illustrate the problems of traditional distributed locks in applications:

[0046] Redis distributed lock: Multiple concurrent threads that need to access the same shared resource are deployed on different servers. These concurrent threads apply for a lock from a Redis service deployed on another server via Ethernet. The Redis service assigns the lock to one of the threads, such as thread A, and sets a lock expiration time for thread A. The service returns the lock acquisition information and the lock expiration time to thread A, allowing thread A to access the shared resource based on the acquired lock. When the lock expiration time is reached, the lock is assigned to the next thread, and so on.

[0047] Zookeeper distributed lock: Zookeeper is a distributed coordination service, including client threads, client listeners and servers. The client threads and servers are interconnected through Ethernet. The server creates a parent node. The client thread that obtains the lock creates a temporary node under the parent node of the server through the network. One client thread is allowed to successfully create a temporary node at the same time. The temporary nodes are created in sequence and the numbers increase in sequence. Before the client thread that successfully creates a temporary node seizes the lock, it needs to obtain all the temporary nodes created under the parent node and determine whether the number of the temporary node it created is the smallest. If so, it acquires the lock. If it is not the smallest, it is in a waiting state, waiting for the notification sent by the previous temporary node when it is deleted. When it receives the notification, it determines that it is its turn to obtain the lock.

[0048] In the above-mentioned distributed lock application, concurrent threads or processes are interconnected with the server via Ethernet. The process of obtaining locks by threads or processes is cumbersome and time-consuming, resulting in poor system performance. In particular, when network congestion and packet loss occur, requests for obtaining locks are lost, which easily leads to long-tail requests. In this case, threads or processes cannot access shared resources due to long-term failure to seize locks, which in turn leads to large system performance jitter.

[0049] In response to the above technical problems, in an embodiment of the present application, a bus protocol that can provide shared memory and the shared memory it provides are introduced into the application and release process of distributed locks. Multiple servers that carry client processes in a distributed system are interconnected with the shared memory module through an interconnection bus corresponding to the bus protocol that can provide shared memory. A lock mark area corresponding to each client process is maintained in the shared memory module. The client process and the lock resource management object implement the application and release of distributed locks by performing read and write operations on the lock mark area in the shared memory module. The entire distributed lock application process no longer interacts through Ethernet, but interacts through an interconnection bus that supports shared memory. With the advantages of bus transmission, the application efficiency of distributed locks can be improved, the delay can be reduced, and the performance of distributed systems that rely on distributed locks can be improved.

[0050] Furthermore, bus protocols that can provide shared memory can provide read and write operations with memory semantics, do not need to be encapsulated into network message format, and can also reduce the overhead of communication protocols. In addition, based on bus protocols that can provide shared memory, packet loss can be avoided during end-to-end communication, which can avoid the long-tail request problem caused by network packet loss, and is conducive to further reducing system performance jitter and improving system performance stability.

[0051] The following describes in detail the technical solutions provided by various embodiments of the present application in conjunction with the accompanying drawings.

[0052] Figure 1 This is a schematic diagram of the structure of a distributed system provided in an embodiment of the present application. Figure 1 As shown, the distributed system 100 may include multiple servers (such as Figure 1 The server 101 and the server 102 are shown, a lock resource management object 103, and a shared memory module 105 interconnected with multiple servers through a target interconnect bus 104.

[0053] The target interconnect bus 104 refers to an information transmission line that connects various components using a target interconnect protocol. In this embodiment, the target interconnect protocol refers to a protocol that can provide a shared memory.

[0054] For example, in some embodiments, the target interconnection protocol may be a Compute Express Link (CXL) protocol. The CXL protocol is an interconnection protocol based on an extension of the high-speed serial computer expansion bus standard (Peripheral Component Interconnect Express, PCIE) protocol. The CXL protocol includes three sub-protocols: CXL.io, CXL.cache, and CXL.memo, and supports read and write operations of memory semantics. The CXL.io protocol is used for initialization, linking, device discovery and enumeration, and register access; the CXL.cache protocol allows the device to save cache cachelines locally; and the CXL.memo protocol allows the device to become a fully consistent memory device, which can be used as a system random access memory (RAM) and / or persistent memory.

[0055] Among them, any server can be a conventional server device, a cloud server or a virtual machine, and this embodiment does not limit it. When the number of servers is large, multiple servers can be connected through Figure 1 The switch 106 and the target interconnection bus 104 are interconnected with the shared memory module 105. The switch 106 and the target interconnection bus 104 follow the same target interconnection protocol.

[0056] Among them, multiple client processes that need to share target resource objects are running on multiple servers. Among them, the target resource objects can be shared resources such as database records, files, caches, etc. in a distributed system. Figure 1 As shown, a client process 101 a is running on the server 101 , and a client process 102 a is running on the server 102 .

[0057] The shared memory module 105 maintains lock mark areas corresponding to the multiple client processes. Figure 1 As shown, the shared memory module 105 can maintain a lock mark area 105 a corresponding to the client process 101 a and a lock mark area 105 b corresponding to the client process 102 a .

[0058] Among them, the lock resource management object 103 is an object used to manage the resources of the distributed lock in the distributed system. The lock resource management object 103 can be implemented as a hardware form or as a software module. Figure 1 In the illustrated embodiment, the deployment implementation method of the lock resource management object 103 is not limited.

[0059] In some exemplary embodiments, the lock resource management object 103 may be implemented in software, specifically as a central service process, such as Figure 2aAs shown, the distributed system 100 further includes a control device 107. The control device 107 can be interconnected with the shared memory module 105 via the target interconnection bus 104. Optionally, the lock resource management object 103 can be a central service process running on the control device 107. The control device 107 can be implemented as follows Figure 2a The server shown can also be implemented as a device on the terminal side, which is not limited in this embodiment.

[0060] In other exemplary embodiments, the lock resource management object 103 is a central service process running on the electronic device 108 to which the shared memory module 105 belongs, such as Figure 2b That is, the lock resource management object 103 and the shared memory module 105 run on the electronic device 108 at the same time.

[0061] In some other exemplary embodiments, the lock resource management object 103 is located on the electronic device 108 to which the shared memory module 105 belongs, and is a lock resource management module implemented based on hardware, such as Figure 2c The hardware may be implemented using, but is not limited to, an application-specific integrated circuit (ASIC) chip, a field-programmable gate array (FPGA), a programmable array logic (PAL), a general array logic (GAL), or a complex programmable logic device (CPLD).

[0062] Figure 2a and Figure 2b and Figure 2c The difference lies in that the way the lock resource management object 103 accesses the shared memory module 105 is different. Figure 2a In the example, the lock resource management object 103 can be interconnected with the shared memory module 105 via the target interconnect bus 104. Figure 2b and Figure 2c In the embodiment, the lock resource management object 103 and the shared memory module 105 are located on the same device, and the shared memory module 105 can be directly accessed. Other operation processes are the same or similar, so in the following embodiment, Figure 2a The system architecture shown is described in detail.

[0063] The lock mark area corresponding to any client process is used to record the usage information of the lock resource corresponding to the client process. The lock mark areas of multiple client processes are independent of each other.

[0064] The lock flag area corresponding to any client process can have one or more lock status flags. Each lock status flag area can support write, read, and delete operations. Based on write and delete operations, the lock flags can be repeatedly overwritten. Client processes and the lock resource management object 103 can implement distributed lock application and management by overwriting the lock status flag area. This is explained below as an example.

[0065] Any client process performs read and write operations on the corresponding lock-marked area in the shared memory module 105 via the target interconnect bus 104 to request a target lock from the lock resource management object 103. The target lock corresponds to the target resource object. The target lock is used to lock the target resource to reduce the risk of data contention and data inconsistency. Once the target lock is obtained, the client can access the target resource object.

[0066] For example, client process 101a can perform read and write operations in the corresponding lock mark area 105a to apply for a target lock from lock resource management object 103. Client process 102a can perform read and write operations in the corresponding lock mark area 105b to apply for a target lock from lock resource management object 103.

[0067] Among them, the lock resource management object 103 is used to read the lock mark area corresponding to multiple client processes in the shared memory module 105 to query whether there is a client process that has applied for the target lock. If there is a client process that has applied for the target lock, the lock resource management object 103 can determine the target client process from the client processes that have applied for the target lock and rewrite the lock mark area corresponding to the target client process in the shared memory module 105 to allocate the target lock to the target client process. For example, the lock resource management object 103 can read the lock mark area 105a to allocate the target lock to the client process 101a. After the target lock is allocated, the lock resource management object 103 can rewrite the lock mark area 105a to indicate that the target lock allocation is complete.

[0068] In some scenarios, there may be multiple client processes applying for lock resources simultaneously. In this case, optionally, when determining the target client process from the client processes applying for the target lock, the lock resource management object 103 can randomly select a client process from the client processes applying for the target lock as the target client process.

[0069] Optionally, the lock resource management object 103 may select a target client process from the client processes applying for the target lock based on at least one of the following information: the length of time the client process applying for the target lock waited for the lock, the number of lock applications, and a priority. For example, the lock resource management object 103 may sort the client processes applying for the target lock in descending order based on the length of time the client process applying for the target lock waited for the lock, and select the target client processes in order starting with the client process with the longest wait time. For another example, the lock resource management object 103 may sort the client processes applying for the target lock in descending order based on the number of lock applications the client process applying for the target lock has made, and select the target client processes in order starting with the client process with the fewest lock applications. The priority may be predefined or determined based on the type of client process, which is not limited in this embodiment.

[0070] Optionally, the lock resource management object 103 may also use the RR scheduling algorithm (Round-Robin Scheduling Algorithm) to select a target client process from the client processes that apply for the target lock. The core idea of ​​the RR scheduling algorithm is to maintain a ready queue and set a timer. Whenever a target lock is allocated to a client process, the timer starts counting. Each client process is assigned a fixed time slice, during which the client process can monopolize the target lock. If the client process fails to release the target lock within the time slice, the client process can be suspended and placed at the end of the ready queue, waiting for its next turn to obtain the lock resource.

[0071] Based on this implementation, the lock resource management object 103 can provide differentiated lock resource allocation services to different client processes according to the actual conditions of the client processes, thereby balancing the demands of different client processes for lock resources.

[0072] Different values ​​written into the lock flag area can represent different usage scenarios of the lock resource. Within the lock flag area, the value written into any lock flag bit can be a numeric value or a string. Numeric values ​​can be binary bit values ​​or decimal values, which are not limited in this embodiment. For example, the bit value written into any lock flag bit can be one or more. One or more bit values ​​can be defined with different semantics to distinguish different usage scenarios of the lock resource.

[0073] The following is an illustrative description of different usage scenarios of lock resources.

[0074] In some exemplary Example A In the process, the client process needs to apply for the target lock from the lock resource management object 103.

[0075] When any client process requests a target lock from the lock resource management object 103, it can write a first value to the lock tag area corresponding to the client process in the shared memory module 105 via the target interconnect bus 104 to request the target lock from the lock resource management object. The first value can be any numerical value or string, and its semantics are predefined as requesting the target lock.

[0076] In this embodiment, the lock resource management object 103 can perform a read operation on the lock mark area corresponding to multiple client processes in the shared memory module 105 to determine whether there is a lock mark area containing the first value. Optionally, the lock resource management object 103 can periodically perform a read operation on the lock mark area corresponding to multiple client processes in a polling manner. If there is a lock mark area containing the first value, the lock resource management object 103 can determine that there is a client process that has applied for the target lock. For example, if the lock mark area corresponding to a client process contains the first value, then the client process is determined to be the client process that has applied for the target lock. Conversely, if there is no lock mark area containing the first value, the lock resource management object 103 can determine that there is no client process that has applied for the target lock.

[0077] The client process requesting the target lock is described as the target client process. The lock resource management object 103 can write a third value into the lock tag area corresponding to the target client process in the shared memory module 105 to assign the target lock to the target client process. The third value can be any numerical value or string, and its semantics are predefined as: the target lock has been obtained.

[0078] Accordingly, when any client process (e.g., a target client process) queries whether it has applied for the target lock, it can read the lock tag area corresponding to the client process in the shared memory module 105 via the target interconnect bus 104 to determine whether the lock tag area contains the third value. If the third value exists, the client process can determine that it has applied for the target lock. If the third value does not exist, the client process can determine that it has not applied for the target lock.

[0079] Optionally, the lock mark area of ​​any client process may include one or more lock mark bits, and any lock mark bit supports write operations, read operations, and delete operations. Based on write and delete operations, repeated rewriting can be implemented in the lock mark bit. If the lock mark area includes multiple lock mark bits, the multiple lock mark bits can be used to record different types of information. For example, among the multiple lock mark bits, there may be at least one lock mark bit for recording the client process's operation information on the distributed lock, and there may also be at least one lock mark bit for recording the status information of the distributed lock. An exemplary description will be provided below.

[0080] In some optional embodiments, the lock mark area corresponding to any client process includes: an application mark bit and a status mark bit. Figure 3 As shown, the lock mark area of ​​each client process in server 1 to server N may include an application mark bit and a status mark bit. The application mark bits and status mark bits of multiple client processes are independent of each other.

[0081] For any client process, when the client process needs to apply for a target lock from the lock resource management object 103, the client process can specifically set the corresponding application mark position in the shared memory module 105 to the first value through the target interconnection bus 104 to apply for the target lock. The application mark bit may have a default value, and the default value may be marked as a second value. The second value may be any numerical value or string, and the semantics of the second value is predefined as: no lock resource is applied for. For example, the first value may be 1, and the second value may be 0; or, the first value may be 0, and the second value may be 1. For another example, the first value may be 100, and the second value may be 001. This embodiment does not impose any restrictions on this. Any client process may perform a lock resource application operation by rewriting the default value of the application mark bit.

[0082] Accordingly, the lock resource management object 103 is specifically configured to read the application flag bits corresponding to multiple client processes in the shared memory module 105 to determine whether there is an application flag bit with a first value. If there is an application flag bit with a first value, the target client process is determined from the client processes that have applied for the target lock based on the client process corresponding to the application flag bit with the first value. The lock resource management object 103 may set the status flag bit corresponding to the target client process to a third value to allocate the target lock to the client process. The status flag bit may have a default value, which may be set to a fourth value. The fourth value may be any numeric value or string, and the semantics of the fourth value are predefined to indicate that the client process does not occupy the lock resource. The lock resource management object 103 may modify the allocation status of the lock resource by overwriting the default value of the status flag bit. The third value may be 1 and the fourth value may be 0; alternatively, the third value may be 0 and the fourth value may be 1. For example, in the default state, the value of the status flag bit is 0. After allocating the target lock to the client process, the lock resource management object 103 may change the status flag bit from 0 to 1 to indicate that the target lock has been allocated to the corresponding client process.

[0083] Optionally, any client process can read the status flag corresponding to it and determine that it has applied for the target lock when the status flag is a third value. For example, the client process can change its corresponding application flag from 0 to 1 to apply for the target lock from the lock resource management object 103. When the lock resource management object 103 finds that the value of the application flag is 1, it can allocate the target lock to the client process. After allocating the target lock, the lock resource management object 103 can change the status flag corresponding to the client from 0 to 1 to indicate that the target lock allocation is completed for the client process. When the client process finds a value of 1 in the status flag, it can be determined that the target lock has been successfully acquired.

[0084] In some optional embodiments, before any client process sets the application flag corresponding to any client process in the shared memory module 105 to the first value via the target interconnect bus 104, it may read the status flag corresponding to the any client process in the shared memory module 105 via the target interconnect bus 104 to determine whether the status flag is the third value. If the status flag is the third value, the client process may continue to read the status flag via the target interconnect bus 104 until the status flag is set to the fourth value. Alternatively, if the status flag is the fourth value, the client process may execute an operation to set the application flag corresponding to the client process in the shared memory module 105 to the first value via the target interconnect bus 104.

[0085] Based on this implementation, any client process can determine whether it currently occupies a lock resource by reading the value of its corresponding status flag before applying for a lock resource. If the status flag is the third value, it indicates that the client process currently occupies the lock resource and needs to wait until the currently occupied lock resource is released before applying for the lock resource. When the status flag is the fourth value, it indicates that the client process currently does not occupy the lock resource. In this case, the client process can apply for a lock resource from the lock resource management object 103 by modifying its corresponding application flag.

[0086] In some exemplary Example B In the process, the client process needs to apply to the lock resource management object 103 to release the target lock.

[0087] Optionally, the lock mark area corresponding to any client process further includes a release mark bit, wherein the release mark bit corresponding to any client process is used to record the release request of the client process for the lock resource.

[0088] Accordingly, if any client process is implemented as a target client process that has been allocated a target lock as described in the aforementioned embodiment, then any client process can set the corresponding release mark position in the shared memory module 105 to the fifth value via the target interconnect bus 104 to release the target lock. The fifth value can be any numerical value or string, and the semantics of the fifth value are predefined as: the client process applies to release the lock resource. The release mark bit can have a default value, which can be marked as a sixth value. The sixth value can be any numerical value or string, and the semantics of the sixth value are predefined as: the lock resource of the client process has been reclaimed. The client process can execute the lock resource release operation by rewriting the default value of the release mark bit. The fifth value can be 1 and the sixth value can be 0; or the fifth value can be 0 and the sixth value can be 1. After the client process completes its use of the target lock, it can change the release mark bit from 0 to 1 to request the lock resource management object 103 to reclaim the target lock.

[0089] Accordingly, the lock resource management object 103 is further configured to read the release flag corresponding to the target client process in the shared memory module 105 and, if the release flag is at the fifth value, set the status flag corresponding to the target client process to the fourth value to reclaim the target lock. For example, if the lock resource management object 103 finds a value of 1 in the release flag of a client process, the target lock allocated to the client process may be reclaimed and the status flag corresponding to the client process may be set to 0 to indicate that the target lock has been reclaimed.

[0090] Optionally, when any client process releases the target lock, the application flag corresponding to the client process is set to the second value. The operation of setting the application flag to the second value can be performed by the client process or by the lock resource management object 103. Each of these operations will be described below with examples.

[0091] In some optional embodiments, when releasing a target lock, any client process may set the request flag corresponding to the client process in the shared memory module 105 to the second value via the target interconnect bus 104 to release the target lock. That is, the client process may change its corresponding request flag from 1 to 0 to release the target lock.

[0092] In other optional embodiments, when reclaiming the target lock, the lock resource management object 103 may set the application flag corresponding to the target client process to the second value, allowing the target client process to apply for the target lock again. Specifically, the lock resource management object 103 may simultaneously set the status flag to the fourth value and the application flag to the second value when allocating the target lock to the target client process.

[0093] Furthermore, when any client process uses the lock resource again, it can apply for the target lock from the lock resource management object 103 by querying the status flag value and rewriting the application flag value. For details, please refer to the records of the aforementioned embodiment A and will not be described again.

[0094] The application flag bit, status flag bit, and release flag bit described in the above embodiments may be logically distinct lock flag areas. In some embodiments, the multiple flag bits may reside in the same physical location within the shared memory module 105. In this manner, the application flag bit, status flag bit, and release flag bit may be distinguished by setting values ​​corresponding to different semantics.

[0095] It is worth noting that, in some optional embodiments, the lock flag area of ​​any client process may include a lock flag bit that supports write, read, and delete operations. The lock flag bit can be repeatedly rewritten based on write and delete operations. The first value, third value, and fifth value can be written to the lock flag area by rewriting. For example, when a client process needs to use a lock resource, it can write a first value (e.g., first value = 1, or first value = 001) into the lock flag bit to request a target lock from the lock resource management object 103. When the lock resource management object 103 finds the first value in the lock flag bit, it can allocate the target lock to the client process. After allocating the target lock, the lock resource management object 103 can delete the first value in the lock flag bit and write a third value (e.g., third value = 2, or third value = 101) into the lock flag bit to indicate that the target lock has been allocated to the client process. When the client process finds the third value in the lock flag bit, it can determine that it has successfully acquired the target lock. After using the target lock, the client process can delete the third value in the lock flag bit and write a fifth value (e.g., fifth value = 3, or third value = 011) in the lock flag bit to indicate the release of the target lock. When the lock resource management object 103 finds the fifth value in the lock flag bit, the target lock allocated to the client process can be reclaimed.

[0096] In this implementation, the application, allocation, and release operations of lock resources can be implemented based on a lock flag bit in the shared memory, which reduces the management complexity of lock resources to a certain extent and helps reduce the memory space required for lock resource management.

[0097] In some exemplary embodiments, when any client process needs to access a target resource object, it may request a lock resource from the lock resource management object 103 based on shared memory. Alternatively, the client process may send a request to the lock resource management object 103 to share the target lock, so that the lock resource management object 103 can create a lock mark area corresponding to the client process in the shared memory module 105 and return the location information of the lock mark area. The client process can receive the location information of the lock mark area returned by the lock resource management object 103 and perform read and write operations on the lock mark area based on the location information of the lock mark area.

[0098] The following further illustrates the distributed lock processing system provided in the embodiments of the present application with reference to the figures.

[0099] Figure 4a It illustrates the execution flow from any client process applying for lock resources to releasing lock resources.

[0100] like Figure 4a As shown, when a client process receives a query request for a target resource object, it can query its own lock status and determine whether it currently holds the lock resource. To query the lock status, the client process can read the value of the status flag. If the value of the status flag is 0, the client process is determined to not currently hold the lock resource. If the value of the status flag is 1, the client process is determined to currently hold the lock resource. If it already holds the lock resource, it can wait for the lock resource to be released. If it does not hold the lock resource, it can initiate a lock grab request. When initiating a lock grab request, the client process can set the corresponding request flag to 1 and the release flag to 0. The client process can then query the lock status. To query the lock status, the client process can read the value of the status flag. If the value of the status flag is 1, the client process is determined to have acquired the lock resource. If the value of the status flag is 0, the client process is determined to have not yet acquired the lock resource. If the client process has currently acquired the lock resource, it can access the target resource object based on the acquired lock resource. After completing the access, the client process can initiate a lock release request. When initiating a lock release request, the client process may set the release flag to 1 and the request flag to 0.

[0101] Figure 4b It illustrates the execution flow of the central service process from receiving lock resource application to releasing lock resources.

[0102] like Figure 4bAs shown, after the lock mark area is reset, the central service process can use polling to query the application mark bits of multiple client processes. Among them, resetting the lock mark area can mean that multiple lock mark bits in the lock mark area are all in a cleared state. The central service process can determine whether there are application mark bits set to 1 among the application mark bits of multiple client processes. If there are multiple application mark bits set to 1, the central service process can select a successful person C from the client processes corresponding to the multiple application mark bits set to 1 according to the set scheduling algorithm, and mark C as having successfully grabbed the lock. When marking C as having successfully grabbed the lock, the central service process can set the status mark position corresponding to C to 1. Afterwards, the central service process can query whether the release mark bit of C is set to 1. If the release mark position of C is 1, it marks C as having successfully released the lock. When marking C as having successfully released the lock, the central service process can set the status mark position corresponding to C to 0. If the release mark position of C is 0, the central service process can continue to query the release mark bit of C until the release mark position of C is 1. As Figure 4b As shown, after marking C as releasing the lock successfully, the central service process can continue to query the application flags of multiple client processes in a polling manner, thereby allocating lock resources for newly initiated lock resource application requests.

[0103] Figure 5a The state machine of the three lock flags of the client process is shown. The three lock flags of any client process have four valid states: A, B, C, and D. E and F are illegal states. Figure 5a As shown, state A is the idle state. In this state, the value of the application flag is 0, the value of the release flag is X, and the value of the status flag is 0. State B is the state where the client process holds the lock. In this state, the client process can access the shared target resource object. Figure 5a As shown, in state B, the application flag is 0, the release flag is X, and the status flag is 1. State C is the state in which the client process applies to release the lock. In this state, the application flag is 0, the release flag is 1, and the status flag is 1. State D is the state in which the client process applies to grab the lock and waits to obtain the lock. In this state, the application flag is 1, the release flag is 0, and the status flag is 0. State E is an illegal state. In this state, the application flag is 1, the release flag is 1, and the status flag is 0. State F is an illegal state. In this state, the application flag is 1, the release flag is 1, and the status flag is 1.

[0104] Among them, the above four valid state transition conditions are as follows Figure 5bWhen the client process initiates a lock grabbing operation, the state machine jumps from state A to state D. When the client process enters the critical section to access the target resource object, the state machine jumps from state D to state B. When the client process completes the operation and applies to release the lock, the state machine jumps from state B to state C. When the central service process clears the completion status flag, the state machine jumps from state C to state A.

[0105] The following will be combined with the attached Figure 6a to Figure 6f , an example is given to illustrate the process of lock grabbing between any two client processes.

[0106] like Figure 6a As shown, when client process 1 and client process 2 simultaneously initiate lock grabbing requests to central service process 3, the application flag bit of client process 1 and the application flag bit of client process 2 are both 1. Central service process 3 can detect the lock grabbing requests of client process 1 and client process 2.

[0107] like Figure 6b As shown, after central service process 3 arbitrates multiple lock requests, it determines that client process 1 has acquired the lock. Central service process 3 sets the status flag of client process 1 to 1. Client process 1 knows it has acquired the lock based on the value of its corresponding status flag. At this point, client process 2, which has not yet acquired the lock, can continue to poll its own status flag.

[0108] like Figure 6c As shown, after client process 1 completes the shared resource access operation, it can initiate a lock release request. Client process 1 can set its corresponding release marker position to 1. When central service process 3 finds that the release marker position corresponding to client process 1 is 1, it can determine that the lock release request from client process 1 has been detected.

[0109] like Figure 6d As shown, the central service process 3 can clear the status flag of the client process 1 to 0 to complete the release of the lock.

[0110] like Figure 6e As shown, after the central service process 3 detects the lock grabbing request of the client process 2, the central service process 3 may set the status flag of the client process 2 to 1. The client process 2 knows that the lock is obtained through the value of its corresponding status flag.

[0111] like Figure 6f As shown, after client process 2 completes the shared resource access operation, it can initiate a lock release request. Client process 2 can set its corresponding release marker to 1. When central service process 3 finds that the release marker corresponding to client process 2 is 1, it can determine that the lock release request from client process 2 has been detected.

[0112] Based on the above implementation, multiple client processes can implement distributed locks through shared memory without relying on Ethernet.

[0113] Figure 7a A flow chart of a distributed lock processing method provided in an embodiment of the present application. The method is applied to any client process on any server in a distributed system, wherein multiple servers in the distributed system are interconnected via a target interconnect bus to share a memory module, wherein the shared memory module maintains lock mark areas corresponding to multiple client processes on the multiple servers that need to share a target resource object. Figure 7a As shown, the method includes:

[0114] Step 701a: Write the lock mark area corresponding to any client process in the shared memory module through the target interconnect bus to apply for a target lock from the lock resource management object; wherein the lock resource management object is responsible for allocating the target lock and rewriting the lock mark area corresponding to the client process allocated to the target lock.

[0115] Step 702a: Perform a read operation on the lock mark area corresponding to any client process in the shared memory module through the target interconnect bus to check whether the target lock is applied for.

[0116] Step 703a: When the target lock is obtained, the target resource object is accessed. The target lock corresponds to the target resource object.

[0117] In an optional embodiment, performing a write operation on a lock tag area corresponding to any client process in a shared memory module via a target interconnect bus to apply for a target lock from a lock resource management object includes: writing a first value into a lock tag area corresponding to any client process in a shared memory module via the target interconnect bus to apply for a target lock from the lock resource management object;

[0118] Correspondingly, a read operation is performed on the lock mark area corresponding to any client process in the shared memory module through the target interconnection bus to query whether the target lock is applied for, including: a read operation is performed on the lock mark area corresponding to any client process in the shared memory module through the target interconnection bus to determine whether there is a third value in the lock mark area; if the third value exists, it is determined that the target lock is applied for; if the third value does not exist, it is determined that the target lock is not applied for.

[0119] In an optional embodiment, the lock tag area corresponding to any client process includes: an application tag bit and a status tag bit. Based on this, a first value is written to the lock tag area corresponding to any client process in the shared memory module via the target interconnect bus to apply for a target lock from the lock resource management object, including: setting the application tag position corresponding to any client process in the shared memory module to the first value via the target interconnect bus to apply for a target lock from the lock resource management object. Correspondingly, a read operation is performed on the lock tag area corresponding to any client process in the shared memory module via the target interconnect bus to determine whether a third value exists in the lock tag area, including: reading the status tag corresponding to any client process in the shared memory module via the target interconnect bus to determine whether the status tag is the third value.

[0120] Furthermore, in an optional embodiment, before setting the application mark position corresponding to any client process in the shared memory module to the first value through the target interconnect bus, the method further includes:

[0121] Reading a status flag bit corresponding to any client process in the shared memory module through the target interconnect bus to determine whether the status flag bit is a third value;

[0122] When the status flag bit is at the fourth value, performing an operation of setting the application flag bit corresponding to any client process in the shared memory module to the first value through the target interconnect bus;

[0123] When the status flag bit is at the third value, the status flag bit is continuously read through the target interconnect bus until the status flag bit is set to a fourth value.

[0124] Further, optionally, the lock flag area corresponding to any client process further includes a release flag bit. Based on this, when the target lock is applied for, the method further includes: setting the release flag bit corresponding to any client process in the shared memory module to the fifth value via the target interconnect bus to release the target lock; wherein, when the target lock is released, the application flag bit corresponding to any client process is set to the second value.

[0125] Further optionally, in the process of releasing the target lock, the method further includes: setting the application mark position corresponding to any client process in the shared memory module to a second value via the target interconnection bus to release the target lock.

[0126] In an optional embodiment, the method further includes: sending a request for a shared target lock to the lock resource management object, so that the lock resource management object creates a lock mark area corresponding to any client process in the shared memory module and returns the location information of the lock mark area; receiving the location information of the lock mark area returned by the lock resource management object, so as to perform read and write operations on the lock mark area according to the location information of the lock mark area.

[0127] Figure 7b A flow chart of another distributed lock processing method provided by an embodiment of the present application. This method is applied to lock resource management objects in a distributed system. Multiple servers in the distributed system are interconnected through a target interconnect bus to share a memory module. The shared memory module maintains lock mark areas corresponding to multiple client processes on multiple servers that need to share the target resource object. Figure 7b As shown, the method includes:

[0128] Step 701b: perform a read operation on the lock mark area corresponding to multiple client processes in the shared memory module to query whether there is a client process that applies for a target lock, and the target lock corresponds to a target resource object.

[0129] Step 702b: If there is a client process that has applied for the target lock, determine the target client process from the client processes that have applied for the target lock.

[0130] Step 703b: rewrite the lock mark area corresponding to the target client process in the shared memory module to allocate the target lock to the target client process.

[0131] In an optional embodiment, a read operation is performed on lock tag areas corresponding to multiple client processes in a shared memory module to query whether there is a client process that has applied for a target lock, including: performing a read operation on lock tag areas corresponding to multiple client processes in the shared memory module to determine whether there is a lock tag area containing a first value; if there is a lock tag area containing the first value, determining that there is a client process that has applied for the target lock; if there is no lock tag area containing the first value, determining that there is no client process that has applied for the target lock. Accordingly, rewriting the lock tag area corresponding to the target client process in the shared memory module to assign the target lock to the target client process includes: writing a third value to the lock tag area corresponding to the target client process in the shared memory module to assign the target lock to the target client process.

[0132] In an optional embodiment, the lock mark area includes: an application mark bit and a status mark bit. Based on this, a read operation is performed on the lock mark area corresponding to multiple client processes in the shared memory module to determine whether there is a lock mark area containing a first value, including: reading the application mark bits corresponding to multiple client processes in the shared memory module to determine whether there is an application mark bit with the first value. Accordingly, a third value is written into the lock mark area corresponding to the target client process in the shared memory module to allocate the target lock to the target client process, including: setting the status mark position corresponding to the target client process in the shared memory module to the third value to allocate the target lock to the target client process.

[0133] In an optional embodiment, each lock tag area further includes a release tag bit. Based on this, the method further includes: reading the release tag bit corresponding to the target client process in the shared memory module, and when the release tag bit is at a fifth value, setting the status tag bit corresponding to the target client process to a fourth value to reclaim the target lock; wherein the release tag bit is set to the fifth value when the target client process releases the target lock.

[0134] Further optionally, during the process of reclaiming the target lock, the method further includes: setting the application mark position corresponding to the target client process to a second value, so that the target client process can apply for the target lock again.

[0135] Further optionally, determining the target client process from the client processes that apply for the target lock includes: randomly selecting a client process from the client processes that apply for the target lock as the target client process; or selecting the target client process based on at least one of the waiting time for the lock, the number of lock applications, and the priority of the client process that applies for the target lock.

[0136] Further optionally, the method also includes: receiving an application for a shared target lock sent by any client process; based on the application, creating a lock mark area corresponding to any client process in the shared memory module and returning the location information of the lock mark area to any client process, so that any client process can perform read and write operations on the lock mark area based on the location information of the lock mark area.

[0137] The detailed implementation and beneficial effects of each step in the method of this embodiment have been described in detail in the aforementioned embodiments and will not be elaborated here.

[0138] It should be noted that the execution entity of each step of the method provided in the above embodiment can be the same device, or the method can be executed by different devices. For example, the execution entity of steps 71a to 73a can be device A; for another example, the execution entity of steps 71a and 72a can be device A, and the execution entity of step 73a can be device B; and so on.

[0139] In addition, some of the processes described in the above embodiments and the accompanying drawings include multiple operations that appear in a specific order, but it should be clearly understood that these operations may not be executed in the order in which they appear in this article or may be executed in parallel. The sequence numbers of the operations, such as 71a, 72a, etc., are only used to distinguish between different operations, and the sequence numbers themselves do not represent any execution order. In addition, these processes may include more or fewer operations, and these operations may be executed in sequence or in parallel. It should be noted that the descriptions of "first", "second", etc. in this article are used to distinguish different messages, devices, modules, etc., and do not represent a sequential order, nor do they limit "first" and "second" to different types.

[0140] Figure 8a This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 8a As shown, the electronic device includes a shared memory module 81a and a hardware-implemented lock resource management module 82a. Shared memory module 81a is interconnected with multiple servers via a target interconnect bus and maintains lock mark areas corresponding to multiple client processes on the multiple servers that need to share target resource objects. Lock resource management module 82a has read and write permissions on shared memory module 81a.

[0141] The lock resource management module 82a can be implemented based on programmable hardware such as FPGA (Field Programmable Gate Array), CPLD (Complex Programming Logic Device), or on a chip such as ASIC (Application Specific Integrated Circuit), without limitation. In addition, there is no limitation on the hardware implementation structure of the lock resource management module 82a. Any hardware implementation structure that can implement the logic described in the above-mentioned distributed lock processing method embodiment is applicable to the embodiment of the present application. The embodiment of the present application provides an implementation structure of the lock resource management module 82a, such as Figure 8a As shown, it includes: a reading unit 821a, a determining unit 822a and a writing unit 823a based on hardware implementation.

[0142] Among them, the reading unit 821a is responsible for reading the lock mark area corresponding to multiple client processes in the shared memory module 81a to query whether there is a client process applying for the target lock, the target lock corresponds to the target resource object, and provides the query result to the determination unit 822a.

[0143] When the query result provided by the reading unit 821a indicates that there is a client process that has applied for the target lock, the determining unit 822a determines a target client process from the client processes that have applied for the target lock and notifies the writing unit 823a.

[0144] The writing unit 823a rewrites the lock mark area corresponding to the target client process in the shared memory module 81a according to the notification of the determining unit 822a, so as to allocate the target lock to the target client process.

[0145] In an optional embodiment, the reading unit 821a performs a read operation on the lock mark area corresponding to multiple client processes in the shared memory module 81a, specifically: performing a read operation on the lock mark area corresponding to multiple client processes in the shared memory module 81a to determine whether there is a lock mark area containing a first value; if there is a lock mark area containing the first value, determining that there is a client process applying for the target lock; if there is no lock mark area containing the first value, determining that there is no client process applying for the target lock.

[0146] Accordingly, the writing unit 823a rewrites the lock mark area corresponding to the target client process in the shared memory module 81a by writing a third value into the lock mark area corresponding to the target client process in the shared memory module 81a to allocate the target lock to the target client process.

[0147] In an optional embodiment, each lock flag area includes an application flag bit and a status flag bit. Based on this, the reading unit 821a is specifically responsible for reading the application flag bits corresponding to multiple client processes in the shared memory module 81a to determine whether there is an application flag bit with a first value. If there is an application flag bit with the first value, it is determined that a client process has applied for the target lock. If there is no application flag bit with the first value, it is determined that there is no client process applying for the target lock.

[0148] Accordingly, the writing unit 823a is specifically responsible for setting the status mark position corresponding to the target client process in the shared memory module 81a to the third value, so as to allocate the target lock to the target client process.

[0149] Further optionally, each lock mark area also includes a release mark bit. Based on this, the read unit 821a is further responsible for: reading the release mark bit corresponding to the target client process in the shared memory module 81a, and when the release mark bit is at the fifth value, notifying the write unit 823a, so that the write unit 823a sets the status mark bit corresponding to the target client process to the fourth value to reclaim the target lock; wherein the release mark bit is set to the fifth value when the target client process releases the target lock.

[0150] Further optionally, the writing unit 823a is further configured to: during the process of reclaiming the target lock, set the application mark position corresponding to the target client process to a second value, so that the target client process can apply for the target lock again.

[0151] In an optional embodiment, the determination unit 822a is specifically used to: randomly select a client process as the target client process from the client processes that apply for the target lock; or select the target client process based on at least one of the waiting time for the lock, the number of lock applications, and the priority of the client process that applies for the target lock.

[0152] The detailed implementation and beneficial effects of the above-mentioned units have been described in detail in the aforementioned embodiments and will not be elaborated here.

[0153] Figure 8b This is a schematic diagram of the structure of another electronic device provided in an embodiment of the present application. The electronic device can be implemented as a server in a distributed system, but is not limited thereto. The electronic device is interconnected to a shared memory module via a target interconnection bus. The shared memory module maintains lock mark areas corresponding to multiple client processes on the multiple servers that need to share a target resource object. Figure 8b As shown, the electronic device includes: a memory 81b and a processor 82b.

[0154] Memory 81b is used to store computer programs, such as the program code corresponding to the client process in the above-mentioned embodiment, and can be configured to store various other data to support operations on the electronic device. Examples of such data include instructions for any application or method operating on the electronic device, messages, images, videos, etc.

[0155] Processor 82b is coupled to memory 81b and is used to execute program code corresponding to the client process in memory 81b, so as to: write a lock mark area corresponding to any client process in the shared memory module through a target interconnection bus to apply for a target lock from the lock resource management object; wherein the lock resource management object is responsible for allocating the target lock and rewriting the lock mark area corresponding to the client process allocated to the target lock; read a lock mark area corresponding to any client process in the shared memory module through the target interconnection bus to query whether the target lock is applied for; if the target lock is applied for, access the target resource object, and the target lock corresponds to the target resource object.

[0156] In an optional embodiment, when the processor 82b performs a write operation on the lock tag area corresponding to any client process in the shared memory module through the target interconnect bus to apply for a target lock from the lock resource management object, the process includes: writing a first value into the lock tag area corresponding to any client process in the shared memory module through the target interconnect bus to apply for the target lock from the lock resource management object;

[0157] Accordingly, when the processor 82b performs a read operation on the lock mark area corresponding to any client process in the shared memory module through the target interconnection bus to query whether the target lock is applied for, it includes: performing a read operation on the lock mark area corresponding to any client process in the shared memory module through the target interconnection bus to determine whether there is a third value in the lock mark area; if the third value exists, it is determined that the target lock is applied for; if the third value does not exist, it is determined that the target lock is not applied for.

[0158] In an optional embodiment, the lock tag area corresponding to any client process includes: an application tag bit and a status tag bit. Based on this, when the processor 82b writes a first value to the lock tag area corresponding to any client process in the shared memory module via the target interconnect bus to apply for a target lock from the lock resource management object, the process includes: setting the application tag position corresponding to any client process in the shared memory module to the first value via the target interconnect bus to apply for the target lock from the lock resource management object. Correspondingly, when the processor 82b reads the lock tag area corresponding to any client process in the shared memory module via the target interconnect bus to determine whether a third value exists in the lock tag area, the process includes: reading the status tag corresponding to any client process in the shared memory module via the target interconnect bus to determine whether the status tag is the third value.

[0159] Further, in an optional embodiment, before setting the application mark position corresponding to any client process in the shared memory module to the first value through the target interconnect bus, the processor 82b is also used to: read the status mark bit corresponding to any client process in the shared memory module through the target interconnect bus to determine whether the status mark bit is the third value; if the status mark bit is the fourth value, execute the operation of setting the application mark position corresponding to any client process in the shared memory module to the first value through the target interconnect bus; if the status mark bit is the third value, continue to read the status mark bit through the target interconnect bus until the status mark bit is set to the fourth value.

[0160] Further, optionally, the lock flag area corresponding to any client process further includes a release flag bit. Based on this, when the target lock is applied for, processor 82b is further configured to: set the release flag bit corresponding to any client process in the shared memory module to the fifth value via the target interconnect bus to release the target lock; wherein, when the target lock is released, the application flag bit corresponding to any client process is set to the second value.

[0161] Further optionally, in the process of releasing the target lock, the processor 82b is further configured to: set the application mark position corresponding to any client process in the shared memory module to the second value via the target interconnect bus to release the target lock.

[0162] In an optional embodiment, the processor 82b is also used to: send a request for a shared target lock to the lock resource management object, so that the lock resource management object can create a lock mark area corresponding to any client process in the shared memory module and return the location information of the lock mark area; receive the location information of the lock mark area returned by the lock resource management object, so as to perform read and write operations on the lock mark area according to the location information of the lock mark area.

[0163] Further, if Figure 8b As shown, the electronic device also includes: a communication component 83b, a display 84b, a power component 85b, an audio component 86b and other components. Figure 8b Only some components are shown schematically, which does not mean that the electronic device only includes Figure 8b In addition, Figure 8b The components in the dotted box are optional components, not mandatory components, and the specific components may depend on the product form of the electronic device. The electronic device of this embodiment can be implemented as a terminal device such as a desktop computer, a laptop computer, a smart phone or an IOT device, or a server device such as a conventional server, a cloud server or a server array. If the electronic device of this embodiment is implemented as a terminal device such as a desktop computer, a laptop computer, a smart phone, etc., it may include Figure 8b If the electronic device of this embodiment is implemented as a conventional server, cloud server or server array and other server-side devices, it may not include Figure 8b Components within the dotted box.

[0164] In addition to the above electronic device, the embodiment of the present application also provides another electronic device, which is Figure 8b The electronic devices shown have the same or similar implementation structures, so they are not shown in the figure. Figure 8bThe difference between the electronic devices shown is that the computer program in the memory 81b executed by the processor 82b is different. In this embodiment, the computer program stored in the memory 81b can be the program code corresponding to the central service process in the above embodiment, wherein the processor 82b executes the program code of the central service process stored in the memory 81b to achieve: reading the lock mark area corresponding to multiple client processes in the shared memory module to query whether there is a client process applying for the target lock, and the target lock corresponds to the target resource object; if there is a client process applying for the target lock, determining the target client process from the client processes applying for the target lock; rewriting the lock mark area corresponding to the target client process in the shared memory module to assign the target lock to the target client process.

[0165] In an optional embodiment, when the processor 82b reads the lock mark area corresponding to multiple client processes in the shared memory module to query whether there is a client process that has applied for the target lock, the processor 82b includes: reading the lock mark area corresponding to multiple client processes in the shared memory module to determine whether there is a lock mark area containing a first value; if there is a lock mark area containing the first value, determining that there is a client process that has applied for the target lock; if there is no lock mark area containing the first value, determining that there is no client process that has applied for the target lock. Accordingly, when the processor 82b rewrites the lock mark area corresponding to the target client process in the shared memory module to assign the target lock to the target client process, the processor includes: writing a third value to the lock mark area corresponding to the target client process in the shared memory module to assign the target lock to the target client process.

[0166] In an optional embodiment, the lock mark area includes: an application mark bit and a status mark bit. Based on this, when the processor 82b reads the lock mark area corresponding to multiple client processes in the shared memory module to determine whether there is a lock mark area containing a first value, it includes: reading the application mark bits corresponding to multiple client processes in the shared memory module to determine whether there is an application mark bit with the first value. Correspondingly, when the processor 82b writes a third value to the lock mark area corresponding to the target client process in the shared memory module to assign the target lock to the target client process, it includes: setting the status mark position corresponding to the target client process in the shared memory module to the third value to assign the target lock to the target client process.

[0167] In an optional embodiment, each lock flag area further includes a release flag bit. Based on this, the processor 82b is further configured to read the release flag bit corresponding to the target client process in the shared memory module and, if the release flag bit is at the fifth value, set the status flag bit corresponding to the target client process to the fourth value to reclaim the target lock; wherein the release flag bit is set to the fifth value when the target client process releases the target lock.

[0168] Further optionally, in the process of reclaiming the target lock, the processor 82b is further configured to: set the application mark position corresponding to the target client process to a second value, so that the target client process can apply for the target lock again.

[0169] Further optionally, when the processor 82b determines the target client process from the client processes that apply for the target lock, it includes: randomly selecting a client process from the client processes that apply for the target lock as the target client process; or selecting the target client process based on at least one of the waiting time for the lock, the number of lock applications, and the priority of the client process that applies for the target lock.

[0170] Further optionally, the processor 82b is also used to: receive an application for a shared target lock sent by any client process; based on the application, create a lock mark area corresponding to any client process in the shared memory module and return the location information of the lock mark area to any client process, so that any client process can perform read and write operations on the lock mark area based on the location information of the lock mark area.

[0171] The detailed implementation and beneficial effects of the above operations have been described in detail in the aforementioned embodiments and will not be elaborated here.

[0172] Accordingly, the present application also provides a computer-readable storage medium storing a computer program. When the computer program is executed by the processor 82b, the processor 82b is enabled to implement each step of the above-mentioned method embodiment. Detailed descriptions of each step in the above-mentioned method embodiments can be found in the above-mentioned embodiments and are not repeated here.

[0173] Accordingly, embodiments of the present application provide a computer program product comprising a computer program / instructions. When the computer program / instructions are executed by processor 82b, processor 82b is enabled to implement each step in the above-described method embodiments. Detailed descriptions of each step in the above-described method embodiments can be found in the aforementioned embodiments and are not repeated here.

[0174] The above-mentioned memory can be implemented by any type of volatile or non-volatile memory device or a combination thereof, such as static random-access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0175] The above-mentioned communication component is configured to facilitate wired or wireless communication between the device where the communication component is located and other devices. The device where the communication component is located can access a wireless network based on a communication standard, such as WiFi, 2G, 3G, 4G / LTE, 5G and other mobile communication networks, or a combination thereof. In an exemplary embodiment, the communication component receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra wide band (UWB) technology, Bluetooth (BT) technology and other technologies.

[0176] The above-mentioned display includes a screen, which may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor can not only sense the boundary of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation.

[0177] The power supply assembly provides power to various components of the device in which the power supply assembly is located. The power supply assembly may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device in which the power supply assembly is located.

[0178] The above-mentioned audio component can be configured to output and / or input audio signals. For example, the audio component includes a microphone (MIC), and when the device where the audio component is located is in an operating mode, such as call mode, recording mode, and voice recognition mode, the microphone is configured to receive external audio signals. The received audio signal can be further stored in a memory or sent via a communication component. In some embodiments, the audio component also includes a speaker for outputting audio signals.

[0179] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to magnetic disk storage, compact disc read-only memory (CD-ROM), optical storage, etc.) that contain computer-usable program code.

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

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

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

[0183] In a typical configuration, a computing device includes one or more processors (Central Processing Unit, CPU), input / output interfaces, network interfaces, and memory.

[0184] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

[0185] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be used to store information using any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change random access memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media such as modulated data signals and carrier waves.

[0186] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.

[0187] The above are merely embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should all be included within the scope of the claims of the present application.

Claims

1. A distributed lock processing method, characterized in that: The method is applied to any client process on any server in a distributed system, wherein multiple servers in the distributed system are interconnected to share a memory module via a target interconnect bus, and the shared memory module maintains lock mark areas corresponding to multiple client processes on the multiple servers that need to share a target resource object. The method includes: Performing a write operation on the lock mark area corresponding to any client process in the shared memory module through the target interconnect bus to apply for a target lock from the lock resource management object; wherein the lock resource management object is responsible for allocating the target lock and rewriting the lock mark area corresponding to the client process allocated to the target lock; Performing a read operation on a lock mark area corresponding to any client process in the shared memory module through the target interconnection bus to query whether the target lock is applied for; When the target lock is applied for, the target resource object is accessed, and the target lock corresponds to the target resource object.

2. The method according to claim 1, characterized in that Performing a write operation on a lock mark area corresponding to any client process in the shared memory module through the target interconnect bus to apply for a target lock from a lock resource management object, including: Writing a first value into a lock mark area corresponding to any client process in the shared memory module through the target interconnect bus to apply for a target lock from the lock resource management object; Accordingly, a read operation is performed on the lock mark area corresponding to any client process in the shared memory module through the target interconnect bus to query whether the target lock is applied for, including: performing a read operation on a lock mark area corresponding to any client process in the shared memory module through the target interconnect bus to determine whether a third value exists in the lock mark area; If the third value exists, it is determined that the target lock is applied for; if the third value does not exist, it is determined that the target lock is not applied for.

3. The method according to claim 2, characterized in that The lock mark area corresponding to any client process includes: an application mark bit and a status mark bit; The method of writing a first value into a lock mark area corresponding to any client process in the shared memory module through the target interconnect bus to apply for a target lock from the lock resource management object includes: Setting the application mark position corresponding to any one of the client processes in the shared memory module to the first value via the target interconnect bus, so as to apply for a target lock from the lock resource management object; The step of performing a read operation on a lock mark area corresponding to any one of the client processes in the shared memory module through the target interconnect bus to determine whether a third value exists in the lock mark area includes: The status flag bit corresponding to any one of the client processes in the shared memory module is read through the target interconnection bus to determine whether the status flag bit is the third value.

4. The method according to claim 3, characterized in that Before setting the application mark position corresponding to any client process in the shared memory module to the first value through the target interconnection bus, the method further includes: Reading a status flag bit corresponding to any one of the client processes in the shared memory module through the target interconnect bus to determine whether the status flag bit is the third value; When the status flag bit is at the fourth value, performing an operation of setting the application flag bit corresponding to the any one of the client processes in the shared memory module to the first value through the target interconnect bus; When the status flag bit is the third value, the status flag bit is continuously read through the target interconnect bus until the status flag bit is set to the fourth value.

5. The method according to claim 3, characterized in that The lock mark area corresponding to any client process also includes: a release mark bit; In the case where the target lock is applied for, the method further includes: setting a release mark position corresponding to any client process in the shared memory module to a fifth value via the target interconnect bus to release the target lock; Wherein, when the target lock is released, the application flag corresponding to any one of the client processes is set to the second value.

6. The method according to any one of claims 1 to 5, characterized in that Also includes: Sending a request for sharing the target lock to the lock resource management object, so that the lock resource management object creates a lock mark area corresponding to any client process in the shared memory module and returns location information of the lock mark area; The location information of the lock mark area returned by the lock resource management object is received, so as to perform a read and write operation on the lock mark area according to the location information of the lock mark area.

7. A distributed lock processing method, characterized in that: A lock resource management object is applied to a distributed system, wherein multiple servers in the distributed system are interconnected to a shared memory module via a target interconnect bus, and the shared memory module maintains lock mark areas corresponding to multiple client processes on the multiple servers that need to share a target resource object. The method includes: Performing a read operation on the lock mark area corresponding to the multiple client processes in the shared memory module to query whether there is a client process that applies for a target lock, the target lock corresponding to the target resource object; If there is a client process that applies for the target lock, determine the target client process from the client processes that apply for the target lock; Rewrite the lock mark area corresponding to the target client process in the shared memory module to allocate the target lock to the target client process.

8. The method according to claim 7, characterized in that Performing a read operation on the lock mark area corresponding to the multiple client processes in the shared memory module to query whether there is a client process that applies for a target lock, including: Performing a read operation on the lock mark areas corresponding to the multiple client processes in the shared memory module to determine whether there is a lock mark area containing the first value; If there is a lock mark area containing the first value, it is determined that there is a client process applying for the target lock; if there is no lock mark area containing the first value, it is determined that there is no client process applying for the target lock; Accordingly, rewriting the lock mark area corresponding to the target client process in the shared memory module to allocate the target lock to the target client process includes: A third value is written into the lock mark area corresponding to the target client process in the shared memory module to allocate the target lock to the target client process.

9. The method according to claim 8, characterized in that The lock mark area includes: an application mark bit and a status mark bit; The step of performing a read operation on the lock mark areas corresponding to the plurality of client processes in the shared memory module to determine whether there is a lock mark area containing the first value includes: Reading the application flag bits corresponding to the multiple client processes in the shared memory module to determine whether there is an application flag bit with the first value; The step of writing a third value into a lock mark area corresponding to the target client process in the shared memory module to allocate the target lock to the target client process includes: The status mark position corresponding to the target client process in the shared memory module is set to the third value, so as to allocate the target lock to the target client process.

10. The method according to claim 9, characterized in that The lock mark area also includes: a release mark bit; the method further includes: Reading a release flag bit corresponding to the target client process in the shared memory module, and when the release flag bit is a fifth value, setting a status flag bit corresponding to the target client process to a fourth value to reclaim the target lock; The release mark bit is set to the fifth value when the target client process releases the target lock.

11. A distributed system, characterized in that: include: a plurality of servers, a lock resource management object, and a shared memory module interconnected with the plurality of servers via a target interconnect bus; A plurality of client processes that need to share a target resource object are running on the plurality of servers, and a lock mark area corresponding to each of the plurality of client processes is maintained in the shared memory module; Any client process is configured to perform read and write operations on the lock mark area corresponding to it in the shared memory module through the target interconnect bus, so as to apply for a target lock from the lock resource management object, and access the target resource object if the target lock is applied for; The lock resource management object is used to read the lock mark areas corresponding to the multiple client processes in the shared memory module to allocate the target lock, and rewrite the lock mark areas corresponding to the client processes allocated to the target lock.

12. The system according to claim 11, wherein: The lock resource management object is a central service process running on a control device, and the control device is interconnected with the shared memory module via a target interconnect bus; Alternatively, the lock resource management object is a central service process running on the electronic device to which the shared memory module belongs; Alternatively, the lock resource management object is located on the electronic device to which the shared memory module belongs, and is a lock resource management module implemented based on hardware.

13. An electronic device, characterized in that: include: Shared memory module and lock resource management module; The shared memory module is interconnected with multiple servers via a target interconnect bus and maintains lock mark areas corresponding to multiple client processes on the multiple servers that need to share a target resource object; wherein the lock resource management module includes: a read unit, a determination unit, and a write unit implemented based on hardware; The reading unit is responsible for performing a read operation on the lock mark area corresponding to the multiple client processes in the shared memory module to query whether there is a client process applying for a target lock, the target lock corresponding to the target resource object, and providing the query result to the determining unit; The determining unit determines a target client process from the client processes that apply for the target lock and notifies the writing unit when the query result provided by the reading unit indicates that there is a client process that applies for the target lock; The writing unit rewrites the lock mark area corresponding to the target client process in the shared memory module according to the notification of the determining unit, so as to allocate the target lock to the target client process.

14. An electronic device, characterized in that: include: memory and processor; The memory is used to store a computer program, and the processor is coupled to the memory and is used to execute the computer program to implement the steps in the method according to any one of claims 1 to 10.

15. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the processor is enabled to implement the steps of the method according to any one of claims 1 to 10.

16. A program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the processor is enabled to implement the steps of the method according to any one of claims 1 to 10.

Citation Information

Cited By

  • Database-based semantic distributed lock implementation method and system

    CN121958406A

  • A database-based semantic distributed lock implementation method and system

    CN121958406B