CN112162845A - Method and device for synchronizing business processes - Google Patents

Method and device for synchronizing business processes Download PDF

Info

Publication number
CN112162845A
CN112162845A CN202011192025.8A CN202011192025A CN112162845A CN 112162845 A CN112162845 A CN 112162845A CN 202011192025 A CN202011192025 A CN 202011192025A CN 112162845 A CN112162845 A CN 112162845A
Authority
CN
China
Prior art keywords
mutex
new
name
service process
target
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.)
Granted
Application number
CN202011192025.8A
Other languages
Chinese (zh)
Other versions
CN112162845B (en
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 North Source Software Co ltd
Original Assignee
Beijing North Source Software 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 North Source Software Co ltd filed Critical Beijing North Source Software Co ltd
Priority to CN202011192025.8A priority Critical patent/CN112162845B/en
Publication of CN112162845A publication Critical patent/CN112162845A/en
Application granted granted Critical
Publication of CN112162845B publication Critical patent/CN112162845B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/485Task life-cycle, e.g. stopping, restarting, resuming execution
    • 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/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Telephonic Communication Services (AREA)

Abstract

The embodiment of the invention provides a method and a device for synchronizing business processes. Wherein, the method comprises the following steps: detecting whether the time of using the mutex by the current business process exceeds a preset time threshold value of waiting for the mutex by the business process, if so, generating a new mutex name according to a preset mutex naming rule; calling a new mutex to access a target resource according to the name of the new mutex; and the new mutex corresponds to the target resource and is used for coordinating the service process to access the target resource in a mutex manner. By adopting the method for synchronizing the service processes disclosed by the embodiment of the invention, the conditions that other processes of the whole system are jammed or jammed and the like because one process is not released in time after acquiring the mutex signal when a plurality of processes in the system are synchronously operated can be effectively avoided, so that each process can smoothly operate, and the operation efficiency of the system is improved.

Description

Method and device for synchronizing business processes
Technical Field
The invention relates to the technical field of computer application, in particular to a method and a device for synchronizing business processes. In addition, an electronic device and a non-transitory computer readable storage medium are also related.
Background
In recent years, with the rapid development of information technology and the internet, the application of software systems in computers is becoming more and more popular. In the application process, when each process in the software system realizes synchronous operation, there are many synchronous operations, for example, there is a situation that a plurality of processes synchronously access a common data resource. Therefore, the concept of mutexes (also called mutexes) is introduced, and corresponding mutexes are set for system data resources respectively to ensure the integrity of the operation of the system data resources. This flag can ensure that only one process can access the system data resource at any one time.
However, in the environment of multithread synchronous operation, there is a certain hidden danger when the multiple processes access the shared data resource through the mutex. When one or more threads wait for system resources and the resources are occupied by the threads or other threads, for example, if a process does not release (crash or exit) after acquiring the mutex, the occupation of the resources is mutually exclusive, which may cause other processes to re-access the resources, because the mutex has no signal, the process waits indefinitely or overtime, and further causes the whole software system to have abnormal situations such as jamming or no response. Therefore, when multiple processes run synchronously, how to ensure that each process runs effectively and avoid the system from jamming becomes a problem to be solved urgently in the industry at present.
Disclosure of Invention
Therefore, embodiments of the present invention provide a method and an apparatus for service process synchronization, so as to solve the problem in the prior art that when multiple processes are operated in synchronization, one process does not obtain a mutex signal and then is not released in time, which causes other processes of the entire system to be stuck or stuck, and further causes poor system operation efficiency.
In a first aspect, an embodiment of the present invention provides a method for service process synchronization, including:
detecting whether the time of using the mutex by the current business process exceeds a preset time threshold value of waiting for the mutex by the business process, if so, generating a new mutex name according to a preset mutex naming rule;
calling a new mutex to access a target resource according to the name of the new mutex; and the new mutex corresponds to the target resource and is used for coordinating the service process to access the target resource in a mutex manner.
Further, the method for synchronizing the business processes further includes:
triggering a preset main service process to start, establishing a shared memory based on the main service process, and writing the name of a mutex for synchronization and a corresponding abnormal index identifier into the shared memory;
the main business process is a program used for creating mutexes and monitoring the calling time information of the mutexes in each business process;
and reading the name of the mutex and the abnormal index identifier from the shared memory based on the main service process, and generating the name of the original mutex according to the name of the mutex and the abnormal index identifier.
Further, the detecting whether the time for the current service process to use the mutex exceeds a preset time threshold for the service process to wait for the mutex, if so, generating a name of a new mutex according to a preset mutex naming rule, and includes:
polling and calling a preset waiting index object function by utilizing the main service process to detect whether the time of using the current mutex by the current service process exceeds the time threshold, if so, increasing the numerical value of an abnormal index identifier corresponding to the current mutex to obtain a target abnormal index identifier;
and splicing the name of the current mutex and the target abnormal index identifier to obtain the name of a new mutex based on the main service process.
Further, the invoking a new mutex according to the name of the new mutex to access a target resource specifically includes:
triggering a new service process to be started, reading an actual abnormal index identifier corresponding to the mutex currently used in the shared memory through the new service process, and generating a name of a new mutex based on the actual abnormal index identifier;
and calling the corresponding new mutex to access the target resource based on the name of the new mutex through the new service process.
Further, the invoking a new mutex according to the name of the new mutex to access a target resource specifically includes:
if the time of the target service process for waiting for the current mutex exceeds the time threshold, reading the target abnormal index identification corresponding to the current mutex in the shared memory through the target service process, and generating a new mutex name based on the target abnormal index identification; the target business process is an operated business process;
and calling the corresponding new mutex to access the target resource based on the name of the new mutex through the target business process.
Further, the method for synchronizing the business processes further includes:
obtaining a waiting index object function; wherein, the waiting exponential object function comprises a mutex handle parameter and a waiting time parameter;
and determining a time threshold corresponding to the mutex waiting of the business process based on the waiting index object function.
Further, the abnormal index identifier is an identification number for distinguishing a mutex, and the size of the identification number is equal to the number of times that the time for using the mutex by the service process exceeds the time threshold.
In a second aspect, an embodiment of the present invention further provides a device for service process synchronization, where the device includes:
a mutex naming unit, configured to detect whether a time for a current service process to use a mutex exceeds a preset time threshold for the service process to wait for the mutex, and if so, generate a name of a new mutex according to a preset mutex naming rule;
the process access control unit is used for calling the new mutex to access the target resource according to the name of the new mutex; and the new mutex corresponds to the target resource and is used for coordinating the service process to access the target resource in a mutex manner.
Further, the apparatus for synchronizing service processes further includes:
the main service process unit triggers the preset main service process to start, establishes a shared memory based on the main service process, and writes the name of the mutual exclusion quantity for synchronization and the corresponding abnormal index identification into the shared memory;
the main business process is a program used for creating mutexes and monitoring the calling time information of the mutexes in each business process;
and the mutex setting unit is used for reading the name of the mutex and the abnormal index identifier from the shared memory based on the main service process and generating the name of the original mutex according to the name of the mutex and the abnormal index identifier.
Further, the detecting whether the time for the current service process to use the mutex exceeds a preset time threshold for the service process to wait for the mutex, if so, generating a name of a new mutex according to a preset mutex naming rule, and includes:
polling and calling a preset waiting index object function by utilizing the main service process to detect whether the time of using the current mutex by the current service process exceeds the time threshold, if so, increasing the numerical value of an abnormal index identifier corresponding to the current mutex to obtain a target abnormal index identifier;
and splicing the name of the current mutex and the target abnormal index identifier to obtain the name of a new mutex based on the main service process.
Further, the process access control unit is specifically configured to:
triggering a new service process to be started, reading an actual abnormal index identifier corresponding to the mutex currently used in the shared memory through the new service process, and generating a name of a new mutex based on the actual abnormal index identifier;
and calling the corresponding new mutex to access the target resource based on the name of the new mutex through the new service process.
Further, the process access control unit is specifically further configured to:
if the time of the target service process for waiting for the current mutex exceeds the time threshold, reading the target abnormal index identification corresponding to the current mutex in the shared memory through the target service process, and generating a new mutex name based on the target abnormal index identification; the target business process is an operated business process;
and calling the corresponding new mutex to access the target resource based on the name of the new mutex through the target business process.
Further, the apparatus for synchronizing service processes further includes:
obtaining a waiting index object function; wherein, the waiting exponential object function comprises a mutex handle parameter and a waiting time parameter;
and determining a time threshold corresponding to the mutex waiting of the business process based on the waiting index object function.
Further, the abnormal index identifier is an identification number for distinguishing a mutex, and the size of the identification number is equal to the number of times that the time for using the mutex by the service process exceeds the time threshold.
In a third aspect, an embodiment of the present invention further provides an electronic device, including: memory, processor and computer program stored on the memory and executable on the processor, the processor implementing the steps of the method of business process synchronization as described in any one of the above when executing the program.
In a fourth aspect, an embodiment of the present invention further provides a non-transitory computer readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the steps of the method for business process synchronization according to any one of the above items.
By adopting the method for synchronizing the business processes, provided by the embodiment of the invention, the time threshold of waiting for the mutex of the business processes can be set, when the time for detecting that the mutex is used by the current business process exceeds the time threshold, the name of a new mutex is generated according to the preset mutex naming rule, and the corresponding new mutex is called to access the target resource, so that the conditions that other processes of the whole system are jammed or jammed and the like due to the fact that one process does not release the mutex after obtaining the mutex signal when the multiple processes synchronously access the shared resource in the system are effectively avoided, each process can effectively run, and the running efficiency of the system is improved.
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 introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is a schematic flowchart of a method for service process synchronization according to an embodiment of the present invention;
fig. 2 is a flowchart of a main business process in a business process synchronization method according to an embodiment of the present invention;
fig. 3 is a flowchart of a new service process in a method for synchronizing service processes according to an embodiment of the present invention;
fig. 4 is a flowchart of a currently running business process in a method for synchronizing business processes according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of a device for service process synchronization according to an embodiment of the present invention;
fig. 6 is a schematic physical structure diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present 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 following describes an embodiment of the service process synchronization method in detail based on the present invention. As shown in fig. 1, which is a flowchart of a method for service process synchronization provided in an embodiment of the present invention, a specific implementation process includes the following steps:
step S101: and detecting whether the time of using the mutex by the current business process exceeds a preset time threshold value of waiting for the mutex by the business process, if so, generating a new mutex name according to a preset mutex naming rule.
In the embodiment of the present invention, it is required to change the waiting time of the current mutex signal from infinite waiting to finite waiting in advance by calling a preset waiting exponential object function (waitforsingleigabject), and determine a time threshold corresponding to the service process waiting mutex based on the waiting exponential object function. Wherein the wait index object function contains a mutex handle parameter (hHandlePar1) and a wait time parameter (timePar 2). The waiting time of the current mutex signal is changed from infinite waiting to FINITE waiting, namely, the waiting time parameter is set to FINITE. It should be noted that the wait index object function is a Windows API function, and when waiting for the pending state, the handle is closed, and the function behavior is undefined, and the handle must have synchronous access rights. The waiting exponential object function is used for detecting the signal state of the hHandle event, when the function is called in a certain process, the process is temporarily suspended, and if the mutex waiting by the process changes to be in the signal state within the dwMillisseconds of suspension, the function immediately returns; if the time has reached dwMilliseconds, but the mutex pointed to by hHandle has not become signaled, the function returns.
As shown in fig. 2, after determining that a service process waits for a time threshold corresponding to a mutex, a preset main service process is triggered to start, a shared memory is created through the main service process, and a name of the mutex for synchronization and a corresponding abnormal index identifier are written into the shared memory. And reading the name of the mutex and the abnormal index identifier from the shared memory based on the main service process, and generating the name of the original mutex according to the name of the mutex and the abnormal index identifier. The main business process is a program used for creating mutexes and monitoring the call time information of the mutexes in each business process. The mutex is a variable that can be in one of two states, unlocked and locked. The abnormal index mark is an identification mark used for distinguishing the mutex, and the size of the identification mark is equal to the times that the time of using the mutex by the service process exceeds the time threshold.
In the specific implementation process, the mutex can be represented by a binary bit; an integer quantity may also be used to indicate a mutex, such as 0 to indicate unlock and all other values to indicate lock. Mutex use involves two processes, the mutex _ lock, which needs to be invoked when a process (or thread) needs to access a target resource in a critical section. If the mutex is currently unlocked (i.e., a critical section is available), this invocation is successful and the calling process is free to enter the critical section. On the other hand, if the mutex is already locked, the calling process is blocked, and the time for using the mutex by the current service process exceeds the preset time threshold, the name of the new mutex is generated according to the preset mutex naming rule, so that the new mutex is called in the subsequent steps to realize the access to the target resource in the critical section, which is not described in detail herein.
In this step, the detecting whether the time for using the mutex by the current service process exceeds a preset time threshold, if so, generating a name of a new mutex according to a preset mutex naming rule, and the specific implementation process may include: polling and calling a preset waiting index object function by utilizing the main service process to detect whether the time of using the current mutex by the current service process exceeds the time threshold, if so, increasing the numerical value of an abnormal index identifier corresponding to the current mutex according to a preset mutex naming rule to obtain a target abnormal index identifier; and splicing the name of the current mutex and the target abnormal index identifier to obtain the name of a new mutex based on the main service process. The abnormal index mark is an identification number used for recording the times that the time of using the mutex by the service process exceeds a preset time threshold; the target abnormal index identifier is an abnormal index identifier obtained after increasing the numerical value of the abnormal index identifier corresponding to the current mutex.
According to a preset mutex naming rule, the name of the original mutex is the name of the existing mutex plus an abnormal index identifier (namely, an abnormal index ID; nIndex), the initial value of the abnormal index identifier is 0, and the name of the original mutex is equal to the name of the current mutex.
If the main process obtains that an exception occurs once (for example, the mutex is not released due to the crash or exit of the service process), the value of the exception index identifier is +1, so that a target exception index identifier is obtained, the name of the current mutex and the target exception index identifier are stored in the shared memory, the main service process is responsible for writing, and other service processes only read from the shared memory. The target abnormal index mark is an identity mark number used for distinguishing mutexes, the size of the identity mark number is equal to the times that the time of using the mutexes by a service process exceeds the time threshold, and when no abnormality is detected, the target abnormal index mark is equal to the abnormal index mark. The access of the shared memory does not set the mutex, namely, the mutex lock is not added.
And regularly checking whether the current mutex has abnormal conditions such as locked condition, unreleased condition and the like based on the main service process. If so, reading the name of the mutex from the shared memory, merging the name of the new mutex into the name of the new mutex according to the obtained target abnormal index identifier, and calling the new mutex by using the name of the new mutex to access the data resources of the system. Specifically, whether the current mutex has a timeout phenomenon or not can be detected by polling a timeout mechanism of a preset wait index object function, that is, whether the mutex is locked or not, and abnormal conditions such as unreleased conditions and the like exist or not can be judged. And if the process acquires the signal but does not release the signal and the process overtime exists, the abnormal conditions such as locked condition, unreleased condition and the like exist, and the abnormal index mark +1 corresponding to the mutex is used for acquiring the target abnormal index mark.
Step S102: and calling the new mutex to access the target resource according to the name of the new mutex. And the new mutex corresponds to the target resource and is used for coordinating the service process to access the target resource in a mutex manner.
As shown in fig. 3 and 4, in the embodiment of the present invention, the invoking a new mutex according to the name of the new mutex to access a target resource specifically includes: and the running service process waits for the overtime of the current mutex or the opening of a new service process, and calls the new mutex to access the target resource according to the name of the new mutex.
Specifically, if the time for the target service process to wait for the current mutex exceeds the time threshold, the target service process reads the target abnormal index identifier corresponding to the current mutex in the shared memory, and generates a new mutex name based on the target abnormal index identifier; and calling the corresponding new mutex to access the target resource based on the name of the new mutex through the target business process. Wherein the target business process is an operated business process. And if the new service process is triggered to be started, reading an actual abnormal index identifier corresponding to the mutex currently used in the shared memory through the new service process, generating a name of a new mutex based on the actual abnormal index identifier, and calling the corresponding new mutex to access the target resource through the new service process based on the name of the new mutex.
In the embodiment of the invention, when the running process is subjected to waiting timeout or a new process is started, the synchronization is carried out according to the new mutex when the public resource is accessed. Reading the overtime process or the new process of the current mutex, obtaining the target abnormal index identification corresponding to the name of the current mutex from the shared memory, generating a new mutex, and using the new mutex as a synchronization basis when accessing the shared resource next time. Specifically, the new process starts to read a target abnormal index identifier corresponding to the used current mutex from the shared memory, generates an actually used mutex name, and synchronizes the processes to access the shared resource; and if the running process waits for the current mutex and is overtime, reading the shared memory, acquiring a target abnormal index identifier corresponding to the currently used mutex, generating a new mutex, and subsequently using the new mutex to synchronously access the shared resource.
It should be noted that the main service process is the main process in fig. 2, and the new service process is the new process in fig. 3, which are not described in detail herein.
By adopting the method for synchronizing the business processes, provided by the embodiment of the invention, the time threshold of waiting for the mutex of the business processes can be set, when the time for detecting that the mutex is used by the current business process exceeds the time threshold, the name of a new mutex is generated according to the preset mutex naming rule, and the corresponding new mutex is called to access the target resource, so that the conditions that other processes of the whole system are jammed or jammed and the like due to the fact that one process does not release the mutex after obtaining the mutex signal when the multiple processes synchronously access the shared resource in the system are effectively avoided, each process can effectively run, and the running efficiency of the system is improved.
Corresponding to the method for synchronizing the business process, the invention also provides a device for synchronizing the business process. Since the embodiment of the device is similar to the above method embodiment, the description is relatively simple, and please refer to the description of the above method embodiment, and the embodiments of the device for service process synchronization described below are only schematic. Fig. 5 is a schematic structural diagram of a device for service process synchronization according to an embodiment of the present invention.
The device for synchronizing the business processes specifically comprises the following parts:
a mutex naming unit 501, configured to detect whether a time for the current service process to use the mutex exceeds a preset time threshold for the service process to wait for the mutex, and if so, generate a name of a new mutex according to a preset mutex naming rule.
And the process access control unit 502 is configured to invoke a new mutex to access the target resource according to the name of the new mutex. And the new mutex corresponds to the target resource and is used for coordinating the service process to access the target resource in a mutex manner.
By adopting the device for synchronizing the business processes, provided by the embodiment of the invention, the time threshold of waiting for the mutex of the business processes can be set, when the time for detecting that the mutex is used by the current business process exceeds the time threshold, the name of a new mutex is generated according to the preset mutex naming rule, and the corresponding new mutex is called to access the target resource, so that the conditions that other processes of the whole system are jammed or jammed and the like due to the fact that one process does not release the mutex after obtaining the mutex signal when the multiple processes synchronously access the shared resource in the system are effectively avoided, each process can effectively run, and the running efficiency of the system is improved.
Corresponding to the method for synchronizing the business processes, the invention also provides electronic equipment. Since the embodiment of the electronic device is similar to the above method embodiment, the description is relatively simple, and please refer to the description of the above method embodiment, and the electronic device described below is only schematic. Fig. 6 is a schematic physical structure diagram of an electronic device according to an embodiment of the present invention. The electronic device may include: a processor (processor)601, a memory (memory)602, and a communication bus 603, wherein the processor 601 and the memory 602 communicate with each other through the communication bus 603. Processor 601 may invoke logic instructions in memory 602 to perform a method of business process synchronization, the method comprising: detecting whether the time of using the mutex by the current business process exceeds a preset time threshold value of waiting for the mutex by the business process, if so, generating a new mutex name according to a preset mutex naming rule; calling a new mutex to access a target resource according to the name of the new mutex; and the new mutex corresponds to the target resource and is used for coordinating the service process to access the target resource in a mutex manner.
Furthermore, the logic instructions in the memory 602 may be implemented in software functional units and stored in a computer readable storage medium when the logic instructions are sold or used as independent products. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
In another aspect, an embodiment of the present invention further provides a computer program product, where the computer program product includes a computer program stored on a non-transitory computer-readable storage medium, the computer program includes program instructions, and when the program instructions are executed by a computer, the computer can perform the method for business process synchronization provided by the above-mentioned method embodiments, where the method includes: detecting whether the time of using the mutex by the current business process exceeds a preset time threshold value of waiting for the mutex by the business process, if so, generating a new mutex name according to a preset mutex naming rule; calling a new mutex to access a target resource according to the name of the new mutex; and the new mutex corresponds to the target resource and is used for coordinating the service process to access the target resource in a mutex manner.
In yet another aspect, an embodiment of the present invention further provides a non-transitory computer-readable storage medium, on which a computer program is stored, where the computer program is implemented by a processor to perform the method for service process synchronization provided by the foregoing embodiments, and the method includes: detecting whether the time of using the mutex by the current business process exceeds a preset time threshold value of waiting for the mutex by the business process, if so, generating a new mutex name according to a preset mutex naming rule; calling a new mutex to access a target resource according to the name of the new mutex; and the new mutex corresponds to the target resource and is used for coordinating the service process to access the target resource in a mutex manner.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. A method for synchronizing business processes, comprising:
detecting whether the time of using the mutex by the current business process exceeds a preset time threshold value of waiting for the mutex by the business process, if so, generating a new mutex name according to a preset mutex naming rule;
calling a new mutex to access a target resource according to the name of the new mutex; and the new mutex corresponds to the target resource and is used for coordinating the service process to access the target resource in a mutex manner.
2. The method for synchronizing business processes according to claim 1, further comprising:
triggering a preset main service process to start, establishing a shared memory based on the main service process, and writing the name of a mutex for synchronization and a corresponding abnormal index identifier into the shared memory;
the main business process is a program used for creating mutexes and monitoring the calling time information of the mutexes in each business process;
and reading the name of the mutex and the abnormal index identifier from the shared memory based on the main service process, and generating the name of the original mutex according to the name of the mutex and the abnormal index identifier.
3. The method for service process synchronization according to claim 2, wherein the detecting whether the time for the current service process to use the mutex exceeds a preset time threshold for the service process to wait for the mutex, if so, generating a new name of the mutex according to a preset mutex naming rule, comprising:
polling and calling a preset waiting index object function by utilizing the main service process to detect whether the time of using the current mutex by the current service process exceeds the time threshold, if so, increasing the numerical value of an abnormal index identifier corresponding to the current mutex to obtain a target abnormal index identifier;
and splicing the name of the current mutex and the target abnormal index identifier to obtain the name of a new mutex based on the main service process.
4. The method for synchronizing service processes according to claim 3, wherein the invoking of the new mutex according to the name of the new mutex to access the target resource specifically comprises:
triggering a new service process to be started, reading an actual abnormal index identifier corresponding to the mutex currently used in the shared memory through the new service process, and generating a name of a new mutex based on the actual abnormal index identifier;
and calling the corresponding new mutex to access the target resource based on the name of the new mutex through the new service process.
5. The method for synchronizing service processes according to claim 3, wherein the invoking of the new mutex according to the name of the new mutex to access the target resource specifically comprises:
if the time of the target service process for waiting for the current mutex exceeds the time threshold, reading the target abnormal index identification corresponding to the current mutex in the shared memory through the target service process, and generating a new mutex name based on the target abnormal index identification; the target business process is an operated business process;
and calling the corresponding new mutex to access the target resource based on the name of the new mutex through the target business process.
6. The method for synchronizing business processes according to claim 1, further comprising:
obtaining a waiting index object function; wherein, the waiting exponential object function comprises a mutex handle parameter and a waiting time parameter;
and determining a time threshold corresponding to the mutex waiting of the business process based on the waiting index object function.
7. The method for synchronizing service processes according to any one of claims 2 to 5, wherein the exception index identifier is an identification number for distinguishing mutexes, and the size of the identification number is equal to the number of times that the time for using mutexes by the service process exceeds the time threshold.
8. An apparatus for business process synchronization, comprising:
a mutex naming unit, configured to detect whether a time for a current service process to use a mutex exceeds a preset time threshold for the service process to wait for the mutex, and if so, generate a name of a new mutex according to a preset mutex naming rule;
the process access control unit is used for calling the new mutex to access the target resource according to the name of the new mutex; and the new mutex corresponds to the target resource and is used for coordinating the service process to access the target resource in a mutex manner.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the steps of the method of business process synchronization according to any of claims 1-7 when executing the program.
10. A non-transitory computer readable storage medium, having stored thereon a computer program, wherein the computer program, when executed by a processor, performs the steps of the method for business process synchronization according to any one of claims 1-7.
CN202011192025.8A 2020-10-30 2020-10-30 Method and device for synchronizing business processes Active CN112162845B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011192025.8A CN112162845B (en) 2020-10-30 2020-10-30 Method and device for synchronizing business processes

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011192025.8A CN112162845B (en) 2020-10-30 2020-10-30 Method and device for synchronizing business processes

Publications (2)

Publication Number Publication Date
CN112162845A true CN112162845A (en) 2021-01-01
CN112162845B CN112162845B (en) 2023-10-13

Family

ID=73865308

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011192025.8A Active CN112162845B (en) 2020-10-30 2020-10-30 Method and device for synchronizing business processes

Country Status (1)

Country Link
CN (1) CN112162845B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114090197A (en) * 2021-10-19 2022-02-25 山东浪潮科学研究院有限公司 Optimization method for multi-process AWG access control

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH11224205A (en) * 1997-11-21 1999-08-17 Fuji Xerox Co Ltd Process control system
CN105511969A (en) * 2015-11-25 2016-04-20 中国船舶工业***工程研究院 Inter-process thread mutex method
US20180191706A1 (en) * 2016-12-29 2018-07-05 Yahoo Holdings, Inc. Controlling access to a shared resource
CN108958911A (en) * 2018-05-30 2018-12-07 北京小米移动软件有限公司 The control method and device of process
CN110704492A (en) * 2018-06-25 2020-01-17 中兴通讯股份有限公司 Data acquisition method and device and computer readable storage medium
CN111078417A (en) * 2019-12-17 2020-04-28 深圳前海环融联易信息科技服务有限公司 Account scheduling method and device, computer equipment and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH11224205A (en) * 1997-11-21 1999-08-17 Fuji Xerox Co Ltd Process control system
CN105511969A (en) * 2015-11-25 2016-04-20 中国船舶工业***工程研究院 Inter-process thread mutex method
US20180191706A1 (en) * 2016-12-29 2018-07-05 Yahoo Holdings, Inc. Controlling access to a shared resource
CN108958911A (en) * 2018-05-30 2018-12-07 北京小米移动软件有限公司 The control method and device of process
CN110704492A (en) * 2018-06-25 2020-01-17 中兴通讯股份有限公司 Data acquisition method and device and computer readable storage medium
CN111078417A (en) * 2019-12-17 2020-04-28 深圳前海环融联易信息科技服务有限公司 Account scheduling method and device, computer equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114090197A (en) * 2021-10-19 2022-02-25 山东浪潮科学研究院有限公司 Optimization method for multi-process AWG access control
CN114090197B (en) * 2021-10-19 2024-05-28 山东浪潮科学研究院有限公司 Optimization method for multi-process AWG access control

Also Published As

Publication number Publication date
CN112162845B (en) 2023-10-13

Similar Documents

Publication Publication Date Title
CN112650576B (en) Resource scheduling method, device, equipment, storage medium and computer program product
US8868604B2 (en) Methods and apparatus for implementing Semi-distributed Lock Management
KR20080038301A (en) Blocking local sense synchronization barrier
US10630399B2 (en) Testing distributed applications that have an established exchange in an advanced message queuing protocol (AMQP) message broker
US8930970B2 (en) Method and computer for obtaining using-frequency of application program
CN107832403B (en) Directory file management method and device, electronic terminal and readable storage medium
CN112162845A (en) Method and device for synchronizing business processes
CN114398631A (en) Business processing method and device, electronic equipment and storage medium
JP2017033552A (en) User-mode component injection and atomic hooking
CN112015563A (en) Message queue switching method and device, electronic equipment and storage medium
CN110119429B (en) Data processing method, data processing device, computer equipment and storage medium
CN106407016B (en) Method and device for simulating multithreading contention and robbery of resources
CN110309224B (en) Data copying method and device
CN116108435A (en) On-demand opening method and device for safety cut surface of mobile terminal
CN115878336A (en) Information processing method and device in lock operation and computing equipment
CN115858483A (en) Log analysis and management method, terminal and computer readable storage medium
CN111858075A (en) Deadlock detection method, system, equipment and readable storage medium
CN113867701A (en) Container object instantiation method and device, storage medium and electronic equipment
CN111680334A (en) Disk security access method, device, equipment and medium
CN113190427B (en) Method and device for monitoring blocking, electronic equipment and storage medium
US20160274957A1 (en) Information processing device, control method thereof, and recording medium
CN103713982A (en) Method and device for monitoring return result of remote service
CN111078658B (en) Method and device for mounting cluster file system
CN109918895B (en) Method, electronic device, and computer-readable medium for outputting data
CN108923973B (en) Monitoring method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant