CN111625422B - Thread monitoring method, thread monitoring device, electronic equipment and computer readable storage medium - Google Patents

Thread monitoring method, thread monitoring device, electronic equipment and computer readable storage medium Download PDF

Info

Publication number
CN111625422B
CN111625422B CN202010462740.2A CN202010462740A CN111625422B CN 111625422 B CN111625422 B CN 111625422B CN 202010462740 A CN202010462740 A CN 202010462740A CN 111625422 B CN111625422 B CN 111625422B
Authority
CN
China
Prior art keywords
thread
monitored
offset address
key parameter
acquiring
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.)
Active
Application number
CN202010462740.2A
Other languages
Chinese (zh)
Other versions
CN111625422A (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.)
Douyin Vision Co Ltd
Original Assignee
Douyin Vision 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 Douyin Vision Co Ltd filed Critical Douyin Vision Co Ltd
Priority to CN202010462740.2A priority Critical patent/CN111625422B/en
Publication of CN111625422A publication Critical patent/CN111625422A/en
Application granted granted Critical
Publication of CN111625422B publication Critical patent/CN111625422B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/3013Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system is an embedded system, i.e. a combination of hardware and software dedicated to perform a certain function in mobile devices, printers, automotive or aircraft systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/302Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/3024Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a central processing unit [CPU]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3051Monitoring arrangements for monitoring the configuration of the computing system or of the computing system component, e.g. monitoring the presence of processing resources, peripherals, I/O links, software programs
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computing Systems (AREA)
  • Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The disclosure provides a thread monitoring method, a thread monitoring device, electronic equipment and a storage medium, wherein the method comprises the following steps: acquiring an offset address of a key parameter in a reference thread and an offset address of a thread interface structure body, wherein the thread comprises a pointer parameter, and the key parameter comprises at least one of a thread identifier and a thread entry function; determining the offset address of the key parameter in the thread to be monitored based on the offset address of the key parameter in the reference thread, the offset address of the thread interface structure in the reference thread, the offset address of the pointer parameter in the reference thread and the thread identification of the thread to be monitored; and determining the thread related information of the thread to be monitored based on the offset address of the key parameter in the thread to be monitored. In the embodiment of the disclosure, the thread to be monitored can be effectively monitored based on the created reference thread, so that the problem of the thread running can be found in time based on the thread related information, the dynamic link library corresponding to the thread to be monitored is improved, and the user experience is improved.

Description

Thread monitoring method, thread monitoring device, electronic equipment and computer readable storage medium
Technical Field
The present disclosure relates to the field of computer technology, and in particular, to a thread monitoring method, a thread monitoring device, an electronic device, and a computer readable storage medium.
Background
The multithreading is widely applied at present, and the multithreading can fully utilize the multi-core advantage of a Central Processing Unit (CPU) to split one service into a plurality of sub-tasks, so that the logic of each sub-service can be well isolated. Multithreading has many advantages, but in embedded devices such as mobile phones, due to limited system resources, if threads are not effectively monitored, for example, for a certain service, too many threads are created, and corresponding sub-services are correspondingly completed through the created threads, so that system resources may be exhausted, and the system is blocked or crashed, thereby bringing poor experience to users.
Disclosure of Invention
The present disclosure aims to solve at least one of the above technical drawbacks, monitor a thread to be monitored while the thread is running, and discover problems in time when the thread is running. The technical scheme adopted by the present disclosure is as follows:
in a first aspect, the present disclosure provides a thread monitoring method, the method comprising:
Acquiring an offset address of a key parameter in a reference thread and an offset address of a thread interface structure body, wherein the reference thread comprises pointer parameters, and the key parameters comprise at least one of a thread identifier and a thread entry function;
determining the offset address of the key parameter in the thread to be monitored based on the offset address of the key parameter in the reference thread, the offset address of the thread interface structure body in the reference thread, the offset address of the pointer parameter in the reference thread and the thread identification of the thread to be monitored;
and determining the thread related information of the thread to be monitored based on the offset address of the key parameter in the thread to be monitored.
In a second aspect, the present disclosure provides a thread monitoring apparatus comprising:
the address acquisition module is used for acquiring an offset address of a key parameter in a reference thread and an offset address of a thread interface structure body, the reference thread comprises a pointer parameter, and the key parameter comprises at least one of a thread identifier and a thread entry function;
the address determining module is used for determining the offset address of the key parameter in the thread to be monitored based on the offset address of the key parameter in the reference thread, the offset address of the thread interface structure body in the reference thread, the offset address of the pointer parameter in the reference thread and the thread identification of the thread to be monitored;
The thread related information determining module is used for determining thread related information of the thread to be monitored based on the offset address of the key parameter in the thread to be monitored.
In a third aspect, the present disclosure provides an electronic device comprising:
a processor and a memory;
a memory for storing operation instructions;
a processor for executing the method as shown in any embodiment of the first aspect of the present disclosure by invoking an operation instruction.
In a fourth aspect, the present disclosure provides a computer-readable storage medium having stored thereon computer program instructions for causing a computer to execute to implement a method as shown in any embodiment of the first aspect of the present disclosure.
The technical scheme provided by the embodiment of the disclosure has the beneficial effects that:
according to the thread monitoring method, the device, the electronic equipment and the computer-readable electronic equipment, when the thread to be monitored is monitored, a thread (reference thread) can be created in advance, the offset address of key parameters in the reference thread and the offset address of a thread interface structure body are determined, the offset address of the key parameters, the offset address of a thread interface structure body, the offset address of pointer parameters and the thread identification of the thread to be monitored are based on the offset address of the key parameters, the offset address of the pointer parameters and the thread identification of the thread to be monitored, the key parameters are parameters reflecting the running state of the thread, and therefore information reflecting the running state of the thread to be monitored, namely thread related information, can be determined through the offset address of the key parameters in the thread to be monitored, the thread to be monitored can be effectively monitored, so that the problem when the thread is running can be found in time based on the thread related information, a dynamic link library corresponding to the thread to be monitored is improved, and the use experience of a user is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the drawings that are required to be used in the description of the embodiments of the present disclosure will be briefly introduced below.
FIG. 1 is a flow chart of a thread monitoring method according to an embodiment of the present disclosure;
FIG. 2 is a schematic diagram of a thread monitoring device according to an embodiment of the present disclosure;
fig. 3 is a schematic structural diagram of an electronic device according to an embodiment of the disclosure.
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 have been shown in the accompanying 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 are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustration purposes only and are not intended to limit the scope of the present 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. Furthermore, 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 "including" and variations thereof as used herein are intended to be 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. Related definitions of other terms will be given in the description below.
It should be noted that the terms "first," "second," and the like in this disclosure are used merely to distinguish one device, module, or unit from another device, module, or unit, and are not intended to limit the order or interdependence of the functions performed by the devices, modules, or units.
It should be noted that references to "one", "a plurality" and "a plurality" in this disclosure are intended to be illustrative rather than limiting, and those of ordinary skill in the art will appreciate that "one or more" is intended to be understood as "one or more" unless the context clearly indicates otherwise.
In the prior art, the multithreading is widely applied at present, and the multithreading can fully utilize the multi-core advantage of a Central Processing Unit (CPU) to split one service into a plurality of sub-tasks, so that the logic of each sub-service can be well isolated. Multithreading has many advantages, but in embedded devices such as mobile phones, if the system resources are limited and the threads of the service are not effectively monitored, for example, for a certain service, too many threads are created, and corresponding sub-services are correspondingly completed through the created threads, so that the system resources may be exhausted, and the system is blocked or crashed, thereby bringing poor experience to users.
In addition, in the prior art, the data structure of the threads in the system is hidden, and different versions of Read-Only Memory ROM (Read-Only Memory) may be different, so that all versions of threads cannot be compatible through one fixed data structure thread, and thus, all versions of threads are effectively monitored.
Aiming at the technical problems in the prior art, the embodiment of the disclosure provides a thread monitoring method, which can pre-create a thread when monitoring the thread in a system, determine the offset address of a key parameter in the thread, determine the offset address of the key parameter in the thread to be monitored based on the offset address of the key parameter and the offset address of a pointer parameter, and determine the offset address of the key parameter in the thread to be monitored, wherein the key parameter is a parameter reflecting the running state of the thread.
Meanwhile, the parameters of the threads to be monitored, which need to be monitored, can be dynamically acquired through the threads which are created in advance in the scheme, and compatibility problems do not need to be considered, so that the threads in different systems can be monitored through the created threads, and universality is better.
The following describes the technical solutions of the present disclosure and how the technical solutions of the present disclosure solve the above technical problems in detail with specific embodiments. The following embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments. Embodiments of the present disclosure will be described below with reference to the accompanying drawings.
The execution subject of the present disclosure may be any electronic device, such as a user terminal, e.g., for a user terminal that may include at least one thread therein.
Fig. 1 shows a flowchart of a thread monitoring method according to an embodiment of the present disclosure, where, as shown in the drawing, the disclosure uses a user terminal as an execution body for illustration, and the method may include steps S110 to S130, where:
step S110, obtaining an offset address of a key parameter in a reference thread and an offset address of a thread interface structure body, wherein the thread comprises a pointer parameter, and the key parameter comprises at least one of a thread identifier and a thread entry function.
In practical application, the reference thread may be created in advance, then when the thread runs, the offset address of the key parameter in the reference thread is obtained, the offset address of the key parameter is stored in the user terminal, when the thread runs, the offset address of the key parameter in the reference thread may be directly called, or when the reference thread runs each time, the offset address of the key parameter in the reference thread may be obtained in real time.
In an alternative aspect of the present disclosure, the key parameters include at least one of a thread identification and a thread entry function, and the pointer parameters include a front pointer and a back pointer.
The thread identifier tid is an identity of a thread, and through the thread identifier tid, which thread is known. A thread entry function is a function that is executed when a thread runs. The front pointer of the current thread is used to identify the thread before the current thread, and the back pointer is used to identify the thread after the current thread.
Step S120, determining the offset address of the key parameter in the thread to be monitored based on the offset address of the key parameter in the reference thread, the offset address of the thread interface structure in the reference thread, the offset address of the pointer parameter in the reference thread, and the thread identification of the thread to be monitored.
The thread to be monitored is a thread in the user terminal, the reference thread and the thread to be monitored can run in the same user terminal, and the data structure of the thread in the user terminal is usually hidden. Pointer parameters are parameters inherent in a thread, based on which all threads before and after the reference thread can be determined. Because the data structure of the thread to be monitored is hidden, the offset address of the key parameter in the thread to be monitored cannot be directly acquired, in the scheme, the offset address of the key parameter in the thread to be monitored can be acquired based on the created offset address of the key parameter of the reference thread, the offset address of the thread interface structure body in the reference thread, the offset address of the pointer parameter in the reference thread and the thread identification of the thread to be monitored.
Wherein, based on the thread identification of the thread to be monitored, which thread is to be monitored, when determining the offset address of the key parameter in the thread to be monitored, the offset address of the key parameter in which thread is determined can be known, and the thread to be monitored can be the thread before and/or after the reference thread.
Wherein, one user terminal may include at least one thread, and the thread to be monitored may be at least one thread of the at least one thread.
In practical applications, before monitoring a thread in a system (a system corresponding to a user terminal), a thread (a reference thread) needs to be created, where the reference thread includes a key parameter and a pointer parameter. The offset address of the key parameter and the offset address of the pointer parameter in the created thread can be obtained when the thread in the user terminal needs to be monitored.
Step S130, determining the thread related information of the thread to be monitored based on the offset address of the key parameter in the thread to be monitored.
The thread related information determined based on the offset address of the key parameter in the thread to be monitored is information capable of reflecting the running state of the thread to be monitored, so that the thread to be monitored can be effectively monitored based on the thread related information, the problem during the running of the thread can be found in time based on the thread related information, the dynamic link library corresponding to the thread to be monitored is improved, and the user experience is improved.
The above-mentioned thread related information includes, but is not limited to, a dynamic link library name (hereinafter may be simply referred to as a dynamic library name) of a dynamic link library corresponding to the thread to be monitored, a thread name of the thread to be monitored, an operation duration of the thread to be monitored, and a CPU usage duration of a central processing unit corresponding to the thread to be monitored. Based on the dynamic library names corresponding to the threads to be monitored and the thread names of the threads to be monitored, the number of threads created by each dynamic library can be known, so that the dynamic library with a large number of created threads can be found, the problems of resource exhaustion and the like of a system when the dynamic library runs are avoided, and the dynamic library is improved. A service may correspond to a dynamic link library. Similarly, based on the running time of the thread to be monitored and the use time of the CPU corresponding to the thread to be monitored, the running state of the thread can be known, the possible problems of the thread can be found in time, and timely improvement is performed.
For a user terminal, at least one application program may be included in the user terminal, and each application program may correspond to at least one thread, and based on the scheme of the present disclosure, threads corresponding to all application programs in the user terminal may be monitored, that is, when an application program runs, threads corresponding to the application program may be monitored, so as to analyze the running state of the threads corresponding to the application program, and avoid situations such as crash and blocking of the application program.
In an alternative scheme of the present disclosure, the thread related information may be sent to a server, where the thread related information may be analyzed based on a pre-configured policy to obtain an operating state in a thread operating process.
According to the scheme in the embodiment of the disclosure, when the thread to be monitored is monitored, a thread (reference thread) can be created in advance, the offset address of the key parameter in the reference thread is determined, the offset address of the key parameter in the thread to be monitored is determined based on the offset addresses of the key parameter and the pointer parameter and the thread identification of the thread to be monitored, and the key parameters are parameters reflecting the running state of the thread.
In an embodiment of the present disclosure, obtaining an offset address of a critical parameter in a reference thread and an offset address of a thread interface structure includes:
acquiring an offset address of a thread interface structure of a reference thread;
and acquiring the offset address of the key parameter in the reference thread based on the offset address of the thread interface structure of the reference thread.
In this scheme, the offset address of the thread interface structure may be used as a reference address to obtain the offset address of the key parameter in the reference thread.
In an alternative aspect of the present disclosure, obtaining an offset address of a thread interface structure of a reference thread includes:
acquiring a thread entry function of a reference thread;
based on the reference thread entry function, the offset address of the thread interface structure of the reference thread is obtained through the thread structure address calling function.
As an example, a thread (reference thread) is created by pthread_create, specifically as follows:
pthread_creat(…,my_start_routine);
wherein my_start_route is a custom thread entry function.
In this reference thread, i.e., in the my_start_route function, the pthread_self () function is called, the address of the thread structure of the reference thread itself, i.e. the offset address of the thread structure, is obtained.
In an embodiment of the present disclosure, acquiring an offset address of a key parameter in a reference thread based on an offset address of a thread interface structure of the reference thread includes:
obtaining a variable value corresponding to a thread identifier of a reference thread;
and acquiring the offset address of the thread identifier in the reference thread based on the offset address of the thread interface structure of the reference thread and the corresponding value of the thread identifier.
In each thread, the variable value corresponding to the thread identifier may be different, and then the variable value may be used as an identity basis for searching the thread identifier, and the field corresponding to the offset address of the thread interface structure body contains the variable value, and then the offset address of the thread interface structure body is used as a reference address, and the field after traversing the address from the reference address is searched for the address corresponding to the variable value, namely the offset address of the thread identifier.
In an alternative aspect of the present disclosure, the variable value of the thread identification of the thread may be obtained by a variable value acquisition function. In one example, the variable value retrieval function may be gettid (). The variable value corresponding to the thread identification of the thread itself can be obtained based on the function.
In an alternative aspect of the present disclosure, the offset address of the thread entry function may be obtained during thread operation.
In an alternative aspect of the present disclosure, the offset address of the pointer parameter may be obtained based on the offset address of the thread interface structure of the reference thread.
If the fields corresponding to the front pointer and the rear pointer are the first two fields of the thread structure, the offset addresses corresponding to the front pointer and the rear pointer can be obtained based on the fields corresponding to the offset addresses of the thread interface structure of the reference thread.
As one example, the offset of the front pointer may be denoted as 0, the offset of the rear pointer as 1, the offset address of the front pointer as prev_offset, and the offset address of the rear pointer as next_offset.
In an embodiment of the disclosure, when the pointer parameter includes a front pointer, the thread to be monitored includes a thread before the reference thread, and when the pointer parameter includes a back pointer, the thread to be monitored includes a thread after the reference thread.
It is known from the foregoing description that, when the previous pointer of the current thread is used to identify a thread before the current thread and the next pointer is used to identify a thread after the current thread, the pointer parameter includes the previous pointer, which indicates that the thread to be monitored (the thread to be monitored) is at least one of the threads before the reference thread. Similarly, when the pointer parameter includes a post pointer, it indicates that at least one of the threads following the reference thread needs to be monitored. When the pointer parameter includes a front pointer and a back pointer, it indicates that the thread to be monitored is at least one of the threads before and at least one of the threads after the reference thread.
In other words, any thread before the reference thread can be monitored based on the front pointer, any thread after the reference thread can be monitored based on the back pointer, and the thread before and after the reference thread can be monitored based on the front pointer and the back pointer.
In the embodiment of the disclosure, the thread related information includes at least one of a dynamic link library name of a dynamic link library corresponding to the thread to be monitored, a thread name of the thread to be monitored, an operation duration of the thread to be monitored and a CPU use duration of a central processing unit corresponding to the thread to be monitored; the key parameters in the thread to be monitored include at least one of a thread identification and a thread entry function.
In practical application, if the key parameter includes the thread identifier of the created thread, when determining the offset address of the key parameter in the thread to be monitored based on the offset address of the key parameter and the offset address of the pointer parameter, the offset address of the thread identifier of the thread to be monitored is included in the key parameter in the thread to be monitored. Similarly, if the critical parameter includes the thread entry function of the created thread, the critical parameter in the thread to be monitored includes the offset address of the thread entry function of the thread to be monitored when the offset address of the critical parameter in the thread to be monitored is determined based on the offset address of the critical parameter and the offset address of the pointer parameter.
In an embodiment of the present disclosure, the thread-related information includes a dynamic link library name of a dynamic link library corresponding to a thread to be monitored, and determining the thread-related information of the thread to be monitored based on an offset address of a key parameter in the thread to be monitored includes:
and acquiring the dynamic link library name of the dynamic link library corresponding to the thread to be monitored through the appointed system function based on the offset address of the thread entry function.
Based on the offset address of the thread entry function, a value corresponding to the thread entry function can be obtained and is recorded as: the start_route value may be transmitted to a specified system function to obtain a dynamic link library name of the dynamic link library corresponding to the thread to be monitored. As one example, the specified system function may be dladdr ().
The thread related information comprises the thread name of the thread to be monitored, and the thread related information of the thread to be monitored is determined based on the offset address of the key parameter in the thread to be monitored, and comprises the following steps:
obtaining thread identification from a thread name correlation directory the thread name of the thread to be monitored corresponding to the offset address;
acquiring starting time and CPU use time of a thread to be monitored from a specified directory based on the thread identification;
And determining the running time of the thread to be monitored based on the current time and the starting time.
The thread name of the thread to be monitored corresponding to the offset address of the thread identifier is stored in the thread name related directory, and then the thread name corresponding to the offset address of the thread identifier can be obtained based on the offset address of the thread identifier. As an example, in this scenario, the thread name correlation directory may be noted as: proc/self/task/pid/comm.
The starting time of the thread of each thread is stored in the appointed directory, and the CPU use time is stored in the appointed directory, so that the starting time and the CPU use time of the thread corresponding to the thread identification can be obtained from the appointed directory based on the thread identification. The current time minus the starting time of the thread is the running time of the thread.
In order to better explain the scheme of the present disclosure, the thread monitoring method of the present disclosure is specifically described below with reference to the specific embodiment:
step 1, creating a thread (reference thread) through pthread_create, specifically as follows:
pthread_creat(…,my_start_routine);
wherein my_start_route is a custom thread entry function;
step 2, calling a pthread_self () function in the reference thread, namely, the my_start_route function, and acquiring the address of the pthread structure of the reference thread, namely, the offset address of the thread structure.
In step 3, since the fields corresponding to the previous pointer prev and the next pointer next are always the first two fields of the thread structure, their offsets are 1 and 0, respectively, and their offset addresses can be denoted as prev_offset and next_offset, respectively.
And 4, calling a system function gettid () in the my_start_route function, obtaining a variable value corresponding to the thread identification tid of the thread, namely a tid value, then traversing from the offset address of the pthread structure to find the tid value, and recording a corresponding offset address after finding the tid value, namely an offset address tid_offset of the thread identification.
Step 5, starting traversing and searching from the offset address of the pthread structure body, namely finding the offset address of the my_start_route function, and marking as: route_offset.
Step 6, after the offset address of the key parameter in the reference thread is obtained, based on the offset address of the previous pointer, it can be determined which thread (to be monitored thread) is before the reference thread, and by the offset address of the subsequent pointer, it can be determined which thread (to be monitored thread) is after the reference thread.
Step 7, for the thread to be monitored, acquiring the offset address of the key parameter in the thread to be monitored, and determining the thread related information of the thread to be monitored based on the offset address of the key parameter by the following method:
1, obtaining an offset address of a thread identifier of a thread to be monitored through an offset address +tid_offset of a pthread structure;
it can be appreciated that the determined offset address of the thread identification of the thread to be monitored is used as a basis to determine the offset address of the thread identification of the thread preceding or following the thread to be monitored. As an example, if the thread to be monitored is thread a, and the thread immediately preceding the thread a is thread B, the offset address of the thread identifier of thread B may be: the offset address of the pthread structure + tid_offset (the offset address of the thread a's thread identification).
2, after determining the offset address of the thread identifier of the thread to be monitored, determining the process identifier pid corresponding to the thread identifier based on the offset address of the thread identifier of the thread to be monitored, and then obtaining the thread name of the thread to be monitored based on the directory by reading the/proc/self/task/pid/comm directory, wherein the directory contains the thread name; where comm denotes a process name.
3, based on the process identification pid corresponding to the thread identification, reading a/proc/self/task/pid/stat catalog (the catalog comprises the process identification of the thread), and acquiring the starting time and the CPU use time of the thread to be monitored based on the catalog; subtracting the starting time based on the current time uptime to obtain the actual running time of the thread to be monitored; where stat represents the running state of a thread.
And 4, acquiring an offset address start_route value of a thread entry function of the thread to be monitored through an offset address +route_offset of the pthread structure, and transferring the start_route value into a function dladd () through calling a system function dladd (), so as to acquire a dynamic library name corresponding to the start_route.
In practical application, the same principle as the determination principle of the offset address of the thread identification is adopted, the determined offset address of the thread entry function of the thread to be monitored is taken as a basis, and the offset address of the thread entry function of the thread before or after the thread to be monitored is determined. As an example, if the thread to be monitored is thread a, and the thread immediately preceding the thread a is thread B, the offset address of the thread entry function of thread B may be: the offset address of the pthread structure + route_offset (the offset address of the thread entry function of thread a).
By the method, the thread related information of each thread in the system can be obtained, and as an example, three threads of the aThread-1, the aThread-2 and the bThread-2 are monitored, and the thread related information of the three threads is obtained as shown in the following table:
the thread related information is sent to a server, and the server can analyze the running state of each thread based on the thread related information of the thread, and timely find possible problems of the thread, for example, too many threads are created corresponding to a certain dynamic library, the running efficiency is affected, and the like, so that the thread corresponding to the dynamic library can be optimized, for example, unnecessary threads are reduced.
Based on the same principle as the method shown in fig. 1, a thread monitoring apparatus 20 is further provided in an embodiment of the present disclosure, and as shown in fig. 2, the apparatus 20 may include: an address acquisition module 210, an address determination module 220, and a thread-related information determination module 230, wherein,
an address obtaining module 210, configured to obtain an offset address of a key parameter in a reference thread and an offset address of a thread interface structure, where the thread includes a pointer parameter, and the key parameter includes at least one of a thread identifier and a thread entry function;
an address determining module 220, configured to determine an offset address of a key parameter in a thread to be monitored based on the offset address of the key parameter in the reference thread, the offset address of the thread interface structure in the reference thread, the offset address of the pointer parameter in the reference thread, and the thread identification of the thread to be monitored;
the thread related information determining module 230 is configured to determine thread related information of the thread to be monitored based on the offset address of the key parameter in the thread to be monitored.
According to the scheme in the embodiment of the disclosure, when the thread to be monitored is monitored, a thread (reference thread) can be created in advance, the offset address of key parameters in the reference thread and the offset address of the thread interface structure body are determined, the offset address of key parameters in the thread to be monitored is determined based on the offset address of the key parameters, the offset address of the thread interface structure body, the offset address of pointer parameters and the thread identification of the thread to be monitored, and the key parameters are parameters reflecting the running state of the thread.
In an embodiment of the present disclosure, the address acquisition module is specifically configured to, when acquiring an offset address of a key parameter in a reference thread and an offset address of a thread interface structure:
acquiring an offset address of a thread interface structure of a reference thread;
and acquiring the offset address of the key parameter in the reference thread based on the offset address of the thread interface structure of the reference thread.
In an embodiment of the present disclosure, when the address obtaining module obtains the offset address of the key parameter in the reference thread based on the offset address of the thread interface structure of the reference thread, the address obtaining module is specifically configured to:
obtaining a variable value corresponding to a thread identifier of a reference thread;
and acquiring the offset address of the thread identifier in the reference thread based on the offset address of the thread interface structure of the reference thread and the corresponding value of the thread identifier.
In an embodiment of the disclosure, when the pointer parameter includes a front pointer, the thread to be monitored includes a thread before the reference thread, and when the pointer parameter includes a back pointer, the thread to be monitored includes a thread after the reference thread.
In an embodiment of the disclosure, the thread related information includes at least one of a dynamic link library name of a dynamic link library corresponding to the thread to be monitored, a thread name of the thread to be monitored, an operation duration of the thread to be monitored, and a central processing unit CPU usage duration corresponding to the thread to be monitored.
In the embodiment of the disclosure, the thread related information includes a dynamic link library name of a dynamic link library corresponding to the thread to be monitored, and the thread related information determining module is specifically configured to, when determining the thread related information of the thread to be monitored based on an offset address of a key parameter in the thread to be monitored:
acquiring a dynamic link library name of a dynamic link library corresponding to the thread to be monitored through a specified system function based on an offset address of a thread entry function in the thread to be monitored;
the thread related information determining module is specifically configured to, when determining thread related information of a thread to be monitored based on an offset address of a key parameter in the thread to be monitored, wherein the thread related information includes a thread name of the thread to be monitored:
acquiring the thread name of the thread to be monitored corresponding to the offset address of the thread identification in the thread to be monitored from the thread name related directory;
acquiring starting time and CPU use time of the thread to be monitored from a specified directory based on the thread identification in the thread to be monitored;
and determining the running time of the thread to be monitored based on the current time and the starting time.
The thread monitoring device according to the embodiments of the present disclosure may perform a thread monitoring method provided by the embodiments of the present disclosure, and the implementation principle of the thread monitoring method is similar, and actions performed by each module in the thread monitoring device according to each embodiment of the present disclosure correspond to steps in the thread monitoring method according to each embodiment of the present disclosure, and detailed functional descriptions of each module of the thread monitoring device may be specifically referred to descriptions in the corresponding thread monitoring method shown in the foregoing, which are not repeated herein.
Based on the same principles as the thread monitoring method in the embodiments of the present disclosure, there is also provided in the embodiments of the present disclosure an electronic device, which may include, but is not limited to: a processor and a memory; a memory for storing computer operating instructions; and the processor is used for executing the method shown in the embodiment by calling the computer operation instruction.
Based on the same principle as the thread monitoring method in the embodiments of the present disclosure, there is also provided a computer readable storage medium storing at least one operation, at least one program, a code set or an operation set, where the at least one operation, the at least one program, the code set or the operation set is loaded and executed by a processor to implement the method shown in the above embodiments, which is not described herein again.
Based on the same principle as the method in the embodiments of the present disclosure, reference is now made to fig. 3, which shows a schematic structural diagram of an electronic device (e.g. a terminal device or server in fig. 1) 600 suitable for implementing the embodiments of the present disclosure. The terminal 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., in-vehicle navigation terminals), and the like, and stationary terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 3 is merely an example and should not be construed to limit the functionality and scope of use of the disclosed embodiments.
An electronic device includes: a memory and a processor, where the processor may be referred to as a processing device 601 hereinafter, the memory may include at least one of a Read Only Memory (ROM) 602, a Random Access Memory (RAM) 603, and a storage device 608 hereinafter, as shown in detail below:
as shown in fig. 3, the electronic device 600 may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 601, which may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 602 or a program loaded from a storage means 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic apparatus 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
In general, the following devices may be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, and the like; an output device 607 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 608 including, for example, magnetic tape, hard disk, etc.; and a communication device 609. The communication means 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. While fig. 3 shows an electronic device 600 having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a non-transitory computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via communication means 609, or from storage means 608, or from ROM 602. The above-described functions defined in the methods of the embodiments of the present disclosure are performed when the computer program is executed by the processing device 601.
It should be noted that the computer readable medium described in the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage 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 context of this disclosure, a computer-readable storage 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 the present disclosure, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage 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, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
In some implementations, the clients, 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 communication 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 networks.
The computer readable medium may be contained in the electronic device; or may exist alone without being incorporated 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: acquiring an offset address of a key parameter in a reference thread and an offset address of a thread interface structure body, wherein the reference thread comprises pointer parameters, and the key parameters comprise at least one of a thread identifier and a thread entry function; determining the offset address of the key parameter in the thread to be monitored based on the offset address of the key parameter in the reference thread, the offset address of the thread interface structure in the reference thread and the offset address of the pointer parameter in the reference thread; and determining the thread related information of the thread to be monitored based on the offset address of the key parameter in the thread to be monitored.
Computer program code for carrying out operations of the present disclosure may be written in 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 kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts 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 involved in the embodiments of the present disclosure may be implemented by means of software, or may be implemented by means of hardware. Where the name of a module or unit does not in some cases constitute a limitation of the unit itself.
The functions described above herein 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: a Field Programmable Gate Array (FPGA), an Application Specific Integrated Circuit (ASIC), an Application Specific Standard Product (ASSP), a system on a chip (SOC), a Complex Programmable Logic Device (CPLD), 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. The 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. 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 thread monitoring method, comprising:
acquiring an offset address of a key parameter in a reference thread and an offset address of a thread interface structure body, wherein the thread comprises a pointer parameter, and the key parameter comprises at least one of a thread identifier and a thread entry function;
determining the offset address of the key parameter in the thread to be monitored based on the offset address of the key parameter in the reference thread, the offset address of the thread interface structure body in the reference thread, the offset address of the pointer parameter in the reference thread and the thread identification of the thread to be monitored;
and determining the thread related information of the thread to be monitored based on the offset address of the key parameter in the thread to be monitored.
According to one or more embodiments of the present disclosure, the acquiring the offset address of the key parameter in the reference thread and the offset address of the thread interface structure includes:
acquiring an offset address of a thread interface structure of the reference thread;
and acquiring the offset address of the key parameter in the reference thread based on the offset address of the thread interface structure of the reference thread.
According to one or more embodiments of the present disclosure, the obtaining, based on the offset address of the thread interface structure of the reference thread, the offset address of the key parameter in the reference thread includes:
acquiring a variable value corresponding to a thread identifier of the reference thread;
and acquiring the offset address of the thread identifier in the reference thread based on the offset address of the thread interface structure of the reference thread and the variable value corresponding to the thread identifier.
According to one or more embodiments of the present disclosure, when the pointer parameter includes a front pointer, the thread to be monitored includes a thread before the reference thread, and when the pointer parameter includes a back pointer, the thread to be monitored includes a thread after the reference thread.
According to one or more embodiments of the present disclosure, the thread related information includes a dynamic link library name of the dynamic link library corresponding to the thread to be monitored, a thread name of the thread to be monitored, at least one of a running duration of the thread to be monitored and a CPU usage duration of a central processing unit corresponding to the thread to be monitored.
According to one or more embodiments of the present disclosure, the thread related information includes a dynamic link library name of the dynamic link library corresponding to the thread to be monitored, and the determining the thread related information of the thread to be monitored based on the offset address of the key parameter in the thread to be monitored includes:
Acquiring a dynamic link library name of a dynamic link library corresponding to the thread to be monitored through a specified system function based on the offset address of the thread entry function in the thread to be monitored;
the thread related information includes a thread name of the thread to be monitored, and the determining the thread related information of the thread to be monitored based on the offset address of the key parameter in the thread to be monitored includes:
acquiring the thread name of the thread to be monitored corresponding to the offset address of the thread identification in the thread to be monitored from a thread name related directory;
acquiring starting time of the thread to be monitored and the CPU use time from a specified directory based on the thread identification in the thread to be monitored;
and determining the running time of the thread to be monitored based on the current time and the starting time.
According to one or more embodiments of the present disclosure, there is provided a thread monitoring apparatus [ example two ] comprising:
the address acquisition module is used for acquiring an offset address of a key parameter in a reference thread and an offset address of a thread interface structure body, wherein the reference thread comprises pointer parameters, and the key parameter comprises at least one of a thread identifier and a thread entry function;
The address determining module is used for determining the offset address of the key parameter in the thread to be monitored based on the offset address of the key parameter in the reference thread, the offset address of the thread interface structure body in the reference thread, the offset address of the pointer parameter in the reference thread and the thread identification of the thread to be monitored;
and the thread related information determining module is used for determining the thread related information of the thread to be monitored based on the offset address of the key parameter in the thread to be monitored.
In accordance with one or more embodiments of the present disclosure, the address acquisition module, when acquiring the offset address of the critical parameter in the reference thread and the offset address of the thread interface structure, is specifically configured to:
acquiring an offset address of a thread interface structure of the reference thread;
and acquiring the offset address of the key parameter in the reference thread based on the offset address of the thread interface structure of the reference thread.
According to one or more embodiments of the present disclosure, the address acquisition module is specifically configured to, when acquiring an offset address of a key parameter in the reference thread based on an offset address of a thread interface structure of the reference thread:
Acquiring a variable value corresponding to a thread identifier of the reference thread;
and acquiring the offset address of the thread identifier in the reference thread based on the offset address of the thread interface structure of the reference thread and the variable value corresponding to the thread identifier.
According to one or more embodiments of the present disclosure, when the pointer parameter includes a front pointer, the thread to be monitored includes a thread before the reference thread, and when the pointer parameter includes a back pointer, the thread to be monitored includes a thread after the reference thread.
According to one or more embodiments of the present disclosure, the thread related information includes a dynamic link library name of the dynamic link library corresponding to the thread to be monitored, a thread name of the thread to be monitored, at least one of a running duration of the thread to be monitored and a CPU usage duration of a central processing unit corresponding to the thread to be monitored.
According to one or more embodiments of the present disclosure, the thread-related information includes a dynamic link library name of the dynamic link library corresponding to the thread to be monitored, and the thread-related information determining module is specifically configured to, when determining the thread-related information of the thread to be monitored based on an offset address of a key parameter in the thread to be monitored:
Acquiring a dynamic link library name of a dynamic link library corresponding to the thread to be monitored through a specified system function based on the offset address of the thread entry function in the thread to be monitored;
the thread related information determining module is specifically configured to, when the thread related information includes a thread name of the thread to be monitored, determine the thread related information of the thread to be monitored based on an offset address of a key parameter in the thread to be monitored:
acquiring the thread name of the thread to be monitored corresponding to the offset address of the thread identification in the thread to be monitored from a thread name related directory;
acquiring starting time of the thread to be monitored and the CPU use time from a specified directory based on the thread identification in the thread to be monitored;
and determining the running time of the thread to be monitored based on the current time and the starting time.
The foregoing description is only of the preferred embodiments of the present disclosure and description of the principles of the technology being employed. It will be appreciated by persons skilled in the art that the scope of the disclosure referred to in this disclosure is not limited to the specific combinations of features described above, but also covers other embodiments which may be formed by any combination of features described above or equivalents thereof without departing from the spirit of the disclosure. Such as those described above, are mutually substituted with the technical features having similar functions disclosed in the present disclosure (but not limited thereto).
Moreover, although 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. In 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 limiting the scope of the present 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 example forms of implementing the claims.

Claims (9)

1. A method of thread monitoring, comprising:
acquiring an offset address of a key parameter in a reference thread and an offset address of a thread interface structure body, wherein the reference thread comprises a pointer parameter, and the key parameter comprises at least one of a thread identifier and a thread entry function;
Determining the offset address of the key parameter in the thread to be monitored based on the offset address of the key parameter in the reference thread, the offset address of the thread interface structure body in the reference thread, the offset address of the pointer parameter in the reference thread and the thread identification of the thread to be monitored;
determining thread related information of the thread to be monitored based on the offset address of the key parameter in the thread to be monitored;
the thread related information includes a dynamic link library name of the dynamic link library corresponding to the thread to be monitored and a thread name of the thread to be monitored, and the determining the thread related information of the thread to be monitored based on the offset address of the key parameter in the thread to be monitored includes:
acquiring a dynamic link library name of a dynamic link library corresponding to the thread to be monitored through a specified system function based on the offset address of the thread entry function in the thread to be monitored;
acquiring the thread name of the thread to be monitored corresponding to the offset address of the thread identification in the thread to be monitored from a thread name related directory;
acquiring starting time and CPU use time of the thread to be monitored from a specified directory based on the thread identification in the thread to be monitored;
And determining the running time of the thread to be monitored based on the current time and the starting time.
2. The method of claim 1, wherein the obtaining the offset address of the critical parameter in the reference thread and the offset address of the thread interface structure comprises:
acquiring an offset address of a thread interface structure of the reference thread;
and acquiring the offset address of the key parameter in the reference thread based on the offset address of the thread interface structure of the reference thread.
3. The method of claim 2, wherein the obtaining the offset address of the critical parameter in the reference thread based on the offset address of the thread interface structure of the reference thread comprises:
acquiring a variable value corresponding to a thread identifier of the reference thread;
and acquiring the offset address of the thread identifier in the reference thread based on the offset address of the thread interface structure of the reference thread and the variable value corresponding to the thread identifier.
4. A method according to any one of claims 1 to 3, wherein the thread to be monitored comprises a thread preceding a reference thread when the pointer parameter comprises a leading pointer and comprises a thread following a reference thread when the pointer parameter comprises a trailing pointer.
5. A method according to any one of claims 1 to 3, wherein the thread related information includes at least one of a thread name of the thread to be monitored, a running time of the thread to be monitored, and a CPU usage time of a central processing unit corresponding to the thread to be monitored, the dynamic link library name corresponding to the dynamic link library of the thread to be monitored.
6. A thread monitoring apparatus, comprising:
the address acquisition module is used for acquiring an offset address of a key parameter in a reference thread and an offset address of a thread interface structure body, wherein the reference thread comprises pointer parameters, and the key parameter comprises at least one of a thread identifier and a thread entry function;
the address determining module is used for determining the offset address of the key parameter in the thread to be monitored based on the offset address of the key parameter in the reference thread, the offset address of the thread interface structure body in the reference thread, the offset address of the pointer parameter in the reference thread and the thread identification of the thread to be monitored;
the thread related information determining module is used for determining thread related information of the thread to be monitored based on the offset address of the key parameter in the thread to be monitored; the thread related information determining module is further configured to obtain, by a specified system function, a dynamic link library name of the dynamic link library corresponding to the thread to be monitored based on an offset address of a thread entry function in the thread to be monitored; acquiring the thread name of the thread to be monitored corresponding to the offset address of the thread identification in the thread to be monitored from a thread name related directory; acquiring starting time and CPU use time of the thread to be monitored from a specified directory based on the thread identification in the thread to be monitored; and determining the running time of the thread to be monitored based on the current time and the starting time.
7. The apparatus of claim 6, wherein the address acquisition module, when acquiring the offset address of the critical parameter in the reference thread and the offset address of the thread interface structure, is specifically configured to:
acquiring an offset address of a thread interface structure of the reference thread;
and acquiring the offset address of the key parameter in the reference thread based on the offset address of the thread interface structure of the reference thread.
8. An electronic device, comprising:
a processor and a memory;
the memory is used for storing computer operation instructions;
the processor is configured to execute the method of any one of the preceding claims 1 to 5 by invoking the computer operating instructions.
9. A computer readable storage medium, characterized in that the computer readable storage medium has stored thereon computer program instructions for causing a computer to perform the method of any of the preceding claims 1 to 5.
CN202010462740.2A 2020-05-27 2020-05-27 Thread monitoring method, thread monitoring device, electronic equipment and computer readable storage medium Active CN111625422B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010462740.2A CN111625422B (en) 2020-05-27 2020-05-27 Thread monitoring method, thread monitoring device, electronic equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010462740.2A CN111625422B (en) 2020-05-27 2020-05-27 Thread monitoring method, thread monitoring device, electronic equipment and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN111625422A CN111625422A (en) 2020-09-04
CN111625422B true CN111625422B (en) 2023-07-18

Family

ID=72270195

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010462740.2A Active CN111625422B (en) 2020-05-27 2020-05-27 Thread monitoring method, thread monitoring device, electronic equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN111625422B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112181702B (en) * 2020-09-23 2023-06-06 北京紫光展锐通信技术有限公司 Thread monitoring method and device
GB202103020D0 (en) * 2021-03-03 2021-04-14 Zeroperil Ltd Methods and systems for detecting and blocking malicious actions in an operating system
CN113032215B (en) * 2021-03-24 2024-05-28 北京字节跳动网络技术有限公司 Thread snapshot analysis method, device, equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7797702B1 (en) * 2005-02-22 2010-09-14 Symantec Corporation Preventing execution of remotely injected threads
CN105550575A (en) * 2015-12-03 2016-05-04 北京神州绿盟信息安全科技股份有限公司 Method and device for obtaining un-exported function address and data structure offset
US10579806B1 (en) * 2019-08-27 2020-03-03 Zeus Sw Defender, Llc Systems and methods for dynamic reencryption of code pointers

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7689971B2 (en) * 2004-08-09 2010-03-30 Intel Corporation Method and apparatus for referencing thread local variables with stack address mapping
US7412710B2 (en) * 2004-11-12 2008-08-12 Red Hat, Inc. System, method, and medium for efficiently obtaining the addresses of thread-local variables
CN101593125B (en) * 2009-07-02 2012-03-14 上海交通大学 Method for dynamically monitoring execution flow of binary internal translator by using monitoring thread
CN107294764A (en) * 2017-04-26 2017-10-24 中国科学院信息工程研究所 Intelligent supervision method and intelligent monitoring system
US10747645B2 (en) * 2018-04-27 2020-08-18 Microsoft Technology Licensing, Llc Selectively tracing portions of computer process execution
CN110737320B (en) * 2019-09-25 2023-08-18 腾讯音乐娱乐科技(深圳)有限公司 Power consumption detection method and device, electronic equipment and storage medium
CN110888773B (en) * 2019-10-28 2023-06-06 北京字节跳动网络技术有限公司 Method, device, medium and electronic equipment for acquiring thread identification

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7797702B1 (en) * 2005-02-22 2010-09-14 Symantec Corporation Preventing execution of remotely injected threads
CN105550575A (en) * 2015-12-03 2016-05-04 北京神州绿盟信息安全科技股份有限公司 Method and device for obtaining un-exported function address and data structure offset
US10579806B1 (en) * 2019-08-27 2020-03-03 Zeus Sw Defender, Llc Systems and methods for dynamic reencryption of code pointers

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于VMIC的虚拟试验系统中信息监控研究;钱怡;杜承烈;尤涛;;计算机测量与控制(第10期);全文 *

