A deadlock detection method, system, device and readable storage medium
By performing hash operation and record table judgment on the lock address information in multi-core programming, the problem of deadlock detection is solved, the deadlock location is quickly located, and the problem repair efficiency and system stability are improved.
Patent Information
- Application Number
- CN202010616572.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-30
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2040-06-30
AI Technical Summary
In multi-core programming, due to the introduction of the lock mechanism, it is difficult for operation and maintenance personnel to quickly detect the location of a deadlock when a deadlock occurs, which affects the efficiency of problem repair.
By obtaining the address information of the lock after the locking operation, performing a hash operation to obtain the hash value, and determining whether the hash value exists in the preset record table. If it exists, determine the location where the deadlock occurred. If it does not exist, determine the location where the deadlock occurred. If there is, it is stored in the record table, and the corresponding relationship is deleted when unlocking. The deadlock position is determined based on the relationship where the storage time exceeds the threshold.
It realizes the rapid detection of the deadlock position when a deadlock occurs, improves the efficiency of problem repair, and improves the stability of the operating system and product quality.
Smart Images

Figure CN111858075B
Abstract
Description
Technical Field
[0001] The present application relates to the field of deadlock detection, and in particular to a deadlock detection method, system, device and readable storage medium. Background Art
[0002] In modern operating systems and software development, multi-core concurrent programs have been widely used in practical applications due to their advantages such as high resource utilization and fast computing speed. However, due to the uncertainty and complexity of multi-core concurrent behavior, its development and maintenance are more difficult than single-core. Therefore, in multi-core programming, in order to ensure the consistency of data operations, the operating system introduces a lock mechanism to ensure the security of critical section code.
[0003] However, the introduction of the lock mechanism also leads to the risk of operating system deadlock. The uncertainty of running programs on multi-core processors often leads to deadlock. When deadlock occurs, it often takes a long time for operation and maintenance personnel to detect the location of the deadlock, which greatly affects the efficiency of problem repair.
[0004] Therefore, how to quickly detect the location where the deadlock occurs when the deadlock occurs is a technical problem that those skilled in the art need to solve at present. Summary of the invention
[0005] The purpose of the present application is to provide a deadlock detection method, system, device and readable storage medium, which are used to quickly detect the location where the deadlock occurs when the deadlock occurs.
[0006] In order to solve the above technical problems, the present application provides a deadlock detection method, which includes:
[0007] After the lock operation is performed, the lock address information is obtained;
[0008] Performing a hash operation on the address information to obtain a corresponding hash value;
[0009] Determine whether the hash value is stored in a preset record table;
[0010] If so, the location where the deadlock occurs is determined according to the address information corresponding to the hash value.
[0011] Optionally, when the hash value is not stored in the preset record table, the method further includes:
[0012] The corresponding relationship between the hash value and the address information is stored in the preset record table.
[0013] Optionally, also include:
[0014] When the unlocking operation is performed, the corresponding relationship between the address information to be unlocked and the hash value in the preset record table is deleted.
[0015] Optionally, also include:
[0016] Obtaining the storage time of all corresponding relationships in the preset record table;
[0017] The location where the deadlock occurs is determined according to the corresponding relationship that the storage time exceeds the threshold.
[0018] The present application also provides a deadlock detection system, the system comprising:
[0019] A first acquisition module, used to acquire the address information of the lock after the locking operation is performed;
[0020] A calculation module, used for performing a hash operation on the address information to obtain a corresponding hash value;
[0021] A judging module, used to judge whether the hash value is stored in a preset record table;
[0022] The first determination module is used to determine the location where the deadlock occurs according to the address information corresponding to the hash value when the hash value is stored in the preset record table.
[0023] Optionally, also include:
[0024] A storage module is used to store the corresponding relationship between the hash value and the address information in the preset record table when the hash value is not stored in the preset record table.
[0025] Optionally, also include:
[0026] The deleting module is used to delete the corresponding relationship between the address information to be unlocked and the hash value in the preset record table when performing an unlocking operation.
[0027] Optionally, also include:
[0028] A second acquisition module is used to acquire the storage time of all corresponding relationships in the preset record table;
[0029] The second determining module is used to determine the location where the deadlock occurs according to the corresponding relationship that the storage time exceeds the threshold.
[0030] The present application also provides a deadlock detection device, the deadlock detection device comprising:
[0031] Memory for storing computer programs;
[0032] A processor is used to implement the steps of any of the above-mentioned deadlock detection methods when executing the computer program.
[0033] The present application also provides a readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the deadlock detection method as described in any one of the above items are implemented.
[0034] The deadlock detection method provided in the present application includes: obtaining the address information of the lock after performing a locking operation; performing a hash operation on the address information to obtain a corresponding hash value; determining whether the hash value is stored in a preset record table; if so, determining the location where the deadlock occurs based on the address information corresponding to the hash value.
[0035] The technical solution provided by the present application obtains the address information of the lock after the locking operation, and then performs a hash operation on the address information to obtain the corresponding hash value. When the hash value is stored in the preset record table, it indicates that the lock has been locked before, and locking again causes a deadlock. At this time, the location where the deadlock occurs is determined according to the address information corresponding to the hash value. The present application detects the deadlock that occurs by using a hash algorithm and records the deadlock information, so that the location where the deadlock occurs can be quickly detected when the deadlock occurs, thereby improving the efficiency of problem repair, the quality of the product and the stability of the operating system. The present application also provides a deadlock detection system, device and readable storage medium, which have the above-mentioned beneficial effects and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0037] Figure 1 A flowchart of a deadlock detection method provided in an embodiment of the present application;
[0038] Figure 2 A structural diagram of a deadlock detection system provided in an embodiment of the present application;
[0039] Figure 3 A structural diagram of another deadlock detection system provided in an embodiment of the present application;
[0040] Figure 4 A structural diagram of a deadlock detection device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0041] The core of the present application is to provide a deadlock detection method, system, device and readable storage medium, which are used to quickly detect the location where the deadlock occurs when the deadlock occurs.
[0042] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0043] Please refer to Figure 1 , Figure 1 A flowchart of a deadlock detection method provided in an embodiment of the present application.
[0044] It specifically includes the following steps:
[0045] S101: After performing a locking operation, the address information of the lock is obtained;
[0046] In multi-threaded programming, the operating system introduces a lock mechanism, which can ensure that in a multi-core multi-threaded environment, only one thread can enter the critical section code at a certain point in time, thereby ensuring the consistency of the operation data in the critical section.
[0047] The introduction of the lock mechanism leads to the risk of deadlock in the operating system. The uncertainty of running programs on multi-core processors often leads to deadlock. When a deadlock occurs, it often takes a long time for operation and maintenance personnel to detect the location where the deadlock occurs, which greatly affects the efficiency of problem repair. Therefore, this application provides a deadlock detection method to solve the above problem.
[0048] S102: Perform a hash operation on the address information to obtain a corresponding hash value;
[0049] In this step, the address information is hashed to obtain the corresponding hash value in order to obtain a hash value uniquely corresponding to the address information, and then determine whether the lock corresponding to the address information has been locked before based on the hash value, and then determine whether this locking operation has caused a deadlock.
[0050] S103: Determine whether the hash value is stored in the preset record table;
[0051] If yes, proceed to step S104;
[0052] When a hash value is stored in the preset record table, it indicates that a locking operation has been performed before this locking operation, and this locking operation must have caused a deadlock. At this time, step S104 is executed to determine the location where the deadlock occurred according to the address information corresponding to the hash value, so that the operation and maintenance personnel can locate the location where the deadlock occurred in time, thereby improving the efficiency of problem repair.
[0053] Optionally, when there is no hash value stored in the preset record table, it indicates that no locking operation has been performed before this locking operation, and this locking operation cannot cause deadlock. At this time, the correspondence between the hash value and the address information can also be stored in the preset record table to indicate that the locking operation has been performed at the location of the current address information.
[0054] Optionally, when performing an unlocking operation, the corresponding relationship between the address information to be unlocked and the hash value in the preset record table may also be deleted to reduce the impact of the unlocked address information on the deadlock detection.
[0055] Optionally, when the corresponding relationship in the preset record table still exists, it indicates that the lock has not been unlocked. It is very likely that a deadlock is caused by waiting for other locks. At this time, the following steps can also be performed to determine the location where the deadlock occurs:
[0056] Get the storage time of all corresponding relationships in the preset record table;
[0057] The location where the deadlock occurs is determined according to the corresponding relationship that the storage time exceeds the threshold.
[0058] S104: Determine the location where the deadlock occurs according to the address information corresponding to the hash value.
[0059] Optionally, after determining the location where the deadlock occurs, the location where the deadlock occurs may be sent as prompt information to a preset location (such as a mailbox, a mailbox, etc.) so that operation and maintenance personnel can repair the deadlock in time.
[0060] Based on the above technical solution, a deadlock detection method provided by the present application obtains the address information of the lock after the locking operation, and then performs a hash operation on the address information to obtain a corresponding hash value. When the hash value is stored in the preset record table, it indicates that the lock has been locked before, and locking again causes a deadlock. At this time, the location where the deadlock occurs is determined according to the address information corresponding to the hash value. The present application detects the deadlock by using a hash algorithm and records the deadlock information, so that the location where the deadlock occurs can be quickly detected when the deadlock occurs, thereby improving the efficiency of problem repair, improving the quality of the product and the stability of the operating system.
[0061] Please refer to Figure 2 , Figure 2 A structural diagram of a deadlock detection system provided in an embodiment of the present application.
[0062] The system may include:
[0063] A first acquisition module 100 is used to acquire the address information of the lock after the locking operation is performed;
[0064] The operation module 200 is used to perform a hash operation on the address information to obtain a corresponding hash value;
[0065] A determination module 300, used to determine whether a hash value is stored in a preset record table;
[0066] The first determination module 400 is used to determine the location where the deadlock occurs according to the address information corresponding to the hash value when the hash value is stored in the preset record table.
[0067] Please refer to Figure 3 , Figure 3 A structural diagram of another deadlock detection system provided in an embodiment of the present application.
[0068] The system may also include:
[0069] The storage module is used to store the corresponding relationship between the hash value and the address information in the preset record table when the hash value is not stored in the preset record table.
[0070] The system may also include:
[0071] The deletion module is used to delete the corresponding relationship between the address information to be unlocked and the hash value in the preset record table when performing the unlocking operation.
[0072] The system may also include:
[0073] The second acquisition module is used to acquire the storage time of all corresponding relationships in the preset record table;
[0074] The second determination module is used to determine the location where the deadlock occurs according to the corresponding relationship that the storage time exceeds the threshold.
[0075] Since the embodiments of the system part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the system part, which will not be repeated here.
[0076] Please refer to Figure 4 , Figure 4 A structural diagram of a deadlock detection device provided in an embodiment of the present application.
[0077] The deadlock detection device 400 may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 422 (for example, one or more processors) and memory 432, one or more storage media 430 (for example, one or more mass storage devices) storing application programs 442 or data 444. Among them, the memory 432 and the storage medium 430 can be temporary storage or permanent storage. The program stored in the storage medium 430 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the device. Furthermore, the processor 422 can be configured to communicate with the storage medium 430 to execute a series of instruction operations in the storage medium 430 on the deadlock detection device 400.
[0078] The deadlock detection device 400 may also include one or more power supplies 424, one or more wired or wireless network interfaces 450, one or more input and output interfaces 458, and / or, one or more operating systems 441, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
[0079] Above Figure 1 The steps in the deadlock detection method described are performed by the deadlock detection device based on the Figure 4 The structure shown is implemented.
[0080] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and modules described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0081] In the several embodiments provided in the present application, it should be understood that the disclosed devices, equipment and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of modules is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.
[0082] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0083] In addition, each functional module in each embodiment of the present application can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated modules can be implemented in the form of hardware or software functional modules.
[0084] If the integrated module is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a function calling device, or a network device, etc.) to execute all or part of the steps of each embodiment method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program code.
[0085] The above is a detailed introduction to a deadlock detection method, system, device and readable storage medium provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core ideas of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.
[0086] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
Claims
1. A deadlock detection method, characterized in that: include: After the lock operation is performed, the lock address information is obtained; Performing a hash operation on the address information to obtain a corresponding hash value; Determine whether the hash value is stored in a preset record table; If yes, determine the location where the deadlock occurs according to the address information corresponding to the hash value; If not, storing the corresponding relationship between the hash value and the address information in the preset record table; Also includes: When the unlocking operation is performed, the corresponding relationship between the address information to be unlocked and the hash value in the preset record table is deleted; Also includes: Obtaining the storage time of all corresponding relationships in the preset record table; Determine the location where the deadlock occurs according to the corresponding relationship that the storage time exceeds the threshold; Also includes: The location where the deadlock occurs is sent as a prompt message to a preset location so that the operation and maintenance personnel can repair the deadlock in time.
2. A deadlock detection system, characterized in that: include: A first acquisition module, used to acquire the address information of the lock after the locking operation is performed; A calculation module, used for performing a hash operation on the address information to obtain a corresponding hash value; A judging module, used to judge whether the hash value is stored in a preset record table; A first determination module, configured to determine a deadlock occurrence location according to address information corresponding to the hash value when the hash value is stored in the preset record table; Also includes: A storage module, configured to store the corresponding relationship between the hash value and the address information in the preset record table when the hash value is not stored in the preset record table; A deletion module, used to delete the correspondence between the address information to be unlocked and the hash value in the preset record table when performing an unlocking operation; A second acquisition module is used to acquire the storage time of all corresponding relationships in the preset record table; A second determination module, configured to determine a location where a deadlock occurs according to a corresponding relationship that the storage time exceeds a threshold; The location where the deadlock occurs is sent as a prompt message to a preset location so that the operation and maintenance personnel can repair the deadlock in time.
3. A deadlock detection device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the deadlock detection method as claimed in claim 1 when executing the computer program.
4. A readable storage medium, characterized in that: The readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the deadlock detection method according to claim 1 are implemented.
