CN110990161A - Shared resource access method, device, equipment and computer readable storage medium - Google Patents

Shared resource access method, device, equipment and computer readable storage medium Download PDF

Info

Publication number
CN110990161A
CN110990161A CN201911121525.XA CN201911121525A CN110990161A CN 110990161 A CN110990161 A CN 110990161A CN 201911121525 A CN201911121525 A CN 201911121525A CN 110990161 A CN110990161 A CN 110990161A
Authority
CN
China
Prior art keywords
resource
accessed
locking
resources
resource access
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.)
Pending
Application number
CN201911121525.XA
Other languages
Chinese (zh)
Inventor
周恒�
秦海中
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Inspur Data Technology Co Ltd
Original Assignee
Beijing Inspur Data Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing Inspur Data Technology Co Ltd filed Critical Beijing Inspur Data Technology Co Ltd
Priority to CN201911121525.XA priority Critical patent/CN110990161A/en
Publication of CN110990161A publication Critical patent/CN110990161A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores
    • G06F9/526Mutual exclusion algorithms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/52Indexing scheme relating to G06F9/52
    • G06F2209/522Manager

Abstract

The invention discloses a shared resource access method, which comprises the following steps: receiving a target resource access request, and analyzing the target resource access request to obtain a resource set to be accessed; respectively acquiring state information of each resource to be accessed in the resource set to be accessed; and when the state information of each resource to be accessed is determined to be idle, uniformly locking each resource to be accessed. By applying the technical scheme provided by the embodiment of the invention, the processing logic of resource locking is simplified, the resource locking efficiency is greatly improved, the expenditure is reduced, and the programming requirement of an application layer is greatly reduced. The invention also discloses a shared resource access device, equipment and a storage medium, and has corresponding technical effects.

Description