Also Published As

Publication number Publication date
CN111625422A (en) 2020-09-04

Similar Documents

Publication Publication Date Title
CN111625422B (en) Thread monitoring method, thread monitoring device, electronic equipment and computer readable storage medium
CN110865852B (en) Webpage component loading method and device, electronic equipment and storage medium
CN113835992B (en) Memory leakage processing method and device, electronic equipment and computer storage medium
CN110673986A (en) Memory operation abnormity capturing method, device, terminal and storage medium
CN111309304B (en) Method, device, medium and electronic equipment for generating IDL file
CN112099982A (en) Collapse information positioning method, device, medium and electronic equipment
CN114328097A (en) File monitoring method and device, electronic equipment and storage medium
CN112084024B (en) Memory monitoring method, device, medium and electronic equipment
CN113391860B (en) Service request processing method and device, electronic equipment and computer storage medium
CN110888773B (en) Method, device, medium and electronic equipment for acquiring thread identification
CN110704050B (en) Module initializing method and device, electronic equipment and computer readable storage medium
CN111984496B (en) Method, device, medium and electronic equipment for monitoring stack memory leakage
CN111309323B (en) Parameter initialization method and device and electronic equipment
CN110764995B (en) Method, device, medium and electronic equipment for detecting file access abnormality
CN113176937A (en) Task processing method and device and electronic equipment
CN111782410B (en) Lock jam monitoring method and device, electronic equipment and computer readable medium
CN115827415B (en) System process performance test method, device, equipment and computer medium
CN111209042B (en) Method, device, medium and electronic equipment for establishing function stack
CN112650647B (en) Information acquisition method, device, equipment and medium
CN111399902B (en) Client source file processing method and device, readable medium and electronic equipment
CN111581305B (en) Feature processing method, device, electronic equipment and medium
CN116401173A (en) Test case generation method and device, medium and electronic equipment
CN117992204A (en) Memory detection method, device, equipment and storage medium
CN116701013A (en) Message consumption method, device, electronic equipment and computer readable medium
CN114817006A (en) Stack information writing 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: 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.

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.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant