Method and device for solving deadlock of batch process data resources
By detecting and processing deadlocks in a parallel processing environment, identifying high-priority deadlock processes and executing interrupt mechanisms, resource competition and deadlock problems are solved, and the stability and response speed of the system are improved.
Patent Information
- Application Number
- CN202411716878.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-03-18
AI Technical Summary
In a parallel processing environment, since multiple modules access the same resource at the same time, resource competition and deadlock conflicts are caused, which in turn affects the stability and user experience of the system.
By obtaining the process resource allocation diagram, detect whether there is a data resource deadlock. If it exists, multiple deadlock processes will be identified. The highest priority deadlock process is found according to the program information table, marked as the target process, and the process is executed in combination with the preset time slice. When the target process has not been executed, the interrupt process is triggered to interrupt the process and store its basic information and required data resources in the interrupt program registration table. Regularly detect the interrupt program registration table. If the data resource lock flag is not locked, the corresponding process will be executed according to the data resource and the preset time slice until all processes have completed execution.
Effectively manage resource access, avoid deadlocks and resource exclusivity, improve system throughput and response speed, and ensure batch processes execution efficiency and system stability.
Smart Images

Figure CN119645675A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of database management, and in particular to a solution and device for batch process data resource deadlock. Background Art
[0002] As the level of enterprise informatization continues to improve, the business systems within many companies have gradually evolved from single applications to complex systems consisting of multiple functional modules. These modules collaborate through data sharing and resource access to achieve efficient operation of the system. However, as the functions of the system continue to expand, the data resource relationship between modules becomes more and more complex. In a parallel processing environment, multiple modules may access the same resource at the same time, resulting in resource competition and deadlock conflicts.
[0003] Current deadlock detection and prevention mechanisms mostly focus on monitoring the access status of resources, ignoring complex cross-access scenarios. In addition, batch processes usually occupy resources for a long time, resulting in resource locks not being released for a long time. Long-term resource occupation may cause other jobs to be blocked for a long time, especially when the number of jobs is large and the task execution time is long. This blocking effect will reduce system throughput and may cause a sharp drop in system performance, ultimately affecting system stability and user experience. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides a method and device for solving a batch process data resource deadlock problem, so as to efficiently identify, prevent and solve the deadlock problem.
[0005] To achieve the above objectives, the embodiments of the present invention provide the following technical solutions:
[0006] A first aspect of the present invention discloses a method for solving a batch process data resource deadlock problem, the method comprising:
[0007] Obtain a process resource allocation graph, and detect whether there is a data resource deadlock in the process resource allocation graph; the process resource allocation graph is pre-constructed according to the status of each process in the batch process;
[0008] If so, obtaining multiple deadlock processes corresponding to the data resource deadlock;
[0009] Searching for priorities of the plurality of deadlocked processes from a preset program information table;
[0010] Mark the deadlock process with the highest priority as the target process, obtain the data resources required by the target process, and execute the target process in combination with a preset time slice;
[0011] When the preset time slice ends and the target process has not been completed, triggering an interruption process to interrupt the target process;
[0012] Storing the basic information of the target process and the data resources required by the target process in an interrupt program registration table;
[0013] When it is periodically detected that the data resource lock flag of the data resource in the interrupt program registration table is in an unlocked state, the process corresponding to the data resource is executed according to the data resource and the preset time slice until all processes in the interrupt program registration table are executed.
[0014] Preferably, after marking the deadlock process with the highest priority as the target process, acquiring the data resources required by the target process, and executing the target process in combination with the preset time slice, the method further includes:
[0015] When the preset time slice ends and the target process is executed, periodically checking whether the data resource lock flag bit of the data resource in the interrupt program registration table is in an unlocked state;
[0016] If the data resource lock flag is in an unlocked state, the process corresponding to the data resource is executed according to the data resource and the preset time slice until all processes in the interrupt program registration table are executed.
[0017] Preferably, the triggering interruption process to interrupt the target process includes:
[0018] Triggering an interruption process, and determining the process number of the target process according to the program information table;
[0019] Generate an interrupt command based on the process number to interrupt the operating system process of the target process;
[0020] Acquire the resource ID of the data resource required by the target process from the program information table;
[0021] The database process of the target process is interrupted according to the resource ID.
[0022] Preferably, storing the basic information of the target process and the data resources required by the target process in an interrupt program registration table includes:
[0023] Obtaining the process ID of the target process and the resource ID of the data resource required by the target process;
[0024] Set the data resource lock flag of the resource ID to 1, where 1 indicates that the data resource lock flag is in a locked state;
[0025] The process ID, the resource ID and the data resource lock flag are stored to obtain an interrupt program registration table.
[0026] Preferably, the process of constructing the process resource allocation graph in advance according to the status of each process in the batch process includes:
[0027] For any process in the batch process, determining whether data resources required by the process are occupied by other processes in the batch process;
[0028] If the data resources required by the process are occupied by other processes in the batch process, an edge from the process to the other processes is drawn to obtain the process resource allocation graph;
[0029] If the data resources required by the process are not occupied by other processes in the batch process, then determining whether the data resources required by the process have been occupied by other processes in the batch process;
[0030] If the data resources required by the process have not been occupied by other processes in the batch process, then establishing a corresponding relationship between the process and the data resources required by the process;
[0031] If the data resources required by the process have been occupied by other processes in the batch process, determining whether there is an edge from the process to the other process;
[0032] If there is no edge from the process to the other process, a corresponding relationship between the process and the data resources required by the process is established to obtain the process resource allocation graph;
[0033] If there is an edge from the process to the other process, the edge from the process to the other process is deleted, and a corresponding relationship between the process and the data resources required by the process is established to obtain the process resource allocation graph.
[0034] A second aspect of the present invention discloses a device for resolving batch process data resource deadlock, the device comprising:
[0035] A first detection unit is used to obtain a process resource allocation graph and detect whether there is a data resource deadlock in the process resource allocation graph; the process resource allocation graph is pre-constructed according to the status of each process in the batch process;
[0036] an acquiring unit, configured to acquire a plurality of deadlock processes corresponding to the data resource deadlock, if any;
[0037] A searching unit, used for searching priorities of a plurality of deadlocked processes from a preset program information table;
[0038] A first execution unit, used for marking the deadlock process with the highest priority as a target process, obtaining data resources required by the target process, and executing the target process in combination with a preset time slice;
[0039] An interruption unit, configured to trigger an interruption procedure to interrupt the target process when the preset time slice ends and the target process has not been completed;
[0040] A storage unit, used for storing the basic information of the target process and the data resources required by the target process into an interrupt program registration table;
[0041] The second execution unit is used to execute the process corresponding to the data resource according to the data resource and the preset time slice when it is periodically detected that the data resource lock flag bit of the data resource in the interrupt program registration table is in an unlocked state, until all the processes in the interrupt program registration table are executed.
[0042] Preferably, it also includes:
[0043] A second detection unit is used to periodically detect whether the data resource lock flag bit of the data resource in the interrupt program registration table is in an unlocked state when the preset time slice ends and the target process is executed;
[0044] The third execution unit is used to execute the process corresponding to the data resource according to the data resource and the preset time slice if the data resource lock flag is in an unlocked state, until all processes in the interrupt program registration table are executed.
[0045] Preferably, the interruption unit comprises:
[0046] A determination module, used to trigger the interruption process and determine the process number of the target process according to the program information table;
[0047] A generating module, configured to generate an interrupt command based on the process number to interrupt the operating system process of the target process;
[0048] A first acquisition module, used for acquiring a resource ID of a data resource required by the target process from the program information table;
[0049] An interruption module is used to interrupt the database process of the target process according to the resource ID.
[0050] Preferably, the storage unit comprises:
[0051] A second acquisition module is used to acquire the process ID of the target process and the resource ID of the data resource required by the target process;
[0052] A setting module, used to set the data resource lock flag of the resource ID to 1, wherein 1 indicates that the data resource lock flag is in a locked state;
[0053] The storage module is used to store the process ID, the resource ID and the data resource lock flag to obtain an interrupt program registration table.
[0054] Preferably, it also includes:
[0055] A first judgment unit is used to judge, for any process in the batch process, whether data resources required by the process are occupied by other processes in the batch process;
[0056] a drawing unit, configured to draw an edge from the process to the other processes if the data resources required by the process are occupied by other processes in the batch process, so as to obtain the process resource allocation graph;
[0057] a second determining unit, configured to determine whether the data resources required by the process have been occupied by other processes in the batch process if the data resources required by the process have not been occupied by other processes in the batch process;
[0058] A first establishing unit, configured to establish a corresponding relationship between the process and the data resources required by the process if the data resources required by the process have not been occupied by other processes in the batch process;
[0059] A third judgment unit is used to judge whether there is an edge from the process to the other process if the data resources required by the process have been occupied by other processes in the batch process;
[0060] A second establishing unit is used for establishing a corresponding relationship between the process and the data resources required by the process if there is no edge from the process to the other process, so as to obtain the process resource allocation graph;
[0061] The deleting unit is used to delete the edge from the process to the other process if there is one, and establish a corresponding relationship between the process and the data resources required by the process to obtain the process resource allocation graph.
[0062] Based on the above-mentioned embodiment of the present invention, a method and device for solving the data resource deadlock of a batch process is provided, and a process resource allocation diagram is obtained to detect whether there is a data resource deadlock. If so, multiple deadlocked processes are identified. According to the program information table, the deadlocked process with the highest priority is used as the target process. The data resources required by the target process are obtained, and the process is executed in combination with a preset time slice. If the target process is not completed within the time slice, the interrupt mechanism is triggered, and the basic information of the target process and the required resources are saved in the interrupt program registration table. The process status in the interrupt program registration table is regularly checked. When the data resource lock flag bit required by a process is in an unlocked state, the corresponding process is scheduled for execution according to the preset time slice until all processes are executed. Through this method, resource access can be efficiently managed, deadlock and resource monopoly can be avoided, the throughput and response speed of the system can be improved, and the execution efficiency of batch processes and system stability can be ensured. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] In order to more clearly illustrate the embodiments of the present invention 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 invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0064] Figure 1 A schematic diagram of a directed ring of a process resource allocation graph provided by an embodiment of the present invention;
[0065] Figure 2 A flowchart of a method for solving a batch process data resource deadlock provided by an embodiment of the present invention;
[0066] Figure 3 A flowchart of a process resource allocation diagram for building a process provided by an embodiment of the present invention;
[0067] Figure 4 A flowchart of forcibly interrupting a target process by interrupting a process provided by an embodiment of the present invention;
[0068] Figure 5 A structural block diagram of a device for resolving batch process data resource deadlock provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0069] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0070] In this application, the terms "comprises", "comprising" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising 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 sentence "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element.
[0071] As can be seen from the background technology, in a batch process parallel processing environment, when multiple modules access the same resource at the same time, it is easy to cause resource competition and deadlock problems. Figure 1 As shown in , a directed loop is formed between process A, process B, process C, and process D. Existing deadlock detection and prevention mechanisms usually focus on monitoring resource access status, but ignore complex cross-access scenarios. In addition, batch processes usually occupy resources for a long time, resulting in resource locks not being released for a long time, which will cause other jobs to be blocked for a long time. Especially when the number of jobs is large and the task execution time is long, it may cause the system throughput to decrease and affect the system performance and stability.
[0072] Therefore, an embodiment of the present invention provides a solution and device for batch process data resource deadlock, which obtains a process resource allocation diagram to detect whether there is a data resource deadlock. If so, multiple deadlocked processes are identified. According to the program information table, the deadlocked process with the highest priority is used as the target process. The data resources required by the target process are obtained, and the process is executed in combination with a preset time slice. If the target process is not completed within the time slice, the interrupt mechanism is triggered, and the basic information of the target process and the required resources are saved in the interrupt program registration table. The process status in the interrupt program registration table is regularly checked. When the data resource lock flag bit required by a process is in an unlocked state, the corresponding process is scheduled for execution according to the preset time slice until all processes are executed. Through this method, resource access can be efficiently managed, deadlock and resource monopoly can be avoided, the throughput and response speed of the system can be improved, and the execution efficiency of batch processes and system stability can be ensured.
[0073] See also Figure 2 , shows a flow chart of a solution to batch process data resource deadlock provided by an embodiment of the present invention, which is applicable to the scenario where multiple batch processes access data resources simultaneously.
[0074] The method includes:
[0075] Step S201: Obtain a process resource allocation graph, and detect whether there is a data resource deadlock in the process resource allocation graph.
[0076] It should be noted that the process resource allocation diagram is pre-built according to the status of each process in the batch process. For details on the specific construction process, see the embodiment of the present invention. Figure 3 The content in.
[0077] In the specific implementation of step S201, a pre-built process resource allocation graph is obtained to detect whether there is a directed cycle in the process resource allocation graph, that is, a data resource deadlock. If there is a data resource deadlock in the process resource allocation graph, step S202 is executed; if there is no data resource deadlock in the process resource allocation graph, the current process ends.
[0078] Step S202: Acquire multiple deadlock processes corresponding to the data resource deadlock.
[0079] In the specific implementation of step S202, if there is a data resource deadlock in the process resource allocation graph, multiple deadlock processes corresponding to the data resource deadlock are obtained. In other words, multiple processes forming a directed ring in the process resource allocation graph are recorded as deadlock processes.
[0080] Step S203: searching the priorities of multiple deadlocked processes from a preset program information table.
[0081] It can be understood that the preset program information table includes but is not limited to the process ID of the batch process, process name, process number, resource ID of the data resources required by the process, process priority and process occupied time slice (i.e., the length of time the process occupies the data resources), etc.
[0082] In the specific process of implementing step S203, the priority of each deadlocked process is searched from a preset program information table.
[0083] It should be noted that, since data resource deadlock is a deadlock caused by competition for resources, without external force, all processes will be unable to proceed. Therefore, the embodiment of the present invention breaks this deadlock through a priority mechanism.
[0084] It is understandable that by introducing a priority mechanism to break data resource deadlock, it is possible to effectively avoid long waits for processes and reduce the chance of deadlock. High-priority tasks can obtain resources first, preventing resources from being occupied by low-priority processes for a long time, thereby improving resource utilization. In addition, priority scheduling can also optimize the system's throughput and response time, ensure that important or urgent tasks are processed in a timely manner, improve the overall performance and stability of the system, and further enable the system to adapt to different business needs, ensure efficient operation in a high-concurrency environment, and reduce the risk of deadlock.
[0085] Step S204: Mark the deadlock process with the highest priority as the target process, obtain the data resources required by the target process, and execute the target process in combination with the preset time slice.
[0086] In the specific implementation of step S204, the deadlock process with the highest priority among the multiple deadlock processes is marked as the target process, and the data resources required for the execution of the target process are obtained, and the target process is executed in combination with the data resources and the preset time slice.
[0087] It is understandable that the introduction of a preset time slice mechanism can effectively prevent processes from occupying resources for a long time and avoid blocking other processes, thereby improving system responsiveness, throughput, and fairness.
[0088] Specifically, by allocating a fixed preset time slice to each process, the system can achieve time sharing, ensure that each process has a chance to execute, reduce process starvation, and optimize resource allocation. In addition, the preset time slice mechanism can also improve the overall efficiency of the system, especially in a multi-tasking environment, to ensure the fairness of the system, avoid a process monopolizing resources, and support more efficient task scheduling.
[0089] Step S205: When the preset time slice ends and the target process is not completed, triggering an interruption process to interrupt the target process.
[0090] In the process of implementing step S205, if the preset time slice allocated to the target process ends but the target process has not been completed, an interruption process will be triggered to forcibly interrupt the execution of the target process.
[0091] It should be noted that the interruption target process is divided into two parts: the operating system process and the database process of the interruption target process. Therefore, the specific process of forcibly interrupting the target process through the interruption process is detailed in the embodiment of the present invention. Figure 4 The content in Figure 4 include:
[0092] Step S401: trigger the interruption process and determine the process number of the target process according to the program information table.
[0093] In the specific implementation of step S401, the interruption process is triggered, the program ID of the target process is queried from the program information table, and then the process number of the target process is found based on the program ID.
[0094] Step S402: Generate an interrupt command based on the process number to interrupt the operating system process of the target process.
[0095] In the specific implementation of step S402, an interrupt command (eg, a "kill -9 process number" command) is generated according to the process number of the target process, and the operating system process of the target process is interrupted by the interrupt command.
[0096] Step S403: Obtain the resource ID of the data resource required by the target process from the program information table.
[0097] In the specific implementation of step S403, the resource ID of the data resource required for the execution of the target process is obtained from the program information table.
[0098] Step S404: interrupting the database process of the target process according to the resource ID.
[0099] In the specific implementation of step S404, the database process of the data resource is obtained based on the current resource ID to interrupt the database process, thereby achieving the purpose of interrupting the database process of the target process.
[0100] It is understandable that dividing the interrupt target process into operating system processes and database processes helps improve the flexibility, performance, maintainability, and fault tolerance of the system. The operating system process focuses on system resource management and scheduling, while the database process focuses on data operations and transaction processing, thereby avoiding resource conflicts, improving efficiency, and reducing system load. This division of labor makes the system more adaptable, facilitates independent optimization and expansion, enhances system stability, and improves overall system performance.
[0101] Step S206: storing the basic information of the target process and the data resources required by the target process into the interrupt program registration table.
[0102] It is understandable that the interrupted target process will not be lost, and the relevant information is specifically saved in the interrupt program registration table. The interrupt program registration table includes but is not limited to the process ID of the interrupted process, the resource ID of the data resource that the process is waiting for (that is, the data resource required by the process), the data resource lock flag (0-unlocked state, 1-locked state) and the interrupt sequence number.
[0103] In the specific implementation of step S206, after the target process is interrupted, basic information of the target process and information of data resources required by the target process are obtained and stored in the interrupt program registration table.
[0104] Specifically, the process ID of the target process and the resource ID of the data resource required by the target process are obtained; the data resource lock flag of the resource ID is set to 1; the process ID, resource ID and data resource lock flag are stored to obtain an interrupt program registration table.
[0105] It should be noted that 1 indicates that the data resource lock flag is in a locked state.
[0106] It can be understood that when the high-priority process is executed and the data resources are released (the data resource lock flag is updated from 1 to 0), that is, when it is detected that the data resources that the process is waiting for in the interrupt program registration table are released (that is, when the data resource lock flag is 0), it is called up for execution according to the interrupt sequence number in the interrupt program registration table. For the specific process, please refer to the content in step S207.
[0107] Step S207: when it is periodically detected that the data resource lock flag of the data resource in the interrupt program registration table is in an unlocked state, the process corresponding to the data resource is executed according to the data resource and the preset time slice until all the processes in the interrupt program registration table are executed.
[0108] In the process of implementing step S207, when it is periodically detected that the data resource lock flag of the data resource in the interrupt program registration table is in an unlocked state (that is, the data resource lock flag is 0), the process corresponding to the data resource is executed according to the data resource and the preset time slice, that is, the interrupted process is restarted until all processes in the interrupt program registration table are executed.
[0109] It is understandable that there is a situation where the target process is executed within the preset time slice. In some specific embodiments, when the preset time slice ends and the target process is executed, the data resource lock flag bit of the data resource in the interrupt program registration table is periodically checked to see if it is in an unlocked state; if the data resource lock flag bit is in an unlocked state, the process corresponding to the data resource is executed according to the data resource and the preset time slice until all processes in the interrupt program registration table are executed.
[0110] That is, when the preset time slice ends and the target process is executed, the system can take appropriate actions according to the status of the current process. For example, if the target process has successfully completed its task, the system can immediately mark it as completed, release the occupied resources, and then schedule the next process.
[0111] In addition, if the target process is completed ahead of schedule and there are no subsequent tasks, the system can also perform appropriate optimizations, such as adjusting the execution time of the next process in advance to improve overall efficiency. At this time, through precise preset time slice management and resource scheduling, the efficient operation of the system can be ensured and unnecessary waiting or resource waste can be avoided.
[0112] In an embodiment of the present invention, the execution of batch processes is monitored in real time through deadlock detection, and deadlock problems are discovered and resolved in a timely manner. By setting the resource access priority of the process, deadlock caused by cross access is avoided. Processes with higher priorities are given priority to obtain resources to reduce conflicts; low-priority processes are interrupted and temporarily stored to avoid deadlock. This method also sets resource occupancy time slices and interrupt mechanisms. When a process occupies resources for a long time, a forced interrupt is triggered to avoid other processes from being blocked for a long time, thereby improving response speed and resource utilization. The interrupted process information is saved in the interrupt registration table, and the process is scheduled in sequence after the resource lock is released to ensure the execution order and data integrity. These designs effectively manage resource access, avoid deadlock and resource monopoly, and improve the execution efficiency and stability of batch processes.
[0113] The process of constructing a process resource allocation diagram according to the status of each process in the batch process in advance as proposed in the above embodiment of the present invention is described in detail in the embodiment of the present invention. Figure 3 The content in Figure 3 include:
[0114] It should be noted that, combined with Figure 1 The content in Figure 3 Provide explanation.
[0115] Step S301: for any process in the batch process, determine whether the data resources required by the process are occupied by other processes in the batch process. If the data resources required by the process are occupied by other processes in the batch process, execute step S302; if the data resources required by the process are not occupied by other processes in the batch process, execute step S303.
[0116] In the specific implementation of step S301, for any process (such as process A) in the batch process, it is determined whether the data resources required by the process (such as process A) are occupied by other processes (such as process B) in the batch process.
[0117] Step S302: If the data resources required by the process are occupied by other processes in the batch process, edges pointing from the process to other processes are drawn to obtain a process resource allocation graph.
[0118] In the process of implementing step S302, if the data resources required by a process (such as process A) are occupied by other processes in the batch process (such as process B), edges pointing from the process to other processes are drawn (such as the edge from process A to process B) to obtain a process resource allocation graph.
[0119] Step S303: If the data resources required by the process are not occupied by other processes in the batch process, it is determined whether the data resources required by the process have been occupied by other processes in the batch process. If the data resources required by the process have not been occupied by other processes in the batch process, step S304 is executed; if the data resources required by the process have been occupied by other processes in the batch process, step S305 is executed.
[0120] In the process of specifically implementing step S303, if the data resources required by the process are not occupied by other processes in the batch process, it is determined whether the data resources required by the process have been occupied by other processes in the batch process.
[0121] For example: if the data resources required by process A are not occupied by process B, then determine whether the data resources required by process A have been occupied by process B.
[0122] Step S304: If the data resources required by the process have not been occupied by other processes in the batch process, a corresponding relationship between the process and the data resources required by the process is established.
[0123] For example: if the data resources required by process A have not been occupied by process B, a corresponding relationship between the process (such as process A) and the data resources required by the process is established.
[0124] Step S305: If the data resources required by the process have been occupied by other processes in the batch process, determine whether there is an edge from the process to other processes. If there is no edge from the process to other processes, execute step S306; if there is an edge from the process to other processes, execute step S307.
[0125] For example: If the data resources required by process A have been occupied by process B, then determine whether there is an edge from one process to another in the process resource allocation graph, that is, whether there is an edge from process A to process B.
[0126] Step S306: If there is no edge from one process to another process, a corresponding relationship between the process and the data resources required by the process is established to obtain a process resource allocation graph.
[0127] In the process of implementing step S306, if there is no edge from one process to another process (that is, there is no edge from process A to process B), a correspondence is established between the process (such as process A) and the data resources required by the process to obtain a process resource allocation graph.
[0128] Step S307: If there are edges from a process to other processes, delete the edges from the process to other processes, and establish a corresponding relationship between the process and the data resources required by the process to obtain a process resource allocation graph.
[0129] In the process of implementing step S307, if there are edges from processes pointing to other processes (that is, there are edges from process A pointing to process B), the edges from processes pointing to other processes are deleted (that is, the edges from process A pointing to process B are deleted), and a correspondence is established between the process (such as process A) and the data resources required by the process to obtain a process resource allocation graph.
[0130] In an embodiment of the present invention, constructing a process resource allocation graph helps to provide an intuitive, dynamic, and original code-free way to detect data resource deadlocks in the system. By graphically representing the resource allocation relationship between threads, loops in resource requests and allocations can be clearly found, thereby determining whether data resource deadlocks occur. This method is not only applicable to multi-threaded environments, but also helps developers understand the causes of deadlocks, take preventive measures or solutions, and improve the stability and reliability of the system.
[0131] Corresponding to the solution to the deadlock of batch process data resources provided by the above embodiment of the present invention, see Figure 5 , shows a structural block diagram of a device for resolving a batch process data resource deadlock provided by an embodiment of the present invention, the device comprising: a first detection unit 501, an acquisition unit 502, a search unit 503, a first execution unit 504, an interruption unit 505, a storage unit 506 and a second execution unit 507.
[0132] The first detection unit 501 is used to obtain a process resource allocation graph and detect whether there is a data resource deadlock in the process resource allocation graph; the process resource allocation graph is pre-constructed according to the status of each process in the batch process.
[0133] The acquisition unit 502 is used to acquire multiple deadlock processes corresponding to the data resource deadlock, if any.
[0134] The searching unit 503 is used to search the priorities of multiple deadlocked processes from a preset program information table.
[0135] The first execution unit 504 is used to mark the deadlock process with the highest priority as a target process, obtain data resources required by the target process, and execute the target process in combination with a preset time slice.
[0136] The interruption unit 505 is used to trigger an interruption procedure to interrupt the target process when the preset time slice ends and the target process has not been completed.
[0137] The storage unit 506 is used to store the basic information of the target process and the data resources required by the target process into the interrupt program registration table.
[0138] The second execution unit 507 is used to execute the process corresponding to the data resource according to the data resource and the preset time slice when it is periodically detected that the data resource lock flag bit of the data resource in the interrupt program registration table is in the unlocked state, until all the processes in the interrupt program registration table are executed.
[0139] In an embodiment of the present invention, the execution of batch processes is monitored in real time through deadlock detection, and deadlock problems are discovered and resolved in a timely manner. By setting the resource access priority of the process, deadlock caused by cross access is avoided. Processes with higher priorities are given priority to obtain resources to reduce conflicts; low-priority processes are interrupted and temporarily stored to avoid deadlock. This method also sets resource occupancy time slices and interrupt mechanisms. When a process occupies resources for a long time, a forced interrupt is triggered to avoid other processes from being blocked for a long time, thereby improving response speed and resource utilization. The interrupted process information is saved in the interrupt registration table, and the process is scheduled in sequence after the resource lock is released to ensure the execution order and data integrity. These designs effectively manage resource access, avoid deadlock and resource monopoly, and improve the execution efficiency and stability of batch processes.
[0140] Combination Figure 5 According to the content shown, the device also includes: a second detection unit and a third execution unit.
[0141] The second detection unit is used to periodically detect whether the data resource lock flag bit of the data resource in the interrupt program registration table is in an unlocked state when the preset time slice ends and the target process is executed.
[0142] The third execution unit is used to execute the process corresponding to the data resource according to the data resource and the preset time slice if the data resource lock flag is in the unlocked state, until all the processes in the interrupt program registration table are executed.
[0143] Combination Figure 5 The content shown, the interruption unit 505 includes: a determination module, a generation module, a first acquisition module and an interruption module.
[0144] The determination module is used to trigger the interruption process and determine the process number of the target process according to the program information table.
[0145] A generation module is used to generate an interrupt command based on a process number to interrupt the operating system process of a target process.
[0146] The first acquisition module is used to acquire the resource ID of the data resource required by the target process from the program information table.
[0147] The interrupt module is used to interrupt the database process of the target process according to the resource ID.
[0148] Combination Figure 5The content shown, the storage unit 506, includes: a second acquisition module, a setting module and a storage module.
[0149] The second acquisition module is used to acquire the process ID of the target process and the resource ID of the data resource required by the target process.
[0150] The setting module is used to set the data resource lock flag bit of the resource ID to 1, wherein 1 indicates that the data resource lock flag bit is in a locked state.
[0151] The storage module is used to store the process ID, resource ID and data resource lock flag to obtain an interrupt program registration table.
[0152] Combination Figure 5 According to the content shown, the device also includes: a first judging unit, a drawing unit, a second judging unit, a first establishing unit, a third judging unit, a second establishing unit and a deleting unit.
[0153] The first judgment unit is used to judge, for any process in the batch process, whether data resources required by the process are occupied by other processes in the batch process.
[0154] The drawing unit is used to draw the edge from the process to other processes if the data resources required by the process are occupied by other processes in the batch process, so as to obtain a process resource allocation graph.
[0155] The second judgment unit is used to judge whether the data resources required by the process have been occupied by other processes in the batch process if the data resources required by the process have not been occupied by other processes in the batch process.
[0156] The first establishing unit is used to establish a corresponding relationship between a process and the data resources required by the process if the data resources required by the process have not been occupied by other processes in the batch process.
[0157] The third judgment unit is used to judge whether there is an edge from the process to other processes if the data resources required by the process have been occupied by other processes in the batch process.
[0158] The second establishing unit is used to establish a corresponding relationship between a process and data resources required by the process if there is no edge from the process to other processes, so as to obtain a process resource allocation graph.
[0159] The deletion unit is used to delete the edge from the process to other processes if there is one, and to establish a corresponding relationship between the process and the data resources required by the process to obtain a process resource allocation graph.
[0160] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can refer to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system or system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiment. The system and system embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without creative work.
[0161] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0162] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A solution to batch process data resource deadlock, characterized in that: The method comprises: Obtain a process resource allocation graph, and detect whether there is a data resource deadlock in the process resource allocation graph; the process resource allocation graph is pre-constructed according to the status of each process in the batch process; If so, obtaining multiple deadlock processes corresponding to the data resource deadlock; Searching for priorities of the plurality of deadlocked processes from a preset program information table; Mark the deadlock process with the highest priority as the target process, obtain the data resources required by the target process, and execute the target process in combination with a preset time slice; When the preset time slice ends and the target process has not been completed, triggering an interruption process to interrupt the target process; Storing the basic information of the target process and the data resources required by the target process in an interrupt program registration table; When it is periodically detected that the data resource lock flag of the data resource in the interrupt program registration table is in an unlocked state, the process corresponding to the data resource is executed according to the data resource and the preset time slice until all processes in the interrupt program registration table are executed.
2. The method according to claim 1, characterized in that Marking the deadlock process with the highest priority as a target process, acquiring data resources required by the target process, and executing the target process in combination with a preset time slice, further comprising: When the preset time slice ends and the target process is executed, periodically checking whether the data resource lock flag bit of the data resource in the interrupt program registration table is in an unlocked state; If the data resource lock flag is in an unlocked state, the process corresponding to the data resource is executed according to the data resource and the preset time slice until all processes in the interrupt program registration table are executed.
3. The method according to claim 1, characterized in that The triggering interruption process to interrupt the target process includes: Triggering an interruption process, and determining the process number of the target process according to the program information table; Generate an interrupt command based on the process number to interrupt the operating system process of the target process; Acquire the resource ID of the data resource required by the target process from the program information table; The database process of the target process is interrupted according to the resource ID.
4. The method according to claim 1, characterized in that: The storing of the basic information of the target process and the data resources required by the target process into the interrupt program registration table includes: Obtaining the process ID of the target process and the resource ID of the data resource required by the target process; Set the data resource lock flag of the resource ID to 1, where 1 indicates that the data resource lock flag is in a locked state; The process ID, the resource ID and the data resource lock flag are stored to obtain an interrupt program registration table.
5. The method according to claim 1, characterized in that The process of constructing the process resource allocation graph in advance according to the status of each process in the batch process includes: For any process in the batch process, determining whether data resources required by the process are occupied by other processes in the batch process; If the data resources required by the process are occupied by other processes in the batch process, an edge from the process to the other processes is drawn to obtain the process resource allocation graph; If the data resources required by the process are not occupied by other processes in the batch process, then determining whether the data resources required by the process have been occupied by other processes in the batch process; If the data resources required by the process have not been occupied by other processes in the batch process, then establishing a corresponding relationship between the process and the data resources required by the process; If the data resources required by the process have been occupied by other processes in the batch process, determining whether there is an edge from the process to the other process; If there is no edge from the process to the other process, a corresponding relationship between the process and the data resources required by the process is established to obtain the process resource allocation graph; If there is an edge from the process to the other process, the edge from the process to the other process is deleted, and a corresponding relationship between the process and the data resources required by the process is established to obtain the process resource allocation graph.
6. A device for resolving batch process data resource deadlock, characterized in that: The device comprises: A first detection unit is used to obtain a process resource allocation graph and detect whether there is a data resource deadlock in the process resource allocation graph; the process resource allocation graph is pre-constructed according to the status of each process in the batch process; an acquiring unit, configured to acquire a plurality of deadlock processes corresponding to the data resource deadlock, if any; A searching unit, used for searching priorities of a plurality of deadlocked processes from a preset program information table; A first execution unit, used for marking the deadlock process with the highest priority as a target process, obtaining data resources required by the target process, and executing the target process in combination with a preset time slice; An interruption unit, configured to trigger an interruption procedure to interrupt the target process when the preset time slice ends and the target process has not been completed; A storage unit, used for storing the basic information of the target process and the data resources required by the target process into an interrupt program registration table; The second execution unit is used to execute the process corresponding to the data resource according to the data resource and the preset time slice when it is periodically detected that the data resource lock flag bit of the data resource in the interrupt program registration table is in an unlocked state, until all the processes in the interrupt program registration table are executed.
7. The device according to claim 6, characterized in that Also includes: A second detection unit is used to periodically detect whether the data resource lock flag bit of the data resource in the interrupt program registration table is in an unlocked state when the preset time slice ends and the target process is executed; The third execution unit is used to execute the process corresponding to the data resource according to the data resource and the preset time slice if the data resource lock flag is in an unlocked state, until all processes in the interrupt program registration table are executed.
8. The device according to claim 6, characterized in that The interruption unit comprises: A determination module, used to trigger the interruption process and determine the process number of the target process according to the program information table; A generating module, configured to generate an interrupt command based on the process number to interrupt the operating system process of the target process; A first acquisition module, used for acquiring a resource ID of a data resource required by the target process from the program information table; An interruption module is used to interrupt the database process of the target process according to the resource ID.
9. The device according to claim 6, characterized in that The storage unit comprises: A second acquisition module is used to acquire the process ID of the target process and the resource ID of the data resource required by the target process; A setting module, used to set the data resource lock flag of the resource ID to 1, wherein 1 indicates that the data resource lock flag is in a locked state; The storage module is used to store the process ID, the resource ID and the data resource lock flag to obtain an interrupt program registration table.
10. The device according to claim 6, characterized in that Also includes: A first judgment unit is used to judge, for any process in the batch process, whether data resources required by the process are occupied by other processes in the batch process; a drawing unit, configured to draw an edge from the process to the other processes if the data resources required by the process are occupied by other processes in the batch process, so as to obtain the process resource allocation graph; a second determining unit, configured to determine whether the data resources required by the process have been occupied by other processes in the batch process if the data resources required by the process have not been occupied by other processes in the batch process; A first establishing unit, configured to establish a corresponding relationship between the process and the data resources required by the process if the data resources required by the process have not been occupied by other processes in the batch process; A third judgment unit is used to judge whether there is an edge from the process to the other process if the data resources required by the process have been occupied by other processes in the batch process; A second establishing unit is used for establishing a corresponding relationship between the process and the data resources required by the process if there is no edge from the process to the other process, so as to obtain the process resource allocation graph; The deleting unit is used to delete the edge from the process to the other process if there is one, and establish a corresponding relationship between the process and the data resources required by the process to obtain the process resource allocation graph.