Shared resource access method, device, equipment and computer readable storage medium
Technical Field
The present invention relates to the field of computer application technologies, and in particular, to a method, an apparatus, a device, and a computer-readable storage medium for accessing shared resources.
Background
Distributed locks are a way to control synchronous access to shared resources among distributed systems, ensuring that only one processor is on the same resource at the same time. The distributed locks provided at present are all based on one resource for locking, and if a plurality of resources need to be locked, multiple times of locking are needed from an application layer. And each resource is locked in sequence, and the locking result needs to be logically judged and processed respectively, so that the processing logic is complex. When it is necessary to wait for all resources to be successfully locked, one wait is needed. The application layer logic must lock resource a before locking resource B. When it may happen that resource a is locked, resource B is lockable, and it needs to wait at this time. When locked resource A completes, locked resource B may also need to wait again, and resource locking is inefficient. Multiple locking can cause resource overhead of an application layer, and the overhead of distributed resources such as a network and the like is large because of distributed locking.
Multiple locking, meaning multiple unlocking. I.e., different atomic operations, locking multiple resources requires unlocking multiple resources. To ensure that multiple locked resources are unlocked under both normal and abnormal conditions in a program, it is necessary to ensure that all unlocking is successful. One operation has problems, requiring the application layer to do the consistency handling, and the programming requirement of the application layer is high.
In summary, how to effectively solve the problems of complex processing logic, low locking efficiency, high overhead, high programming requirement on an application layer, and the like of resource locking is a problem that needs to be solved urgently by a person skilled in the art at present.
Disclosure of Invention
The invention aims to provide a shared resource access method, which simplifies the processing logic of resource locking, greatly improves the resource locking efficiency, reduces the expenditure and greatly reduces the programming requirement of an application layer; another object of the present invention is to provide a shared resource access apparatus, device and computer-readable storage medium.
In order to solve the technical problems, the invention provides the following technical scheme:
a shared resource access method, comprising:
receiving a target resource access request, and analyzing the target resource access request to obtain a resource set to be accessed;
respectively acquiring state information of each resource to be accessed in the resource set to be accessed;
and when the state information of each resource to be accessed is determined to be idle, uniformly locking each resource to be accessed.
In one embodiment of the present invention, the method further comprises:
when the state information of each resource to be accessed is determined to be partially idle, judging whether partial locking is allowed or not;
if so, uniformly locking the part of the resources to be accessed, the state information of which is idle.
In one embodiment of the present invention, the method further comprises:
when partial locking is determined not to be allowed, judging whether all the resources to be accessed are waited to be idle or not;
if so, judging whether the target resource access request is crossed with other unfinished resource access requests or not;
if so, outputting a locking failure prompt message;
and if not, executing the step of uniformly locking the resources to be accessed when the state information of the resources to be accessed is determined to be idle.
In a specific embodiment of the present invention, determining whether the target resource access request has resource intersection with other uncompleted resource access requests includes:
acquiring set type information of the resource set to be accessed;
when the set type information is a quantity-limited resource set, converting the resource to be accessed, of which the state information is in a non-idle state, in the resource set to be accessed into corresponding binary values according to a preset binary conversion table, performing exclusive-or operation on the binary values and the binary values corresponding to the locked resources of other uncompleted resource access requests respectively, and determining whether the target resource access request is crossed with the other uncompleted resource access requests according to the exclusive-or operation result;
when the set type information is an infinite resource set, converting the resource to be accessed, of which the state information is in a non-idle state, in the resource set to be accessed into character strings with corresponding suffix character strings according to a suffix character string conversion table, comparing the suffix character strings of the character strings with suffix character strings of character strings corresponding to locked resources of other uncompleted resource access requests respectively, and determining whether the target resource access request is crossed with the other uncompleted resource access requests according to the comparison result.
In a specific embodiment of the present invention, when it is determined that the state information of each resource to be accessed is idle, after performing unified locking on each resource to be accessed, and after performing unified locking on a part of resources to be accessed whose state information is idle, the method further includes:
when a newly-added resource to be accessed is obtained, determining target set type information to which the newly-added resource to be accessed belongs;
and adding the newly-added resources to be accessed into the collection lock corresponding to the target collection type information.
In a specific embodiment of the present invention, after determining that there is no resource intersection between the target resource access request and other uncompleted resource access requests, and when it is determined that the status information of each to-be-accessed resource is idle, before performing unified locking on each to-be-accessed resource, the method further includes:
judging whether the waiting time is out;
if yes, executing the step of outputting the locking failure prompt message;
and if not, executing the step of uniformly locking the resources to be accessed when the state information of the resources to be accessed is determined to be idle.
A shared resource access device, comprising:
the request analysis module is used for receiving a target resource access request and analyzing the target resource access request to obtain a resource set to be accessed;
the state information acquisition module is used for respectively acquiring the state information of each resource to be accessed in the resource set to be accessed;
and the resource locking module is used for uniformly locking each resource to be accessed when the state information of each resource to be accessed is determined to be idle.
In one embodiment of the present invention, the method further comprises:
the first judgment module is used for judging whether partial locking is allowed or not when the state information of each resource to be accessed is determined to be partially idle;
and the resource locking module is also used for uniformly locking the part of the resources to be accessed, the state information of which is idle, when the part of the resources is determined to be allowed to be locked.
A shared resource access device, comprising:
a memory for storing a computer program;
a processor for implementing the steps of the shared resource access method as described above when executing the computer program.
A computer readable storage medium having stored thereon a computer program which, when executed by a processor, carries out the steps of the shared resource access method as described above.
By applying the method provided by the embodiment of the invention, the target resource access request is received and is analyzed to obtain a resource set to be accessed; respectively acquiring state information of each resource to be accessed in the resource set to be accessed; and when the state information of each resource to be accessed is determined to be idle, uniformly locking each resource to be accessed. By acquiring the state information of each resource to be accessed in the resource set to be accessed, when the state information of each resource to be accessed is determined to be idle, the resource to be accessed is uniformly locked, a distributed integrated lock is formed, a plurality of resources to be accessed correspond to one lock and correspond to an atomic operation which can not be decomposed again, the processing logic of resource locking is simplified, the resource locking efficiency is greatly improved, the expenditure is reduced, the resource is uniformly unlocked when being unlocked, and the programming requirement of an application layer is greatly reduced.
Accordingly, embodiments of the present invention further provide a shared resource access apparatus, a device, and a computer-readable storage medium corresponding to the shared resource access method, which have the above technical effects and are not described herein again.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a flowchart of an implementation of a shared resource access method according to an embodiment of the present invention;
FIG. 2 is a flowchart of another implementation of a shared resource access method according to an embodiment of the present invention;
FIG. 3 is a flowchart of another implementation of a method for accessing shared resources according to an embodiment of the present invention;
FIG. 4 is a block diagram of a shared resource access apparatus according to an embodiment of the present invention;
fig. 5 is a block diagram of a shared resource access device according to an embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the disclosure, the invention will be described in further detail with reference to the accompanying drawings and specific embodiments. It is to be understood that the described embodiments are merely exemplary of the invention, and not restrictive of the full scope of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The first embodiment is as follows:
referring to fig. 1, fig. 1 is a flowchart of an implementation of a shared resource access method in an embodiment of the present invention, where the method may include the following steps:
s101: and receiving a target resource access request, and analyzing the target resource access request to obtain a resource set to be accessed.
When a certain distributed system needs to access a certain part of resources in the shared resource pool, a target resource access request can be sent to the resource access management center, wherein the target resource access request contains the set information of the resource set to be accessed. And the resource access management center receives the target resource access request and analyzes the target resource access request to obtain a resource set to be accessed.
The target resource access request may be an access request for any resource in the shared resource pool.
S102: and respectively acquiring the state information of each resource to be accessed in the resource set to be accessed.
For any resource in the shared resource pool, only one visitor is allowed to access at the same time, namely only single-threaded access is allowed. After the resource set to be accessed is obtained through analysis, the state information of each resource to be accessed in the resource set to be accessed can be respectively obtained. Therefore, whether each resource to be accessed is in an idle state or in an accessed locking state at present can be acquired.
S103: and when the state information of each resource to be accessed is determined to be idle, uniformly locking each resource to be accessed.
After the state information of each resource to be accessed in the resource set to be accessed is acquired, if the state information of each resource to be accessed is determined to be idle, the resource to be accessed can be uniformly locked. The distributed integrated lock is formed by uniformly locking the resources to be accessed, a plurality of resources to be accessed correspond to one lock and one atomic operation which can not be decomposed again, so that the reliability and the usability of locking the plurality of resources are greatly improved, the locking efficiency is greatly improved, and the locking performance is improved.
By applying the method provided by the embodiment of the invention, the target resource access request is received and is analyzed to obtain a resource set to be accessed; respectively acquiring state information of each resource to be accessed in the resource set to be accessed; and when the state information of each resource to be accessed is determined to be idle, uniformly locking each resource to be accessed. By acquiring the state information of each resource to be accessed in the resource set to be accessed, when the state information of each resource to be accessed is determined to be idle, the resource to be accessed is uniformly locked, a distributed integrated lock is formed, a plurality of resources to be accessed correspond to one lock and correspond to an atomic operation which can not be decomposed again, the processing logic of resource locking is simplified, the resource locking efficiency is greatly improved, the expenditure is reduced, the resource is uniformly unlocked when being unlocked, and the programming requirement of an application layer is greatly reduced.
It should be noted that, based on the first embodiment, the embodiment of the present invention further provides a corresponding improvement scheme. In the following embodiments, steps that are the same as or correspond to those in the first embodiment may be referred to each other, and corresponding advantageous effects may also be referred to each other, which are not described in detail in the following modified embodiments.
Referring to fig. 2, fig. 2 is a flowchart of another implementation of the shared resource access method in the embodiment of the present invention, where the method may include the following steps:
s201: and receiving a target resource access request, and analyzing the target resource access request to obtain a resource set to be accessed.
S202: and respectively acquiring the state information of each resource to be accessed in the resource set to be accessed.
S203: and when the state information of each resource to be accessed is determined to be idle, uniformly locking each resource to be accessed.
S204: when the state information of each resource to be accessed is determined to be partially free, whether partial locking is allowed is judged, if yes, step S205 is executed, and if not, step S206 is executed.
After the state information of each resource to be accessed in the resource set to be accessed is acquired, if it is determined that the state information of each resource to be accessed is partially idle, it may be determined whether partial locking is allowed, if the current locking rule is to allow partial locking, step S205 may be continuously performed, and if the current locking rule is not to allow partial locking, step S206 may be continuously performed.
S205: and uniformly locking the part of resources to be accessed, the state information of which is idle.
When the state information of each resource to be accessed is determined to be partially idle and the current locking rule is to allow partial locking, the partial resources to be accessed with the idle state information can be uniformly locked, and locking is completed. Therefore, when partial resources in the resources needing to be accessed are in a non-idle state, the delta locking is allowed, the normal access of other resources is not influenced, the resource access is adjustable, and the user access experience is improved.
S206: and judging whether all the resources to be accessed are idle or not, if so, executing the step S207, and if not, executing the step S209.
When it is determined that the status information of each resource to be accessed is partially idle and the current locking rule is not to allow partial locking, it may be determined whether to wait for all the resources to be accessed to be idle, if so, step S207 may be continuously performed, and if not, it is indicated that the resource access at this time must access all the resources to be accessed included in the resource set to be accessed, and in this case, step S209 may be continuously performed.
S207: and judging whether the target resource access request is crossed with other uncompleted resource access requests or not, if so, executing the step S209, and otherwise, executing the step S208.
When it is determined that all the resources to be accessed are waiting for being idle, in order to avoid an invalid waiting situation occurring because the resources to be accessed, in which the currently waiting resource set to be accessed is in a non-idle state, have been locked by other uncompleted resource access requests, it may be determined whether a resource intersection exists between the target resource access request and other uncompleted resource access requests, and if so, it may be determined that the resources to be accessed, in which the currently waiting resource set to be accessed is in a non-idle state, have been locked by other uncompleted resource access requests, and a deadlock state has occurred, and in this case, step S209 may be continuously executed. If not, the process may continue to step S208.
S208: it is determined whether the wait time has expired, and if so, step S209 is executed, and if not, step S203 is executed.
The waiting time for the resource to be accessed which is currently in the non-idle state may be preset, when it is determined that there is no resource intersection between the target resource access request and the other uncompleted resource access requests, it may be determined whether the waiting time out, and if the waiting time out, step S209 may be continuously executed. If not, when the state information of each resource to be accessed is determined to be idle, the resource to be accessed is uniformly locked. By setting the overtime judgment, meaningless waiting caused by other uncertain factors can be avoided, the resource access efficiency is further improved, and the user access experience is improved.
It should be noted that the waiting time duration may be set and adjusted according to actual situations, which is not limited in the embodiment of the present invention.
S209: and outputting a locking failure prompt message.
And when the state information of each resource to be accessed is determined to be partially idle, the current locking rule is that partial locking is not allowed, and all the resources to be accessed are not waited to be completely idle, directly outputting a locking failure prompt message. And when the situation that all the resources to be accessed are idle and the target resource access request and other unfinished resource access requests have resource intersection is confirmed, outputting a locking failure prompt message. And when the target resource access request and other unfinished resource access requests are not crossed by resources after the resources to be accessed are confirmed and wait to be completely idle, and if the waiting time is overtime, outputting a locking failure prompt message. Therefore, the user is prompted in time, and the user can conveniently and timely take corresponding measures.
Example three:
referring to fig. 3, fig. 3 is a flowchart of another implementation of the shared resource access method in the embodiment of the present invention, where the method may include the following steps:
s301: and receiving a target resource access request, and analyzing the target resource access request to obtain a resource set to be accessed.
S302: and respectively acquiring the state information of each resource to be accessed in the resource set to be accessed.
S303: and when the state information of each resource to be accessed is determined to be idle, uniformly locking each resource to be accessed.
S304: when the state information of each resource to be accessed is determined to be partially free, whether partial locking is allowed is judged, if yes, step S305 is executed, and if not, step S306 is executed.
S305: and uniformly locking the part of resources to be accessed, the state information of which is idle.
S306: and judging whether all the resources to be accessed are idle or not, if so, executing the step S307, and if not, executing the step S311.
S307: and acquiring the set type information of the resource set to be accessed.
When all the resources to be accessed are determined to be idle, the set type information of the resource set to be accessed can be obtained. Such as obtaining whether the resource set to be accessed belongs to a quantity-limited resource set or a quantity-unlimited resource set. The quantity-restricted resource means that the quantity of such resource is less than a certain value (e.g. 10000, set according to the hardware condition) under the resource type. An infinite number of resources means that the number of such resources is uncertain for the type of resource.
S308: when the set type information is a quantity-limited resource set, the resource to be accessed, the state information of which is in a non-idle state, in the resource set to be accessed is converted into corresponding binary values according to a preset binary conversion table, the binary values and the binary values corresponding to the locked resources of other uncompleted resource access requests are subjected to exclusive-or operation respectively, whether resource intersection exists between the target resource access request and the other uncompleted resource access requests or not is determined according to the exclusive-or operation result, if so, step 311 is executed, and if not, step 310 is executed.
A binary conversion table may be preset for the quantity-limited resource set, and a one-to-one correspondence relationship is set between each resource and a binary digit, for example, a first resource is mapped to 1, a second non-repeating resource is mapped to 10, and so on 100, 1000, 1000, and 10000 … …. When the set type information of the resource set to be accessed is determined to be a quantity-limited resource set, the resource to be accessed, of which the state information is in a non-idle state, in the resource set to be accessed is converted into corresponding binary values according to a preset binary conversion table, the binary values and the binary values corresponding to the locked resources of other uncompleted resource access requests are subjected to exclusive OR operation respectively, and whether resource intersection exists between the target resource access request and the other uncompleted resource access requests is determined according to the exclusive OR operation result. For example, for a set of resources to be accessed, set resource 1 is converted to 1 (binary), set resource 2 is converted to 10 (binary), set resource 3 is converted to 100 (binary), set resource 4 is converted to 10000000000 (binary), and the entire set resource may be added together numerically to become 10000000111. When the resource is compared with the binary values corresponding to the locked resources of other uncompleted resource access requests, the overlapped resources can be obtained only by carrying out XOR operation, and whether resource intersection exists is efficiently judged.
S309: when the set type information is an infinite resource set, the resource to be accessed, the state information of which is in a non-idle state, in the resource set to be accessed is converted into a character string with a corresponding suffix character string according to a suffix character string conversion table, the suffix character string of each character string is compared with the suffix character string of the character string corresponding to the locked resource of other unfinished resource access requests, whether the target resource access request is crossed with the resource of other unfinished resource access requests is determined according to the comparison result, if so, step S311 is executed, and if not, step S310 is executed.
A suffix character string conversion table can be preset for an infinite number of resource sets, and the resource sets are in one-to-one correspondence with character strings with corresponding suffix character strings. When a new element appears, the last 1 bit of the resource name is sequentially taken to see whether the suffix is occupied, if so, the last 2 bits are taken until the suffix is not occupied. And writing the character string into a corresponding suffix character string conversion table. If the last bit is still occupied up to then, 0-9a-z starts to be added, looking for a suffix that is not occupied. When the set type information is an infinite resource set, the resource to be accessed, the state information of which is in a non-idle state, in the resource set to be accessed is converted into a character string with a corresponding suffix character string according to a suffix character string conversion table, the suffix character string of each character string is compared with the suffix character string of the character string corresponding to the locked resource of other unfinished resource access requests, and whether resource intersection exists between the target resource access request and other unfinished resource access requests is determined according to the comparison result. When a common user is used to appoint the resource, the prefix is the same, and the suffix is different, so that the length of the resource is reduced as much as possible when the set comparison is carried out, and the efficiency is improved. According to the resource type of the resource set to be accessed, only the resource set to be accessed and the resource set to be accessed with the same resource type are subjected to resource cross comparison, so that most of unnecessary comparison is reduced, and the resource access efficiency is greatly improved.
S310: and judging whether the waiting time is overtime, if so, executing step S311, and if not, executing step S303.
S311: and outputting a locking failure prompt message.
In a specific embodiment of the present invention, after the resources to be accessed are uniformly locked and the part of the resources to be accessed whose state information is idle are uniformly locked when it is determined that the state information of the resources to be accessed is idle, the method may further include the following steps:
the method comprises the following steps: when the newly-added resources to be accessed are obtained, determining the type information of a target set to which the newly-added resources to be accessed belong;
step two: and adding the newly-added resources to be accessed into the collection lock corresponding to the target collection type information.
For convenience of description, the above two steps may be combined for illustration.
When the state information of each resource to be accessed is determined to be idle, after the resource to be accessed is uniformly locked, and after the part of the resource to be accessed, the state information of which is idle, is uniformly locked, when the newly-added resource to be accessed is acquired, the target set type information to which the newly-added resource to be accessed belongs is determined, the newly-added resource to be accessed is added into the set lock corresponding to the target set type information, the resource increment locking is allowed, and the usability of the distributed set lock is improved.
Corresponding to the above method embodiments, the embodiments of the present invention further provide a shared resource access apparatus, and the shared resource access apparatus described below and the shared resource access method described above may be referred to correspondingly.
Referring to fig. 4, fig. 4 is a block diagram of a shared resource access apparatus according to an embodiment of the present invention, where the apparatus may include:
a request analysis module 41, configured to receive a target resource access request, and analyze the target resource access request to obtain a resource set to be accessed;
a status information obtaining module 42, configured to obtain status information of each resource to be accessed in the resource set to be accessed;
and the resource locking module 43 is configured to perform unified locking on the resources to be accessed when it is determined that the state information of the resources to be accessed is idle.
By applying the method provided by the embodiment of the invention, the target resource access request is received and is analyzed to obtain a resource set to be accessed; respectively acquiring state information of each resource to be accessed in the resource set to be accessed; and when the state information of each resource to be accessed is determined to be idle, uniformly locking each resource to be accessed. By acquiring the state information of each resource to be accessed in the resource set to be accessed, when the state information of each resource to be accessed is determined to be idle, the resource to be accessed is uniformly locked, a distributed integrated lock is formed, a plurality of resources to be accessed correspond to one lock and correspond to an atomic operation which can not be decomposed again, the processing logic of resource locking is simplified, the resource locking efficiency is greatly improved, the expenditure is reduced, the resource is uniformly unlocked when being unlocked, and the programming requirement of an application layer is greatly reduced.
In one embodiment of the present invention, the apparatus may further include:
the first judgment module is used for judging whether partial locking is allowed or not when the state information of each resource to be accessed is determined to be partially idle;
and the resource locking module 43 is further configured to perform unified locking on the part of the resources to be accessed, the state information of which is idle, when determining that partial locking is allowed.
In one embodiment of the present invention, the apparatus may further include:
the second judgment module is used for judging whether all the resources to be accessed are waited to be idle or not when the partial locking is determined not to be allowed;
the third judgment module is used for judging whether the target resource access request is crossed with other uncompleted resource access requests when all the resources to be accessed are determined to be idle;
the information output module is used for outputting locking failure prompt information when the target resource access request and other unfinished resource access requests have resource intersection;
the resource locking module 43 is specifically a module that performs unified locking on each resource to be accessed when it is determined that the status information of each resource to be accessed is idle after the target resource access request and other uncompleted resource access requests do not have resource intersection.
In an embodiment of the present invention, the third determining module includes:
the set type information acquisition submodule is used for acquiring set type information of a resource set to be accessed;
a third judgment sub-module, configured to, when the set type information is a quantity-limited resource set, convert a resource to be accessed in a resource set to be accessed, of which the state information is a non-idle state, into corresponding binary values according to a preset binary conversion table, perform an exclusive or operation on each binary value and a binary value corresponding to a locked resource of another uncompleted resource access request, and determine whether a target resource access request and another uncompleted resource access request have resource intersection according to an exclusive or operation result; when the set type information is an infinite resource set, the resource to be accessed, the state information of which is in a non-idle state, in the resource set to be accessed is converted into a character string with a corresponding suffix character string according to a suffix character string conversion table, the suffix character string of each character string is compared with the suffix character string of the character string corresponding to the locked resource of other unfinished resource access requests, and whether resource intersection exists between the target resource access request and other unfinished resource access requests is determined according to the comparison result.
In one embodiment of the present invention, the apparatus may further include:
the set type information determining module is used for determining target set type information to which the newly-added resources to be accessed belong when the newly-added resources to be accessed are acquired after the resources to be accessed are uniformly locked and the part of the resources to be accessed, the state information of which is idle, are uniformly locked when the state information of the resources to be accessed is determined to be idle;
and the resource adding module is used for adding the newly-added resources to be accessed into the collection lock corresponding to the target collection type information.
In one embodiment of the present invention, the apparatus may further include:
the fourth judging module is used for judging whether waiting time is overtime or not after determining that the target resource access request does not have resource intersection with other uncompleted resource access requests and before uniformly locking each resource to be accessed when determining that the state information of each resource to be accessed is idle;
and the information output module is also used for outputting a locking failure prompt message after the waiting timeout is determined.
The resource locking module 43 is specifically a module that performs unified locking on each resource to be accessed when it is determined that the waiting time is not overtime and the status information of each resource to be accessed is idle.
Corresponding to the above method embodiment, referring to fig. 5, fig. 5 is a schematic diagram of a shared resource access device provided in the present invention, where the device may include:
a memory 51 for storing a computer program;
the processor 52, when executing the computer program stored in the memory 51, may implement the following steps:
receiving a target resource access request, and analyzing the target resource access request to obtain a resource set to be accessed; respectively acquiring state information of each resource to be accessed in the resource set to be accessed; and when the state information of each resource to be accessed is determined to be idle, uniformly locking each resource to be accessed.
For the introduction of the device provided by the present invention, please refer to the above method embodiment, which is not described herein again.
Corresponding to the above method embodiment, the present invention further provides a computer-readable storage medium having a computer program stored thereon, the computer program, when executed by a processor, implementing the steps of:
receiving a target resource access request, and analyzing the target resource access request to obtain a resource set to be accessed; respectively acquiring state information of each resource to be accessed in the resource set to be accessed; and when the state information of each resource to be accessed is determined to be idle, uniformly locking each resource to be accessed.
The computer-readable storage medium may include: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
For the introduction of the computer-readable storage medium provided by the present invention, please refer to the above method embodiments, which are not described herein again.
The embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same or similar parts among the embodiments are referred to each other. The device, the apparatus and the computer-readable storage medium disclosed in the embodiments correspond to the method disclosed in the embodiments, so that the description is simple, and the relevant points can be referred to the description of the method.
The principle and the implementation of the present invention are explained in the present application by using specific examples, and the above description of the embodiments is only used to help understanding the technical solution and the core idea of the present invention. It should be noted that, for those skilled in the art, it is possible to make various improvements and modifications to the present invention without departing from the principle of the present invention, and those improvements and modifications also fall within the scope of the claims of the present invention.

Claims (10)

1. A method for shared resource access, comprising:
receiving a target resource access request, and analyzing the target resource access request to obtain a resource set to be accessed;
respectively acquiring state information of each resource to be accessed in the resource set to be accessed;
and when the state information of each resource to be accessed is determined to be idle, uniformly locking each resource to be accessed.
2. The shared resource access method of claim 1, further comprising:
when the state information of each resource to be accessed is determined to be partially idle, judging whether partial locking is allowed or not;
if so, uniformly locking the part of the resources to be accessed, the state information of which is idle.
3. The shared resource access method of claim 2, further comprising:
when partial locking is determined not to be allowed, judging whether all the resources to be accessed are waited to be idle or not;
if so, judging whether the target resource access request is crossed with other unfinished resource access requests or not;
if so, outputting a locking failure prompt message;
and if not, executing the step of uniformly locking the resources to be accessed when the state information of the resources to be accessed is determined to be idle.
4. The method of claim 3, wherein determining whether the target resource access request is resource crossed with other outstanding resource access requests comprises:
acquiring set type information of the resource set to be accessed;
when the set type information is a quantity-limited resource set, converting the resource to be accessed, of which the state information is in a non-idle state, in the resource set to be accessed into corresponding binary values according to a preset binary conversion table, performing exclusive-or operation on the binary values and the binary values corresponding to the locked resources of other uncompleted resource access requests respectively, and determining whether the target resource access request is crossed with the other uncompleted resource access requests according to the exclusive-or operation result;
when the set type information is an infinite resource set, converting the resource to be accessed, of which the state information is in a non-idle state, in the resource set to be accessed into character strings with corresponding suffix character strings according to a suffix character string conversion table, comparing the suffix character strings of the character strings with suffix character strings of character strings corresponding to locked resources of other uncompleted resource access requests respectively, and determining whether the target resource access request is crossed with the other uncompleted resource access requests according to the comparison result.
5. The method according to claim 4, wherein when it is determined that the state information of each of the resources to be accessed is idle, after performing unified locking on each of the resources to be accessed, and after performing unified locking on a part of the resources to be accessed whose state information is idle, the method further comprises:
when a newly-added resource to be accessed is obtained, determining target set type information to which the newly-added resource to be accessed belongs;
and adding the newly-added resources to be accessed into the collection lock corresponding to the target collection type information.
6. The method according to any one of claims 3 to 5, wherein after determining that there is no resource intersection between the target resource access request and other uncompleted resource access requests, before uniformly locking each of the resources to be accessed when it is determined that the status information of each of the resources to be accessed is idle, the method further comprises:
judging whether the waiting time is out;
if yes, executing the step of outputting the locking failure prompt message;
and if not, executing the step of uniformly locking the resources to be accessed when the state information of the resources to be accessed is determined to be idle.
7. A shared resource access apparatus, comprising:
the request analysis module is used for receiving a target resource access request and analyzing the target resource access request to obtain a resource set to be accessed;
the state information acquisition module is used for respectively acquiring the state information of each resource to be accessed in the resource set to be accessed;
and the resource locking module is used for uniformly locking each resource to be accessed when the state information of each resource to be accessed is determined to be idle.
8. The shared resource access device of claim 7, further comprising:
the first judgment module is used for judging whether partial locking is allowed or not when the state information of each resource to be accessed is determined to be partially idle;
and the resource locking module is also used for uniformly locking the part of the resources to be accessed, the state information of which is idle, when the part of the resources is determined to be allowed to be locked.
9. A shared resource access device, comprising:
a memory for storing a computer program;
a processor for implementing the steps of the shared resource access method of any one of claims 1 to 6 when executing said computer program.
10. A computer-readable storage medium, having stored thereon a computer program which, when being executed by a processor, carries out the steps of the shared resource access method according to any one of claims 1 to 6.
CN201911121525.XA 2019-11-15 2019-11-15 Shared resource access method, device, equipment and computer readable storage medium Pending CN110990161A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911121525.XA CN110990161A (en) 2019-11-15 2019-11-15 Shared resource access method, device, equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911121525.XA CN110990161A (en) 2019-11-15 2019-11-15 Shared resource access method, device, equipment and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN110990161A true CN110990161A (en) 2020-04-10

Family

ID=70084447

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911121525.XA Pending CN110990161A (en) 2019-11-15 2019-11-15 Shared resource access method, device, equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN110990161A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112231131A (en) * 2020-09-28 2021-01-15 北京金山云网络技术有限公司 Method, device and equipment for realizing database lock and readable storage medium
CN115220910A (en) * 2022-06-17 2022-10-21 中科驭数(北京)科技有限公司 Resource scheduling method, device and equipment
CN115220910B (en) * 2022-06-17 2024-04-19 中科驭数(北京)科技有限公司 Resource scheduling method, device and equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0296862A2 (en) * 1987-06-24 1988-12-28 Westinghouse Electric Corporation Multiprocessor information exchange
CN1945539A (en) * 2006-10-19 2007-04-11 华为技术有限公司 Method for distributing shared resource lock in computer cluster system and cluster system
CN101256509A (en) * 2008-04-07 2008-09-03 中兴通讯股份有限公司 Locking method, unlocking method and implementing method for lock mechanism
GB201015940D0 (en) * 2010-09-23 2010-11-03 Trinity College Dublin Distributed shared-memory system and method
CN107391278A (en) * 2017-07-25 2017-11-24 郑州云海信息技术有限公司 A kind of front and back end communication means based on shared drive

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0296862A2 (en) * 1987-06-24 1988-12-28 Westinghouse Electric Corporation Multiprocessor information exchange
CN1945539A (en) * 2006-10-19 2007-04-11 华为技术有限公司 Method for distributing shared resource lock in computer cluster system and cluster system
CN101256509A (en) * 2008-04-07 2008-09-03 中兴通讯股份有限公司 Locking method, unlocking method and implementing method for lock mechanism
GB201015940D0 (en) * 2010-09-23 2010-11-03 Trinity College Dublin Distributed shared-memory system and method
CN107391278A (en) * 2017-07-25 2017-11-24 郑州云海信息技术有限公司 A kind of front and back end communication means based on shared drive

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112231131A (en) * 2020-09-28 2021-01-15 北京金山云网络技术有限公司 Method, device and equipment for realizing database lock and readable storage medium
CN115220910A (en) * 2022-06-17 2022-10-21 中科驭数(北京)科技有限公司 Resource scheduling method, device and equipment
CN115220910B (en) * 2022-06-17 2024-04-19 中科驭数(北京)科技有限公司 Resource scheduling method, device and equipment

Similar Documents

Publication Publication Date Title
CN108572876B (en) Method and device for realizing read-write lock
CN105183852A (en) Database migration method and device
CN108416199A (en) A kind of user authority control method of application, device and server
KR101104985B1 (en) Method and system for generating random number
CN111444147A (en) Data page creating method and device, terminal equipment and storage medium
CN101763593A (en) Method and device for realizing audit log of system
CN110990161A (en) Shared resource access method, device, equipment and computer readable storage medium
CN109166199B (en) Password generation method, device and equipment
CN111553130A (en) Chapter title style conversion method and device, electronic equipment and storage medium
US7337252B2 (en) System and method for resolving conflicts of re-locking resources
CN112232025B (en) Character string storage method and device and electronic equipment
CN113961364A (en) Large-scale lock system implementation method and device, storage medium and server
CN112965745A (en) System access method, device, equipment and computer readable medium
CN110928672A (en) Task arranging method, device and equipment and storage medium
CN105930521A (en) Database management device and method
CN115396395B (en) Method and device for determining geographic position of IP address
CN105678637A (en) Data parsing system and application method thereof for vehicle charging posts
CN113051329B (en) Data acquisition method, device, equipment and storage medium based on interface
CN114465829B (en) Access time management method and device, electronic equipment and storage medium
CN113076178B (en) Message storage method, device and equipment
CN114020462A (en) Global identifier generation method, device, equipment and storage medium
CN113609352B (en) Character string retrieval method, device, computer equipment and storage medium
CN116880778B (en) User privacy protection method based on regenerative coding and distributed storage
CN113312549B (en) Domain name processing method and device
CN110990000B (en) Data request processing method, device and equipment of MVC pattern design model layer

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20200410