CN111782410A - Lock jam monitoring method and device, electronic equipment and computer readable medium - Google Patents

Lock jam monitoring method and device, electronic equipment and computer readable medium Download PDF

Info

Publication number
CN111782410A
CN111782410A CN202010620835.2A CN202010620835A CN111782410A CN 111782410 A CN111782410 A CN 111782410A CN 202010620835 A CN202010620835 A CN 202010620835A CN 111782410 A CN111782410 A CN 111782410A
Authority
CN
China
Prior art keywords
lock
jam
lock jam
event
time
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
CN202010620835.2A
Other languages
Chinese (zh)
Other versions
CN111782410B (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 ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202010620835.2A priority Critical patent/CN111782410B/en
Publication of CN111782410A publication Critical patent/CN111782410A/en
Application granted granted Critical
Publication of CN111782410B publication Critical patent/CN111782410B/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/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores
    • G06F9/524Deadlock detection or avoidance
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying
    • G06F16/90335Query processing
    • G06F16/90344Query processing by using string matching techniques

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The disclosure provides a lock jam monitoring method and device, electronic equipment and a computer readable medium, and relates to the technical field of computers. The method includes the steps that writing operation of an operating system is intercepted, event content of the writing operation is matched with a preset character string, if it is determined that a current thread corresponding to the writing operation is locked and blocked according to a matching result, and when the current thread obtains a lock successfully, lock blocking duration of the lock blocking is calculated; the preset character string is obtained by extracting key characters from the event content with over-lock jam in advance; and when the lock jam duration reaches a preset threshold value, reporting the lock jam event at the time. According to the technical scheme, the lock blockage of the operating system can be accurately monitored in time, so that the resource loss caused by the lock blockage is avoided.

Description

Lock jam monitoring method and device, electronic equipment and computer readable medium
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a lock jam monitoring method and apparatus, an electronic device, and a computer readable medium.
Background
Multithreading-based concurrency is common in android application development. The issue of resource access conflict may be caused by the concurrence of multiple threads, that is, when multiple threads access a resource simultaneously, only one thread can access the resource at a time due to the special characteristics of some resources, such as: the simultaneous writing operation of multiple threads to a file can cause confusion of the content of the file. Lock technology is usually used to resolve resource access conflicts, and only threads that obtain a lock can write to a file, thereby accessing resources in order.
However, in the actual using process, the problem of lock blocking sometimes occurs in the application of the lock technology, that is, when a certain thread occupies a certain resource all the time without releasing, other threads wait for blocking all the time, which results in serious resource loss of the application system, and especially, no lock detection tool and method specially for the android platform exists at present, the problem of lock blocking in the android application cannot be monitored timely and accurately, which results in serious resource loss of the android platform.
Disclosure of Invention
This summary is provided to introduce a selection of concepts in a simplified form that are further described below in the detailed description. This summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter.
In a first aspect, an embodiment of the present disclosure provides a lock jam monitoring method, including the following steps:
intercepting a write operation of an operating system;
matching the event content of the write-in operation with a preset character string, and if the current thread corresponding to the write-in operation is determined to have lock jam according to the matching result and the lock jam duration of the lock jam is calculated when the current thread successfully acquires the lock; the preset character string is obtained by extracting key characters from the event content with over-lock jam in advance;
and reporting a lock jam event when the lock jam duration reaches a preset threshold value.
In a second aspect, an embodiment of the present disclosure further provides a device for monitoring lock jam, including:
the interception module is used for intercepting the writing operation of the operating system;
the calculation module is used for matching the event content of the write-in operation with a preset character string, and if the current thread corresponding to the write-in operation is determined to have lock jam according to the matching result and the lock acquisition success of the current thread is achieved, calculating the lock jam duration of the lock jam; the preset character string is obtained by extracting key characters from the event content with over-lock jam in advance;
and the reporting module is used for reporting the lock jam event when the lock jam duration reaches a preset threshold value.
In a third aspect, an embodiment of the present disclosure further provides an electronic device, which includes:
one or more processors;
a memory;
one or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs configured to: the method of monitoring for a lock jam as mentioned in any of the embodiments above is performed.
In a fourth aspect, the disclosed embodiments further provide a computer-readable medium, on which a computer program is stored, where the computer program is executed by a processor to implement the lock jam monitoring method mentioned in any of the above embodiments.
The technical scheme provided by the disclosure has the following beneficial effects:
according to the method, the device, the electronic equipment and the computer readable medium for monitoring the lock jam provided by the embodiment, the writing operation of the operating system is intercepted, whether the lock jam occurs in the current thread corresponding to the writing operation is judged by using a character string matching mode for the event content of the writing operation, the lock jam duration is calculated when the current thread is determined to have the lock jam and the lock acquisition is successful, and the lock jam event is reported when the lock jam duration reaches the preset threshold value, so that the lock jam occurring in the operating system can be timely and accurately monitored, and the resource loss caused by the lock jam is avoided.
Additional aspects and advantages of the disclosure will be set forth in part in the description which follows and, in part, will be obvious from the description, or may be learned by practice of the disclosure.
Drawings
The above and other features, advantages and aspects of various embodiments of the present disclosure will become more apparent by referring to the following detailed description when taken in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numbers refer to the same or similar elements. It should be understood that the drawings are schematic and that elements and features are not necessarily drawn to scale.
FIG. 1 is a diagram illustrating instruction execution within a thread according to the prior art;
FIG. 2 is a flow diagram of a method for monitoring lock jams according to an embodiment;
FIG. 3 is a diagram illustrating the use of locks to implement mutually exclusive access in a related multithreaded program;
FIG. 4 is a schematic diagram of an embodiment of a device for monitoring lock jams;
fig. 5 is a schematic structural diagram of an electronic device for lock jam monitoring according to an embodiment.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. Moreover, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "include" and variations thereof as used herein are open-ended, i.e., "including but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing the devices, modules or units, and are not used for limiting the devices, modules or units to be different devices, modules or units, and also for limiting the sequence or interdependence relationship of the functions executed by the devices, modules or units.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise.
The names of messages or information exchanged between devices in the embodiments of the present disclosure are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
The present disclosure provides a lock jam monitoring method, device, electronic device and computer readable medium, which aim to solve the above technical problems in the prior art.
In order to better explain the technical scheme of the present disclosure, the related art is introduced first. Each program running on the system is a process, and each process may include one or more threads, which are the smallest units of program execution flow. The order of execution of instructions within each thread is fixed. FIG. 1 is a diagram illustrating a manner of executing instructions within a thread in the related art, where, as shown in FIG. 1, instruction 1 is executed first, then instruction 2 is executed, and so on until instruction n (n ≧ 2) is executed, and the process ends.
In general, a program including a plurality of threads is referred to as a multi-threaded program, and in the multi-threaded program, when a plurality of threads need to access the same piece of data, that is, shared data, since the execution order of instructions is different, it is necessary to use a lock to realize mutually exclusive access. However, the use of locks can realize mutually exclusive access, but in practical applications, problems such as lock blocking and the like can also be caused.
The following describes the technical solutions of the present disclosure and how to solve the above technical problems in specific embodiments. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments. Embodiments of the present disclosure will be described below with reference to the accompanying drawings.
FIG. 2 is a flow diagram of a method for monitoring lock jams according to an embodiment. The method for monitoring lock blocking in the present disclosure can be applied to various operating systems, and this embodiment is described by taking an Android operating system as an example.
As shown in fig. 2, the method for monitoring the lock jam may include the steps of:
and S110, intercepting the writing operation of the operating system.
During the development of the application software, the operating system writes to various events. When a lock blocking event occurs, the operating system will also write the lock blocking event.
In the embodiment of the disclosure, when the lock jam monitoring method is executed, the write operation of all events of the operating system is intercepted, and the lock jam event is screened out. For example, a write operation of all events of the operating system is intercepted in a whole process link table interception (PLThook) manner, where the write operation includes a write operation of an Atrace event, where the Atrace event is an event that often occurs when a lock is blocked.
The plt (procedure linking table) is mainly used to assist a program to complete a delayed loading function, and assuming that the program calls a function in a dynamic library, because the dynamic library can be loaded to any position in a memory, this embodiment predicts a runtime address of the function by using a delayed loading technique, and delays the resolution of the function address to the time of actual call of the function. The PLThook technology only costs one instruction and one indirect memory reference in the calling after the first function calling, so that the resource loss is reduced.
And S120, matching the event content of the write-in operation with a preset character string, and if the current thread corresponding to the write-in operation is determined to have lock jam according to the matching result and the current thread successfully acquires the lock, calculating the lock jam duration of the lock jam.
And when the operating system performs writing operation, writing the event content of the corresponding event. The event content of the write operation includes a start flag of the write, specific content of the write, a name of a thread involved, and other content and information, and is presented by a series of characters, for example, the event content corresponding to the write operation of a log sample to a certain application is as follows:
B|30978|monitor contention with owner xxx(31060)at boolean android.os.MessageQueue.hasMessages(android.os.Handler,int,java.lang.Object)(MessageQueue.java:598)waiters=0blocking from boolean android.os.MessageQueue.enqueueMessage(android.os.Message,long)(MessageQueue.java:547)。
in this embodiment, a character string for detecting whether a lock jam occurs is set in advance according to an identifier that occurs when a lock jam occurs in a write operation. Furthermore, corresponding preset character strings can be set for lock jam events corresponding to different types of write operations respectively, so as to distinguish the events corresponding to the different types of write operations with lock jams. The preset character string may be obtained by extracting key characters from the event content in which the over-lock jam occurs in advance.
And matching the event content of the write-in operation with a preset character string, if the event content of the write-in operation has a character string segment matched with the preset character string, determining that the current thread corresponding to the write-in operation has lock jam, and if the event content of the write-in operation does not have the character string segment matched with the preset character string, determining that the current thread corresponding to the write-in operation does not have lock jam.
Based on the example of the event content corresponding to the write operation of the log sample of the certain application, the preset character string for determining whether the lock jam occurs in the write operation may be set as: the monitor content determines that the current thread corresponding to the write operation of the log sample has the lock jam, that is, when a string segment exists in the event content of the write operation and matches with the monitor content, the preset string is a string identifier indicating that the lock jam occurs.
And when the current thread is determined to be blocked, the position of the lock holding thread is positioned by acquiring the information of the lock holding thread, and the lock is acquired from the lock holding thread. And when the current thread acquires the lock, the lock jam of the current thread is finished. In one embodiment of the present disclosure, the lock jam duration of the lock jam may be calculated by acquiring the lock jam start time and the lock jam end time.
And S130, when the lock blocking duration reaches a preset threshold, reporting a lock blocking event.
In this embodiment, the preset threshold is the maximum time length set by the user and used for judging the occurrence of lock jam, and if the lock jam time length reaches the preset threshold, the lock jam event is reported, so that the user can find the lock jam event in time, obtain the lock state of the monitored application, find the lock jam problem in time, and avoid resource loss caused by long-time lock jam.
In the embodiment of the disclosure, when a lock jam event is reported, event information of the lock jam is obtained to report the event information, and the event information includes a lock jam thread, a lock holding thread and a lock jam duration. The lock blocking thread is a thread waiting for a lock, the lock is not obtained due to the lock waiting and is in a lock blocking state, and the lock holding thread is a thread acquiring the lock, namely a thread occupying the lock. In the process of using a lock to realize mutual exclusion access, when a lock holding thread occupies the lock but does not release the lock, the lock conflict thread accessing the same resource can perform subsequent operation only after waiting for the lock holding thread to release the lock.
For convenience of understanding, as shown in fig. 3, fig. 3 is a schematic diagram illustrating that a lock is used to implement mutually exclusive access in a related multithread program, where threads a and B access the same resource, when thread B needs to acquire the lock, if thread a is occupying the lock, thread B will be blocked, and only after thread a releases the lock, thread B can perform subsequent processing, at this time, thread a is a lock holding thread, and thread B is a lock blocking thread.
In an alternative embodiment, the lockthread may be obtained by identifying a related string in the event content of the write operation, such as the log sample of some application described above:
B|30978|monitor contention with owner xxx(31060)at boolean android.os.MessageQueue.hasMessages(android.os.Handler,int,java.lang.Object)(MessageQueue.java:598)waiters=0blocking from boolean android.os.MessageQueue.enqueueMessage(android.os.Message,long)(MessageQueue.java:547)。
the character following the B | monitor content contains the information of the thread holding lock, such as the name of the thread holding lock, the function executed by the current thread, etc.
Based on the above example, the lock-holding thread for the write operation is identified as "xxx (31060)". And then, packaging information such as the lock holding thread, the lock blocking time and the like, and reporting the packaged information.
According to the monitoring method for the lock jam, the writing operation of the operating system is intercepted, whether the lock jam occurs to the current thread corresponding to the writing operation is judged in a character string matching mode, when the lock jam occurs to the current thread is determined, when the current thread obtains the lock successfully, the lock jam duration is calculated, when the lock jam duration exceeds a preset threshold value, the lock jam event of the current time is reported, the lock jam can be timely and accurately monitored, and the problem is timely found to avoid resource loss caused by the lock jam.
In order to make the technical solution clearer and easier to understand, specific implementation processes and modes in the technical solution are described in detail below.
In an embodiment of the present disclosure, the event content of the write operation carries a congestion start identifier and a congestion end identifier, and the lock congestion duration may be calculated by identifying the congestion start identifier and the congestion end identifier carried by the event content of the write operation.
Based on this, the calculation of the jam duration of the jam of the lock according to the embodiment of the disclosure can be realized by the following steps:
s201, acquiring the time of recognizing the jam start mark as the lock jam start time.
S202, acquiring the time of recognizing the jam ending mark as the lock jam ending time.
And S203, calculating the lock jam duration according to the lock jam starting time and the lock jam ending time.
In the embodiment of the present disclosure, the corresponding event content in the write operation is analyzed, and it is determined that the event content carries the congestion start identifier and the congestion end representation. Further, a character string matching mode is adopted to identify a jam start identifier and a jam end identifier carried in the event content of the writing operation. For example, "B | monitor content ×" indicates the start of lock blocking, and "E" indicates the end of lock blocking.
For example, matching each character in the event content in the write operation with a preset start identifier, if the recognized character is matched with "B | monitor content", determining that the event content of the write operation carries a lock jam start identifier if the matching is successful, and acquiring the time of recognizing the lock jam start identifier as the lock jam start time.
And matching the recognized character with a preset ending mark, if the recognized character is matched with 'E', if the matching is successful, determining that the event content of the writing operation carries the lock jam ending mark, and acquiring the time of recognizing the lock jam ending mark as the lock jam ending time.
And calculating the difference value of the lock jam ending time and the lock jam starting time to obtain the lock jam duration.
In order to illustrate the present solution more clearly, the working process of the monitoring method for lock jam will be described in an exemplary way with reference to the following embodiments:
intercepting an operating system in a PLThook mode, such as all writing operations in an android operating system, including the writing operation of an atom event, judging whether a current thread corresponding to the current writing operation has lock jam or not in a character string matching mode, if the current thread has the lock jam, acquiring lock-holding thread information, acquiring a lock from the lock-holding thread, calculating the lock jam duration of the current thread when the current thread successfully acquires the lock, and if the lock jam duration exceeds a preset threshold, reporting the current lock jam event, wherein the reported information comprises: the lock blocks up the information such as thread, holds lock thread and lock jam duration to in time monitor out the lock and block up the trouble, avoid the resource loss that the lock blockked up and lead to.
The following describes in detail a related embodiment of the lock jam monitoring device.
Fig. 4 is a schematic structural diagram of a monitoring apparatus for lock jam according to an embodiment, which may be implemented in a monitoring device for lock jam, as shown in fig. 4, the monitoring apparatus 100 for lock jam may include: an interception module 110, a calculation module 120 and a reporting module 130.
The intercepting module 110 is configured to intercept a write operation of an operating system;
the calculation module 120 is configured to match the event content of the write operation with a preset character string, and if it is determined that a lock jam occurs in a current thread corresponding to the write operation according to a matching result, and the current thread successfully acquires the lock, calculate a lock jam duration of the lock jam;
and a reporting module 130, configured to report a lock blocking event when the lock blocking duration reaches a preset threshold.
The monitoring device of lock jam that this embodiment provided, through interception operating system's the operation of writing in, judge whether lock jam appears through the mode of string matching, acquire the lock when the lock jam appears in the affirmation, when acquiring the lock success, it is long when blocking up to calculate the lock, it is long to exceed preset threshold value when blocking up to lock, then reports this time lock jam incident to can reach the accurate monitoring and appear lock jam to operating system, in order to avoid blocking up the resource loss who leads to because of the lock.
In one embodiment, the calculation module 120 includes: the device comprises a first acquisition unit, a second acquisition unit and a duration calculation unit;
the first acquisition unit is used for acquiring the time for identifying the jam start identifier as the lock jam start time; the second acquisition unit is used for acquiring the time for identifying the jam ending mark as the lock jam ending time; and the time length calculating unit is used for calculating the lock jam time length according to the lock jam starting time and the lock jam ending time.
In one embodiment, it is determined that the current thread successfully acquires the lock by: and when the blockage ending identifier in the event content corresponding to the write-in operation is identified, determining that the current thread acquires the lock successfully.
In an embodiment, the reporting module 130 includes an information obtaining unit and an information reporting unit; the information acquisition unit is used for acquiring event information of the lock jam, wherein the event information comprises a lock jam thread, a lock holding thread and lock jam duration; and the information reporting unit is used for reporting the event information.
In an embodiment, the interception module 110 is configured to intercept a write operation of an Atrace event of an operating system by a full process link table interception manner.
The monitoring device for lock jam provided by the above can be used for executing the monitoring method for lock jam provided by any of the above embodiments, and has corresponding functions and beneficial effects.
Referring now to fig. 5, fig. 5 is a schematic diagram of an embodiment of an electronic device for lock jam monitoring, illustrating a schematic diagram of an electronic device 700 suitable for implementing embodiments of the disclosure. The electronic devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., car navigation terminals), and the like, and fixed terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 5 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
The electronic device includes: a memory and a processor, wherein the processor may be referred to as the processing device 701 hereinafter, and the memory may include at least one of a Read Only Memory (ROM)702, a Random Access Memory (RAM)703 and a storage device 708 hereinafter, as shown in detail below:
as shown in fig. 5, electronic device 700 may include a processing means (e.g., central processing unit, graphics processor, etc.) 701 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)702 or a program loaded from storage 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data necessary for the operation of the electronic apparatus 700 are also stored. The processing device 701, the ROM 702, and the RAM 703 are connected to each other by a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
Generally, the following devices may be connected to the I/O interface 705: input devices 706 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 707 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 708 including, for example, magnetic tape, hard disk, etc.; and a communication device 709. The communication means 709 may allow the electronic device 700 to communicate wirelessly or by wire with other devices to exchange data. While fig. 5 illustrates an electronic device 700 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer readable medium, the computer program containing program code for performing the method illustrated by the flow chart. In such embodiments, the computer program may be downloaded and installed from a network via the communication means 709, or may be installed from the storage means 708, or may be installed from the ROM 702. The computer program, when executed by the processing device 701, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable medium or any combination of the two. A computer readable medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may be any computer readable medium that is not a computer readable medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
In some embodiments, the user terminals, servers may communicate using any currently known or future developed network protocol, such as HTTP (Hyper Text transfer protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communications network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed network.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to:
intercepting a write operation of an operating system;
matching the event content of the write-in operation with a preset character string, if the current thread corresponding to the write-in operation is determined to have lock jam according to the matching result, and when the current thread successfully acquires the lock, calculating the lock jam duration of the lock jam;
and reporting a lock jam event when the lock jam duration reaches a preset threshold value.
Computer program code for carrying out operations for the present disclosure may be written in any combination of one or more programming languages, including but not limited to an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules or units described in the embodiments of the present disclosure may be implemented by software or hardware. Where the name of a module or unit does not in some cases constitute a limitation of the unit itself, for example, an intercept module may also be described as a "module intercepting write operations".
The functions described herein above may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), systems on a chip (SOCs), Complex Programmable Logic Devices (CPLDs), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing information. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
According to one or more embodiments of the present disclosure, there is provided a lock jam monitoring method including the steps of:
intercepting a write operation of an operating system;
matching the event content of the write-in operation with a preset character string, and if the current thread corresponding to the write-in operation is determined to have lock jam according to the matching result and the current thread successfully acquires the lock, calculating the lock jam duration of the lock jam;
and reporting a lock jam event when the lock jam duration reaches a preset threshold value.
In one possible implementation, the step of calculating the jam duration of the lock jam comprises:
acquiring the time of recognizing the jam start identifier as the jam start time of the lock;
acquiring the time of recognizing the blockage ending mark as the blockage ending time of the lock;
and calculating the lock jam duration according to the lock jam starting time and the lock jam ending time.
In one possible implementation, it is determined that the current thread successfully acquires the lock by: and when the blockage ending identifier in the event content corresponding to the write-in operation is identified, determining that the current thread acquires the lock successfully.
In a possible implementation manner, the step of reporting the lock blocking event includes:
acquiring event information of the lock jam, wherein the event information comprises a lock jam thread, a lock holding thread and lock jam duration;
and reporting the event information.
In a possible implementation manner, the step of intercepting the write operation of the operating system includes:
and intercepting the write-in operation of the Atrace event of the operating system in a whole-process linked list intercepting mode.
According to one or more embodiments of the present disclosure, there is provided a lock jam monitoring apparatus including:
the interception module is used for intercepting the writing operation of the operating system;
the calculation module is used for matching the event content of the write-in operation with a preset character string, and if the current thread corresponding to the write-in operation is determined to have lock jam according to the matching result and the current thread successfully acquires the lock, calculating the lock jam duration of the lock jam;
and the reporting module is used for reporting the lock jam event when the lock jam duration reaches a preset threshold value.
In one possible implementation, the calculation module includes: the device comprises a first acquisition unit, a second acquisition unit and a duration calculation unit;
a first acquisition unit, configured to acquire a time at which the jam start identifier is recognized as a lock jam start time; the second acquisition unit is used for acquiring the time for identifying the jam ending mark as the lock jam ending time; and the time length calculating unit is used for calculating the lock jam time length according to the lock jam starting time and the lock jam ending time.
In one possible implementation, it is determined that the current thread successfully acquires the lock by: and when the blockage ending identifier in the event content corresponding to the write-in operation is identified, determining that the current thread acquires the lock successfully.
In one possible implementation manner, the reporting module includes an information obtaining unit and an information reporting unit; the information acquisition unit is used for acquiring event information of the lock jam, wherein the event information comprises a lock jam thread, a lock holding thread and lock jam duration; and the information reporting unit is used for reporting the event information.
In a possible implementation manner, the interception module is configured to intercept a write operation of an trace event of the operating system in a full process linked list interception manner.
According to one or more embodiments of the present disclosure, there is provided an electronic device including:
one or more processors;
a memory;
one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, the one or more programs configured to: the monitoring method according to the lock jam is performed.
According to one or more embodiments of the present disclosure, a computer-readable medium is provided, on which a computer program is stored, which when executed by a processor implements the method of monitoring lock jams described.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.
Further, while operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.

Claims (10)

1. A method of monitoring lock jam, comprising the steps of:
intercepting a write operation of an operating system;
matching the event content of the write-in operation with a preset character string, and if the current thread corresponding to the write-in operation is determined to have lock jam according to the matching result and the lock jam duration of the lock jam is calculated when the current thread successfully acquires the lock; the preset character string is obtained by extracting key characters from the event content with over-lock jam in advance;
and reporting a lock jam event when the lock jam duration reaches a preset threshold value.
2. The method of monitoring lock jam according to claim 1, wherein the step of calculating the jam duration of the lock jam includes:
acquiring the time of recognizing the jam start identifier as the jam start time of the lock;
acquiring the time of recognizing the blockage ending mark as the blockage ending time of the lock;
and calculating to obtain the lock jam duration according to the lock jam starting time and the lock jam ending time.
3. The method of claim 1, wherein the current thread is determined to be successful in acquiring the lock by:
and when the blockage ending identifier in the event content corresponding to the write-in operation is identified, determining that the current thread acquires the lock successfully.
4. The lock jam monitoring method according to claim 1, wherein the step of reporting the lock jam event includes:
acquiring event information of the lock jam, wherein the event information comprises a lock jam thread, a lock holding thread and lock jam duration;
and reporting the event information.
5. The method of claim 1, wherein the step of intercepting a write operation by an operating system comprises:
and intercepting the write-in operation of the Atrace event of the operating system in a whole-process linked list intercepting mode.
6. A lock jam monitoring device comprising:
the interception module is used for intercepting the writing operation of the operating system;
the calculation module is used for matching the event content of the write-in operation with a preset character string, and if the current thread corresponding to the write-in operation is determined to have lock jam according to the matching result and the lock acquisition success of the current thread is achieved, calculating the lock jam duration of the lock jam; the preset character string is obtained by extracting key characters from the event content with over-lock jam in advance;
and the reporting module is used for reporting the lock jam event when the lock jam duration reaches a preset threshold value.
7. The lock jam monitoring device of claim 6 wherein the calculation module includes: a blockage starting unit, a blockage ending unit and a time length calculating unit;
the jam starting unit is used for acquiring the time of recognizing the jam starting identifier as the jam starting time of the lock;
the jam ending unit is used for acquiring the time for identifying the jam ending mark as the lock jam ending time;
and the time length calculating unit is used for calculating the lock jam time length according to the lock jam starting time and the lock jam ending time.
8. The lock jam monitoring device according to claim 6, wherein the reporting module includes: the device comprises an information acquisition unit and an information reporting unit;
the information acquisition unit is used for acquiring event information of the lock jam, wherein the event information comprises a lock jam thread, a lock holding thread and lock jam duration;
and the information reporting unit is used for reporting the event information.
9. An electronic device, comprising:
one or more processors;
a memory;
one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, the one or more programs configured to: -performing a method of monitoring a lock jam according to any one of claims 1-5.
10. A computer-readable medium, on which a computer program is stored which, when being executed by a processor, carries out the method of monitoring lock jams according to any one of claims 1 to 5.
CN202010620835.2A 2020-06-30 2020-06-30 Lock jam monitoring method and device, electronic equipment and computer readable medium Active CN111782410B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010620835.2A CN111782410B (en) 2020-06-30 2020-06-30 Lock jam monitoring method and device, electronic equipment and computer readable medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010620835.2A CN111782410B (en) 2020-06-30 2020-06-30 Lock jam monitoring method and device, electronic equipment and computer readable medium

Publications (2)

Publication Number Publication Date
CN111782410A true CN111782410A (en) 2020-10-16
CN111782410B CN111782410B (en) 2023-06-27

Family

ID=72760022

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010620835.2A Active CN111782410B (en) 2020-06-30 2020-06-30 Lock jam monitoring method and device, electronic equipment and computer readable medium

Country Status (1)

Country Link
CN (1) CN111782410B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020184295A1 (en) * 2001-05-24 2002-12-05 Ibm Corporation Method for mutual computer process monitoring and restart
US20100223600A1 (en) * 2009-02-27 2010-09-02 Microsoft Corporation Thread execution analyzer
CN103246552A (en) * 2012-02-14 2013-08-14 腾讯科技(深圳)有限公司 Method and device for preventing thread from blocking
CN107729207A (en) * 2017-09-15 2018-02-23 青岛海信电器股份有限公司 A kind of monitoring method and device of application program main thread
CN109918141A (en) * 2019-03-15 2019-06-21 Oppo广东移动通信有限公司 Thread execution method, device, terminal and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020184295A1 (en) * 2001-05-24 2002-12-05 Ibm Corporation Method for mutual computer process monitoring and restart
US20100223600A1 (en) * 2009-02-27 2010-09-02 Microsoft Corporation Thread execution analyzer
CN103246552A (en) * 2012-02-14 2013-08-14 腾讯科技(深圳)有限公司 Method and device for preventing thread from blocking
CN107729207A (en) * 2017-09-15 2018-02-23 青岛海信电器股份有限公司 A kind of monitoring method and device of application program main thread
CN109918141A (en) * 2019-03-15 2019-06-21 Oppo广东移动通信有限公司 Thread execution method, device, terminal and storage medium

Also Published As

Publication number Publication date
CN111782410B (en) 2023-06-27

Similar Documents

Publication Publication Date Title
CN111090536B (en) Method, device, medium and electronic equipment for acquiring memory leakage information
CN113835992B (en) Memory leakage processing method and device, electronic equipment and computer storage medium
CN110727566B (en) Method, device, medium and electronic equipment for acquiring process crash information
CN112214408A (en) Dependency conflict detection method and device, electronic equipment and computer readable medium
CN110618928A (en) Memory leak detection method and device, terminal equipment and medium
CN111625422B (en) Thread monitoring method, thread monitoring device, electronic equipment and computer readable storage medium
US20230033164A1 (en) Webpage image monitoring method and apparatus, electronic device, and computer-readable storage medium
CN112099982A (en) Collapse information positioning method, device, medium and electronic equipment
CN110928715A (en) Method, device, medium and electronic equipment for prompting error description information
CN112084024B (en) Memory monitoring method, device, medium and electronic equipment
CN111045926B (en) Application program jamming detection method, device, medium and electronic equipment
CN113760503A (en) Task migration method and device, electronic equipment and computer readable medium
CN116302271A (en) Page display method and device and electronic equipment
CN111782410B (en) Lock jam monitoring method and device, electronic equipment and computer readable medium
CN111984496B (en) Method, device, medium and electronic equipment for monitoring stack memory leakage
CN110764995B (en) Method, device, medium and electronic equipment for detecting file access abnormality
CN112379967B (en) Simulator detection method, device, equipment and medium
CN112084086B (en) Information collection method, device, medium and electronic equipment
CN109960659B (en) Method and device for detecting application program
CN114443480A (en) Test method, test system, readable medium and electronic device
CN111949528A (en) Memory leak detection method and device, electronic equipment and storage medium
CN110633566A (en) Intrusion detection method, device, terminal equipment and medium
CN114398233B (en) Load abnormality detection method and device, server and storage medium
CN111209042B (en) Method, device, medium and electronic equipment for establishing function stack
CN112650647B (en) Information acquisition method, device, equipment and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant after: Douyin Vision Co.,Ltd.

Address before: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant before: Tiktok vision (Beijing) Co.,Ltd.

Address after: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant after: Tiktok vision (Beijing) Co.,Ltd.

Address before: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant before: BEIJING BYTEDANCE NETWORK TECHNOLOGY Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant