CN113961364B - Large-scale lock system implementation method and device, storage medium and server - Google Patents
Large-scale lock system implementation method and device, storage medium and server Download PDFInfo
- Publication number
- CN113961364B CN113961364B CN202111189055.8A CN202111189055A CN113961364B CN 113961364 B CN113961364 B CN 113961364B CN 202111189055 A CN202111189055 A CN 202111189055A CN 113961364 B CN113961364 B CN 113961364B
- Authority
- CN
- China
- Prior art keywords
- lock
- application program
- pool
- resource
- calling interface
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 51
- 238000012546 transfer Methods 0.000 claims abstract description 14
- 238000004590 computer program Methods 0.000 claims description 19
- 230000008569 process Effects 0.000 claims description 14
- 230000006870 function Effects 0.000 abstract description 7
- 238000010586 diagram Methods 0.000 description 3
- 238000012545 processing Methods 0.000 description 3
- 238000013461 design Methods 0.000 description 2
- 238000011161 development Methods 0.000 description 2
- 238000004064 recycling Methods 0.000 description 2
- 239000002699 waste material Substances 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/52—Program synchronisation; Mutual exclusion, e.g. by means of semaphores
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5027—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Storage Device Security (AREA)
Abstract
The large-scale lock system implementation method comprises the steps that an application program calls an application program calling interface of the software module, a lock pool management object is initialized, the application program calling interface receives an access request, and the lock pool management layer is transferred to realize service; the application program calls an application program calling interface of the software module, creates a logic lock object for the object needing to be lock protected, receives an access request by the application program calling interface, and transfers to a logic lock management layer to realize service; the application program calls the application program calling interface of the software module, executes the locking flow and the unlocking flow, and transfers to the logic lock operation layer to realize the corresponding service. Because more than one million objects require thread security, excessive memory and lock resource pressure on the system due to excessive locks can be avoided. If critical section locks are used in a large scale, the multithreading competition is happened continuously, and the invention can complete the multithreading safety function with few critical section locks.
Description
Technical Field
The invention relates to the field of large-scale resource object thread security protection, in particular to a large-scale lock system realization method, a device, a storage medium and a server.
Background
The lock is an important resource provided by a multitasking operating system, and is commonly provided with a plurality of forms such as a critical area, a semaphore, a mutex and the like, and the core function of the lock is that in the parallel programming field, when two or more threads face the possibility of simultaneously accessing a certain resource (the same variable, the same memory block, the same Socket handle, the same IO handle and the like), in order to avoid read-write conflict, the read-write operations need to be exclusively protected, and other threads are in a waiting state when a certain thread operates the resource.
In the field of large-scale server development, as multithreading and large-concurrency parallel access is required to be performed on resources such as large-scale variables, memory objects and handle objects, the high-density resource access is required to be supported by high-efficiency and massive lock resources, the integrity and the safety of data access can be ensured, and the efficiency of resource access is ensured. However, the lock is a system resource, the number of locks allowed to be held by each process is limited, and a large amount of lock resources are used, so that handle resources and memory resources of the system are consumed in a large scale, the performance of a service process is seriously affected, and even an operating system is crashed due to insufficient resources. So in server applications that use lock resources on a large scale, this is generally solved by several methods:
1. The protection range of the lock is improved, the occupation of the lock handle is reduced, and a complete data structure, such as all data in an array, a queue or a linked list, is protected by using one lock. The system occupies little resources of the operating system, but the lock collision is too dense when large concurrent access is caused, most threads consume a large amount of time on the preemptive lock, and the access efficiency is low.
2. The spin lock is used for providing independent lock protection for the data resource, and the spin lock works in a user mode, so that the handle resource and the memory resource of an operating system are not occupied, and the condition of insufficient system resources is avoided. However, the large-scale use of spin locks can occupy a large amount of CPU resources, and particularly for some operations with complex business and time consumption, the use of spin locks can seriously affect the performance of a server.
3. The data resource lock protection is achieved by registering the lock and unlock states of the data resource using a state table, which is typically implemented using a Hash table or a Bit-map table. The design method is used in a large amount in the row locks of the database, can effectively reduce lock conflict under the condition that the resources of an operating system are not too much occupied, and can improve the performance of a server to a certain extent. However, in this design, the lock state of the resource needs to be obtained by looking up a table, which has a certain influence on performance, and when the thread is in the user state like the spin lock while preempting the lock resource, the thread has the same disadvantage as the spin lock, and it is difficult to balance the CPU occupation and the CPU utilization.
All the three schemes are imperfect, have low performance or serious resource waste, are difficult to compromise, and are difficult to meet the lock protection requirements of mass data, which are both compatible with performance and occupy a small amount of resources in the field of large servers.
Disclosure of Invention
The invention aims to solve the problems in the prior art and provide a large-scale lock system implementation method, a device, a storage medium and a server, which can use few operating system resources (physical lock resources, memory and the like) to provide large-scale lock resources for an application layer so as to realize an efficient 'small lock' application model and meet the high-performance development requirement in a multi-task environment.
In order to achieve the above purpose, the present invention has the following technical scheme:
in a first aspect, an embodiment of the present invention provides a method for implementing a large-scale lock system, including the following steps:
The application program calls an application program calling interface of the software module, initializes a lock pool management object, receives an access request, and transfers to a lock pool management layer to realize service;
The application program calls an application program calling interface of the software module, creates a logic lock object for the object needing to be lock protected, receives an access request by the application program calling interface, and transfers to a logic lock management layer to realize service;
The application program calls an application program calling interface of the software module, prepares to hold a lock, the application program calling interface receives an access request, and transfers to a logic lock operation layer to realize service, if a critical section lock is requested, a lock () operation is executed, if a read lock of a read-write lock is requested, a rdlock () operation is executed, and if a write lock is read, a wrlock () operation is executed;
The application program calls the application program calling interface of the software module, prepares to release the holding lock, the application program calling interface receives the access request, goes to the logic lock operation layer to realize service, executes unlock () operation if the critical section lock is requested, executes rdunlock () operation if the critical section lock is read lock of the read-write lock, and executes wrunlock () operation if the write lock is read lock.
As a preferred scheme of the implementation method of the large-scale lock system, the operation steps are completed under the protection of the same physical lock of the system, so as to ensure that the operation steps are not interrupted in the execution process.
As a preferred scheme of the implementation method of the large-scale lock system, the lock () operation execution condition is that a plurality of threads access the same resource at the same time.
As a preferred implementation method of the large-scale lock system of the present invention, the lock () operation execution step includes: after the locking requirement is first put forward, a lock pool interface is called to create a global lock pool, and a plurality of idle locks are stored in the lock pool to wait for use; after the lock pool receives the locking task, judging whether the resource initiates a locking request for the first time, if so, actively distributing an idle lock to the resource by the lock pool, adding one to the reference count value of the lock, and then locking; if the lock request is not initiated for the first time, the lock pool does not allocate a new free lock to the request, and only the reference count value is increased by one operation based on the original lock of the resource, so as to indicate that the object is being used by multiple parties.
As a preferred scheme of the implementation method of the large-scale lock system, the execution condition of the unlock () operation is that the current thread finishes using the resource.
As a preferred implementation method of the large-scale lock system of the present invention, the unlock () operation execution step includes: subtracting 1 from the reference count value of the lock occupied by the resource, and judging with the value and 1; if the thread is greater than 1, other threads have the need to lock the resource, and do nothing here; if the value is equal to 1, the demand of the resource is not occupied in a follow-up mode, and when the demand of the resource is not occupied in a follow-up mode, the resource is returned to be locked in the lock pool, and the next locking demand is waited.
In a second aspect, an embodiment of the present invention further provides a device for implementing a large-scale lock system, including:
The initialization module is used for calling an application program calling interface of the software module by an application program, initializing a lock pool management object, receiving an access request by the application program calling interface, and transferring to a lock pool management layer to realize service;
The logic lock creation module is used for calling an application program calling interface of the software module by an application program, creating a logic lock object for an object needing lock protection, receiving an access request by the application program calling interface, and transferring to a logic lock management layer to realize service;
The locking module is used for enabling the application program to call an application program call interface of the software module, preparing to hold a lock, enabling the application program call interface to receive an access request, transferring to a logic lock operation layer to realize service, executing lock () operation if a critical section lock is requested, executing rdlock () operation if a read lock of a read-write lock is requested, and executing wrlock () operation if the write lock is a read lock of the read-write lock;
And the unlocking module is used for enabling the application program to call the application program calling interface of the software module to release the holding lock, enabling the application program calling interface to receive the access request and transfer to the logic lock operation layer to realize service, executing unlock () operation if the critical section lock is requested, executing rdunlock () operation if the critical section lock is read lock of the read-write lock, and executing wrunlock () operation if the read lock is read lock of the read-write lock.
In a third aspect, embodiments of the present invention further provide a computer readable storage medium storing a computer program that when executed by a processor implements the method of implementing a lock system.
In a fourth aspect, an embodiment of the present invention further provides a server, including a memory, a processor, and a computer program stored in the memory and capable of running on the processor, where the processor implements the method for implementing a lock system in large scale when executing the computer program.
Compared with the prior art, the invention has at least the following beneficial effects: the number of threads of the server process is limited, few threads are few, and many threads are only about hundreds of threads, so that the server thread can only use hundreds of lock objects at most under the condition that the server extremely does not have thread conflict. Even if the lock resources are used in a large scale in the server process, the number of the lock resources accessed at the same time is always small, and other large amounts of lock resources are in an idle state, which is a great waste of system resources. If the server process can be recycled and reused in good time like the system memory resource, the aim of using fewer lock resources and realizing large-scale lock application can be achieved. Because more than one million objects require thread security, excessive memory and lock resource pressure on the system due to excessive locks can be avoided. If critical section locks are used on a large scale, event handles are also being created as multi-thread contention continues to occur, and if a process exceeds the number of handles of 16M, the process may not be able to run. While when the large-scale lock system designed by the invention is used, the safety function of multiple threads can be finished by using only few critical zone locks.
Drawings
FIG. 1 is a schematic diagram of a large-scale lock system constructed in accordance with an embodiment of the present invention;
FIG. 2 is a schematic diagram of a locking flow of a method for implementing a large-scale lock system according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of an unlocking flow of a method for implementing a large-scale lock system according to an embodiment of the present invention.
Detailed Description
The invention is described in further detail below with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting thereof. In addition, it should be noted that, for convenience of description, only some, but not all of the structures related to the present invention are shown in the drawings.
As an implementation of a large-scale lock system, the most important of which is the scheduling and utilization of lock resources, i.e. the process in which locking and unlocking takes place.
Referring to fig. 1, in the large-scale lock system structure constructed by the invention, an application program directly calls an API interface, internal logic is not required to be related, a logic lock management layer stores a plurality of logic locks, locks in a lock pool are taken through the logic locks, and the lock pool management layer interacts with the logic lock management layer to realize the taking operation of the locks in the lock pool.
Application call interface: the method is used for defining the operation method of the module, is used for calling other computer programming languages and realizes function output;
lock pool management layer: the lock resource recycling method is used for providing lock resource recycling and allocation algorithm logic based on a pool, and realizing lock resource reuse;
Logical lock management layer: for defining a logical lock object, which is not a real lock, but a logical lock management object, for storing an object pointer and reference counter of a real lock. The logical lock management layer provides a create (), a delete () operation method for creating and releasing logical lock objects;
Logical lock operation layer: for providing lock algorithm logic, each lock implemented provides the corresponding lock type of operation characteristics, such as lock (), unlock (), lock () operations, and read/write lock(s) provide rdlock (), rdunlock (), wrlock (), wrunlock (), etc.
The invention provides a method for realizing a large-scale lock system, which comprises the following steps:
The application program calls an application program calling interface of the software module, initializes a lock pool management object, receives an access request, and transfers to a lock pool management layer to realize service;
The application program calls an application program calling interface of the software module, creates a logic lock object for the object needing to be lock protected, receives an access request by the application program calling interface, and transfers to a logic lock management layer to realize service;
The application program calls an application program calling interface of the software module, prepares to hold a lock, the application program calling interface receives an access request, and transfers to a logic lock operation layer to realize service, if a critical section lock is requested, a lock () operation is executed, if a read lock of a read-write lock is requested, a rdlock () operation is executed, and if a write lock is read, a wrlock () operation is executed;
The application program calls the application program calling interface of the software module, prepares to release the holding lock, the application program calling interface receives the access request, goes to the logic lock operation layer to realize service, executes unlock () operation if the critical section lock is requested, executes rdunlock () operation if the critical section lock is read lock of the read-write lock, and executes wrunlock () operation if the write lock is read lock.
All the actions are completed under the protection of the same system physical lock, so that the operation of all the actions is not interrupted, and the multithreading safety of the software module is ensured.
Referring to fig. 2, the lock () operation is executed under the condition that multiple threads access the same resource at the same time, and in order to ensure the integrity, reliability and security of data, a requirement is raised. When multiple persons operate the same data in the database at the same time, if the same data are contended by multiple persons under the condition of no locking, the final integrity and reliability of the data cannot be ensured, and hidden danger is caused to the use safety of the following data. The lock () operation execution step includes: after the locking requirement is first put forward, a lock pool interface is called to create a global lock pool, and a plurality of idle locks are stored in the lock pool to wait for use; after the lock pool receives the locking task, judging whether the resource initiates a locking request for the first time, if so, actively distributing an idle lock to the resource by the lock pool, adding one to the reference count value of the lock, and then locking; if the lock request is not initiated for the first time, the lock pool does not allocate a new free lock to the request, and only the reference count value is increased by one operation based on the original lock of the resource, so as to indicate that the object is being used by multiple parties.
Referring to fig. 3, the execution condition of the unlock () operation is that the current thread finishes using the resource, so as to ensure that other threads can normally access and process the requirements of the resource. The execution steps of the unlock () operation include: subtracting 1 from the reference count value of the lock occupied by the resource, and judging with the value and 1; if the thread is greater than 1, other threads have the need to lock the resource, and do nothing here; if the value is equal to 1, the demand of the resource is not occupied in a follow-up mode, and when the demand of the resource is not occupied in a follow-up mode, the resource is returned to be locked in the lock pool, and the next locking demand is waited.
Another embodiment of the present invention also proposes a large-scale lock system implementation apparatus, including:
The initialization module is used for calling an application program calling interface of the software module by an application program, initializing a lock pool management object, receiving an access request by the application program calling interface, and transferring to a lock pool management layer to realize service;
The logic lock creation module is used for calling an application program calling interface of the software module by an application program, creating a logic lock object for an object needing lock protection, receiving an access request by the application program calling interface, and transferring to a logic lock management layer to realize service;
The locking module is used for enabling the application program to call an application program call interface of the software module, preparing to hold a lock, enabling the application program call interface to receive an access request, transferring to a logic lock operation layer to realize service, executing lock () operation if a critical section lock is requested, executing rdlock () operation if a read lock of a read-write lock is requested, and executing wrlock () operation if the write lock is a read lock of the read-write lock;
And the unlocking module is used for enabling the application program to call the application program calling interface of the software module to release the holding lock, enabling the application program calling interface to receive the access request and transfer to the logic lock operation layer to realize service, executing unlock () operation if the critical section lock is requested, executing rdunlock () operation if the critical section lock is read lock of the read-write lock, and executing wrunlock () operation if the read lock is read lock of the read-write lock.
Another embodiment of the present invention also proposes a computer readable storage medium storing a computer program which, when executed by a processor, implements the method of implementing a lock system.
Another embodiment of the present invention also proposes a server comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the method of implementing a lock system on large scale when executing the computer program.
The computer program may be divided into one or more modules/units stored in a computer readable storage medium and executed by the processor to perform the steps in the method of implementing a lock system according to the application. The one or more modules/units may be a series of computer readable instruction segments capable of performing a specified function, which describes the execution of the computer program in a server.
The server can be a smart phone, a notebook computer, a palm computer, a cloud server and other computing devices. The server may include, but is not limited to, a processor, memory. Those skilled in the art will appreciate that the server may also include more or fewer components, or may combine certain components, or different components, e.g., the server may also include input and output devices, network access devices, buses, etc.
The Processor may be a central processing unit (CentraL Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (DIGITAL SIGNAL Processor, DSP), application specific integrated circuits (AppLication SPECIFIC INTEGRATED circuits, ASIC), off-the-shelf programmable gate arrays (FieLd-ProgrammabLe GATE ARRAY, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory may be an internal storage unit of the server, such as a hard disk or a memory of the server. The memory may also be an external storage device of the server, such as a plug-in hard disk, a smart memory card (SMART MEDIA CARD, SMC), a Secure DigitaL (SD) card, a flash memory card (FLASH CARD) or the like, which are provided on the server. Further, the memory may also include both an internal storage unit and an external storage device of the server. The memory is used to store the computer readable instructions and other programs and data required by the server. The memory may also be used to temporarily store data that has been output or is to be output.
It should be noted that, because the content of information interaction and execution process between the above devices/units is based on the same concept as the method embodiment, specific functions and technical effects thereof may be referred to in the method embodiment section, and details thereof are not repeated herein.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions. The functional units and modules in the embodiment may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit, where the integrated units may be implemented in a form of hardware or a form of a software functional unit. In addition, the specific names of the functional units and modules are only for distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working process of the units and modules in the above system may refer to the corresponding process in the foregoing method embodiment, which is not described herein again.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the present application may implement all or part of the flow of the method of the above embodiments, and may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, and when the computer program is executed by a processor, the computer program may implement the steps of each of the method embodiments described above. Wherein the computer program comprises computer program code which may be in source code form, object code form, executable file or some intermediate form etc. The computer readable medium may include at least: any entity or device capable of carrying computer program code to a photographing device/terminal apparatus, recording medium, computer Memory, read-Only Memory (ROM), random access Memory (RAM, random Access Memory), electrical carrier signals, telecommunications signals, and software distribution media. Such as a U-disk, removable hard disk, magnetic or optical disk, etc.
The above embodiments are only for illustrating the technical solution of the present application, and not for limiting the same; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application, and are intended to be included in the scope of the present application.
Claims (8)
1. A method for implementing a large scale lock system, comprising the steps of:
The application program calls an application program calling interface of the software module, initializes a lock pool management object, receives an access request, and transfers to a lock pool management layer to realize service;
The application program calls an application program calling interface of the software module, creates a logic lock object for the object needing to be lock protected, receives an access request by the application program calling interface, and transfers to a logic lock management layer to realize service;
The application program calls an application program calling interface of the software module, prepares to hold a lock, the application program calling interface receives an access request, and transfers to a logic lock operation layer to realize service, if a critical section lock is requested, a lock () operation is executed, if a read lock of a read-write lock is requested, a rdlock () operation is executed, and if a write lock is read, a wrlock () operation is executed;
the application program calls an application program calling interface of the software module, prepares to release the holding lock, the application program calling interface receives an access request, and transfers to a logic lock operation layer to realize service, if the request is a critical section lock, an unlock () operation is executed, if the request is a read lock of a read-write lock, a rdunlock () operation is executed, and if the request is a read lock of the read-write lock, a wrunlock () operation is executed by the write lock;
The lock () operation execution step includes: after the locking requirement is first put forward, a lock pool interface is called to create a global lock pool, and a plurality of idle locks are stored in the lock pool to wait for use; after the lock pool receives the locking task, judging whether the resource initiates a locking request for the first time, if so, actively distributing an idle lock to the resource by the lock pool, adding one to the reference count value of the lock, and then locking; if the lock request is not initiated for the first time, the lock pool does not allocate a new free lock to the request, and only the reference count value is increased by one operation based on the original lock of the resource, so as to indicate that the object is being used by multiple parties.
2. The method for implementing a large scale lock system according to claim 1, wherein: the operation steps are completed under the protection of the same system physical lock, so that the operation steps are not interrupted in the execution process.
3. The method for implementing a large scale lock system according to claim 1, wherein: the lock () operation execution condition is that a plurality of threads access the same resource at the same time.
4. The method for implementing a large scale lock system according to claim 1, wherein: the execution condition of the unlock () operation is that the current thread finishes the use of the resources.
5. The method of claim 1, wherein the performing step of unlock () includes: subtracting 1 from the reference count value of the lock occupied by the resource, and judging with the value and 1; if the thread is greater than 1, other threads have the need to lock the resource, and do nothing here; if the value is equal to 1, the demand of the resource is not occupied in a follow-up mode, and when the demand of the resource is not occupied in a follow-up mode, the resource is returned to be locked in the lock pool, and the next locking demand is waited.
6. A mass lock system implementation apparatus, comprising:
The initialization module is used for calling an application program calling interface of the software module by an application program, initializing a lock pool management object, receiving an access request by the application program calling interface, and transferring to a lock pool management layer to realize service;
The logic lock creation module is used for calling an application program calling interface of the software module by an application program, creating a logic lock object for an object needing lock protection, receiving an access request by the application program calling interface, and transferring to a logic lock management layer to realize service;
The locking module is used for enabling the application program to call an application program call interface of the software module, preparing to hold a lock, enabling the application program call interface to receive an access request, transferring to a logic lock operation layer to realize service, executing lock () operation if a critical section lock is requested, executing rdlock () operation if a read lock of a read-write lock is requested, and executing wrlock () operation if the write lock is a read lock of the read-write lock;
The unlocking module is used for enabling the application program to call an application program calling interface of the software module, preparing to release the holding lock, enabling the application program calling interface to receive the access request, transferring to a logic lock operation layer to realize service, executing unlock () operation if the request is a critical section lock, executing rdunlock () operation if the request is a read lock of a read-write lock, and executing wrunlock () operation if the request is a write lock;
The lock () operation execution step includes: after the locking requirement is first put forward, a lock pool interface is called to create a global lock pool, and a plurality of idle locks are stored in the lock pool to wait for use; after the lock pool receives the locking task, judging whether the resource initiates a locking request for the first time, if so, actively distributing an idle lock to the resource by the lock pool, adding one to the reference count value of the lock, and then locking; if the lock request is not initiated for the first time, the lock pool does not allocate a new free lock to the request, and only the reference count value is increased by one operation based on the original lock of the resource, so as to indicate that the object is being used by multiple parties.
7. A computer readable storage medium storing a computer program, wherein the computer program when executed by a processor implements a method of implementing a lock system according to any one of claims 1 to 5.
8. A server comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the method of implementing a lock-on-large-scale system according to any one of claims 1 to 5 when the computer program is executed by the processor.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111189055.8A CN113961364B (en) | 2021-10-12 | 2021-10-12 | Large-scale lock system implementation method and device, storage medium and server |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111189055.8A CN113961364B (en) | 2021-10-12 | 2021-10-12 | Large-scale lock system implementation method and device, storage medium and server |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113961364A CN113961364A (en) | 2022-01-21 |
CN113961364B true CN113961364B (en) | 2024-09-17 |
Family
ID=79463689
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111189055.8A Active CN113961364B (en) | 2021-10-12 | 2021-10-12 | Large-scale lock system implementation method and device, storage medium and server |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113961364B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114528113B (en) * | 2022-04-24 | 2022-08-23 | 广州中望龙腾软件股份有限公司 | Thread lock management system, method, equipment and readable medium |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102156928A (en) * | 2011-04-29 | 2011-08-17 | 浪潮通信信息系统有限公司 | Method for system concurrency control through business logic lock |
CN102681892A (en) * | 2012-05-15 | 2012-09-19 | 西安热工研究院有限公司 | Key-Value type write-once read-many lock pool software module and running method thereof |
Family Cites Families (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6836887B1 (en) * | 1998-12-21 | 2004-12-28 | Microsoft Corporation | Recyclable locking for multi-threaded computing environments |
US7444634B2 (en) * | 2002-10-31 | 2008-10-28 | Sun Microsystems, Inc. | Method and apparatus for providing dynamic locks for global resources |
US7289992B2 (en) * | 2003-05-01 | 2007-10-30 | International Business Machines Corporation | Method, system, and program for lock and transaction management |
US7827559B1 (en) * | 2006-04-24 | 2010-11-02 | Real-Time Innovations, Inc. | Framework for executing multiple threads and sharing resources in a multithreaded computer programming environment |
CN108304251B (en) * | 2018-02-06 | 2021-11-19 | 网宿科技股份有限公司 | Thread synchronization method and server |
CN108874446B (en) * | 2018-04-12 | 2020-10-16 | 武汉斗鱼网络科技有限公司 | Multithreading access method and device |
-
2021
- 2021-10-12 CN CN202111189055.8A patent/CN113961364B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102156928A (en) * | 2011-04-29 | 2011-08-17 | 浪潮通信信息系统有限公司 | Method for system concurrency control through business logic lock |
CN102681892A (en) * | 2012-05-15 | 2012-09-19 | 西安热工研究院有限公司 | Key-Value type write-once read-many lock pool software module and running method thereof |
Also Published As
Publication number | Publication date |
---|---|
CN113961364A (en) | 2022-01-21 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109783229B (en) | Thread resource allocation method and device | |
CN100481014C (en) | System and method for processing information | |
US8763012B2 (en) | Scalable, parallel processing of messages while enforcing custom sequencing criteria | |
CN113205417B (en) | Alliance chain oriented transaction parallel processing method and system | |
Burns et al. | A review of Ada tasking | |
US10095562B2 (en) | System and method for transforming a queue from non-blocking to blocking | |
CN107562685B (en) | Method for data interaction between multi-core processor cores based on delay compensation | |
WO2008101756A1 (en) | Method and system for concurrent message processing | |
CN115509986A (en) | Inter-core communication method, electronic device, and storage medium | |
CN113590320A (en) | Resource processing method, device, equipment and medium for distributed batch task scheduling | |
US10360079B2 (en) | Architecture and services supporting reconfigurable synchronization in a multiprocessing system | |
US7793023B2 (en) | Exclusion control | |
US8127295B1 (en) | Scalable resource allocation | |
CN114168271A (en) | Task scheduling method, electronic device and storage medium | |
CN113961364B (en) | Large-scale lock system implementation method and device, storage medium and server | |
CN111459622A (en) | Method and device for scheduling virtual CPU, computer equipment and storage medium | |
CN115509704A (en) | Task scheduling method, device, equipment and storage medium | |
CN105677481B (en) | A kind of data processing method, system and electronic equipment | |
CN111309494A (en) | Multithreading event processing assembly | |
CN116450328A (en) | Memory allocation method, memory allocation device, computer equipment and storage medium | |
CN111125070A (en) | Data exchange method and platform | |
JP2804478B2 (en) | Task control system and online transaction system | |
CN116107772A (en) | Multithreading data processing method and device, processor and electronic equipment | |
CN111989651A (en) | Method and device for managing kernel service in multi-core system | |
CN112346879B (en) | Process management method, device, computer equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |