CN113778696A - Thread control method, thread control device, and storage medium - Google Patents

Thread control method, thread control device, and storage medium Download PDF

Info

Publication number
CN113778696A
CN113778696A CN202110954555.XA CN202110954555A CN113778696A CN 113778696 A CN113778696 A CN 113778696A CN 202110954555 A CN202110954555 A CN 202110954555A CN 113778696 A CN113778696 A CN 113778696A
Authority
CN
China
Prior art keywords
thread
lock
call stack
time
printing
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.)
Pending
Application number
CN202110954555.XA
Other languages
Chinese (zh)
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 Xiaomi Mobile Software Co Ltd
Original Assignee
Beijing Xiaomi Mobile Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Xiaomi Mobile Software Co Ltd filed Critical Beijing Xiaomi Mobile Software Co Ltd
Priority to CN202110954555.XA priority Critical patent/CN113778696A/en
Publication of CN113778696A publication Critical patent/CN113778696A/en
Pending legal-status Critical Current

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
    • 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/526Mutual exclusion algorithms

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The present disclosure relates to a thread control method, a thread control apparatus, and a storage medium. The thread control method comprises the following steps: and monitoring the lock holding state of the thread, printing a first thread call stack under the condition that the first thread holds the lock and the second thread fails to apply for the lock, and quickly positioning a jam point according to a task recorded in the first thread call stack. Compared with the scheme of printing the overtime information after waiting for the first thread to release the lock, the method and the device can acquire the call stack of the first thread for many times in the process that the first thread holds the lock, and improve the efficiency of positioning the blocking point.

Description

Thread control method, thread control device, and storage medium
Technical Field
The present disclosure relates to the field of information processing, and in particular, to a thread control method, a thread control apparatus, and a storage medium.
Background
Android is used as a mainstream operating system of a mobile terminal, mutual dependency exists among a plurality of threads of some processes, the threads with dependency are synchronized through mechanisms such as synchronous locking, and if one of the threads with mutual dependency is blocked due to overlong lock holding time, the whole Android system can be affected to be stuck, even stuck and restarted (ANR). In order to solve the phenomenon of stuck or dead restarting of the Android system, a jam point needs to be located so as to know the cause of the jam and provide a solution for solving the jam, but how to locate the jam point needs to be solved urgently.
Disclosure of Invention
To overcome the problems in the related art, the present disclosure provides a thread control method, a thread control apparatus, and a storage medium.
According to a first aspect of an embodiment of the present disclosure, there is provided a thread control method including:
and monitoring the lock holding state of the thread, and printing a call stack of the first thread in response to the condition that the first thread holds the lock and the second thread fails to apply for the lock.
In one embodiment, the thread control method further comprises:
and printing the call stack of the first thread again in response to the second thread reapplying for the lock and failing to apply for the lock.
In one embodiment, before printing the first thread call stack again, the thread control method further comprises:
and determining that a time interval meets a preset time interval threshold, and/or the number of times of printing of the first thread call stack is smaller than a printing number threshold, wherein the time interval is the time interval between the time when the current second thread application lock fails and the time when the first thread call stack is printed last time.
In one embodiment, the thread control method further comprises:
recording a time stamp of printing a first thread call stack; the time interval is determined based on the timestamp and a time at which the current second thread failed to apply for the lock.
In one embodiment, before printing the first thread call stack, the thread control method further comprises:
and determining that the timeout parameter added in the synchronous function of each thread represents timeout.
In one embodiment, the second thread comprises the same thread, or a plurality of different threads.
According to a second aspect of the embodiments of the present disclosure, there is provided a line control apparatus including:
the monitoring unit is used for monitoring the locking state of the thread; and the control unit is used for printing the call stack of the first thread in response to the condition that the first thread holds the lock and the second thread fails to apply for the lock.
In one embodiment, the control unit is configured to:
and printing the call stack of the first thread again in response to the second thread reapplying for the lock and failing to apply for the lock.
In one embodiment, the control unit is configured to:
before the first thread call stack is printed again, determining that a time interval meets a preset time interval threshold value, and/or the number of times of printing of the first thread call stack is smaller than a printing number threshold value, wherein the time interval is the time interval between the time when the current second thread application lock fails and the time when the first thread call stack is printed last time.
In one embodiment, the thread control apparatus further comprises:
the recording unit is used for recording a time stamp of printing the first thread call stack; the time interval is determined based on the timestamp and a time at which the current second thread failed to apply for the lock.
In one embodiment, the control unit is configured to:
and before the first thread call stack is printed, determining that the overtime parameter added in the synchronous function of each thread represents overtime.
In one embodiment, the second thread comprises the same thread, or a plurality of different threads.
According to a third aspect of the embodiments of the present disclosure, there is provided a line control apparatus including:
a processor; a memory for storing processor-executable instructions; wherein the processor is configured to execute the thread control method described in the first aspect or any implementation manner of the first aspect.
According to a fourth aspect of the embodiments of the present disclosure, there is provided a non-transitory computer-readable storage medium, wherein instructions of the storage medium, when executed by a processor of a mobile terminal, enable the mobile terminal to perform the thread control method described in the first aspect or any one of the implementation manners of the first aspect.
The technical scheme provided by the embodiment of the disclosure can have the following beneficial effects: and monitoring the lock holding state of the thread, printing a first thread call stack under the condition that the first thread holds the lock and the second thread fails to apply for the lock, and quickly positioning a jam point according to a task recorded in the first thread call stack. Compared with the scheme of printing the overtime information after waiting for the first thread to release the lock, the method and the device can acquire the call stack of the first thread for many times in the process that the first thread holds the lock, and improve the efficiency of positioning the blocking point.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure.
FIG. 1 is a schematic diagram illustrating an android native scheme, according to an example embodiment.
FIG. 2 is a flow diagram illustrating a process control method according to an exemplary embodiment.
FIG. 3 is a diagram illustrating a print lockhold timeout call stack in accordance with an illustrative embodiment.
FIG. 4 is a flow diagram illustrating a process control method according to an exemplary embodiment.
FIG. 5 is a block diagram illustrating a thread control device according to an exemplary embodiment.
FIG. 6 is a block diagram illustrating an apparatus in accordance with an example embodiment.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
FIG. 1 is a schematic diagram illustrating an android native scheme, according to an example embodiment. As shown in FIG. 1, thread A, thread B, and thread C compete for the same lock, and thread B first acquires and holds the lock at time B1. Thread A applies for the lock at time A1, and because thread B holds the lock, thread A fails to apply the lock, so thread A waits for thread B to release the lock. In addition, thread C applies for the lock at time C1, and since thread B holds the lock and thread C fails to apply the lock, thread C waits for thread B to release the lock. In the process, the time a1 may be later than the time B1 or equal to the time B1, and similarly, the time C1 may be later than the time a1 and/or the time B1, may be earlier than the time a1, or may be equal to the time a1 and/or the time B1. Thread B releases the lock at time B2, and thread a and thread C may again apply for the lock at any time during the lock holding time of thread B. The time interval between time B1 and time B2 is determined as the lock holding time for thread B.
While thread a and thread C wait for thread B to release the lock, android system stuck, or even ANR, may result. In the related art, in order to determine the cause of the android system stuck or even ANR problem, the relationship between the lock holding time of the thread B and the set lock holding time threshold is determined, and when the lock holding time of the thread B exceeds the lock holding time threshold, the thread B is controlled to print the timeout information, that is, the log of the thread B, after releasing the lock at time B2. However, the log does not record all task information processed by the thread B between the time B1 and the time B2 in detail, so that related personnel cannot locate the blocking point of the android system stuck or even the ANR according to the log. It should be noted that, in the embodiment of the present disclosure, the thread a, the thread B, and the thread C are taken as examples to illustrate a phenomenon that a plurality of threads contend for the same lock and cause android system stuck, even ANR, but it does not indicate that only three threads exist in a case of contending for the lock.
In summary, the native android scheme in the related art has the following technical problems:
1. native android prints the information of a thread only after the lock holding thread releases the lock, but this does not reflect the thread's condition during lock holding.
2. Native android cannot reflect execution at the time of blocking through the call stack of the waiting thread.
In view of this, the embodiments of the present disclosure provide a thread control method. According to the thread control method, the lock holding state of each thread is monitored, for convenience of description, the lock holding thread is represented by a first thread, and other threads competing for the same lock with the first thread are represented by a second thread. And printing the call stack of the first thread under the condition that the lock of the first thread is monitored and the lock application of the second thread fails. The related personnel can position the jam point by the information of the first thread processing task recorded in the first thread call stack. The second thread may be the same thread or a plurality of different threads. For example, the first thread is thread B and the second thread is thread a and/or thread C. The technical scheme provided by the embodiment of the disclosure is suitable for controlling two or more threads.
FIG. 2 is a flow diagram illustrating a process control method according to an exemplary embodiment. As shown in fig. 2, the thread control method includes the following steps.
In step S11, the lock status of the thread is monitored.
In the disclosed embodiment, the lock holding state of the thread includes that the thread holds the lock and the thread applies for the lock but fails to apply for the lock. And determining whether to print the call stack of the thread with the lock or not on the basis of monitoring that each thread holds the lock and/or the thread applies for the lock but fails to apply for the lock, and realizing the purpose of positioning a jam point by printing the call stack of the thread with the lock.
In step S12, in response to detecting that the first thread holds a lock and the second thread fails to apply for the lock, the first thread call stack is printed.
And printing a first thread call stack for positioning a jam point under the condition that the first thread is monitored to hold a lock and the second thread fails to apply for the lock. In the embodiment of the present disclosure, it is monitored that the first thread holds the lock, and at the same time, it is monitored that the second thread applies for holding the lock, but the second thread fails to apply for the lock because the first thread already holds the lock, and at this time, the second thread waits for the first thread to release the lock, and re-applies for the lock at the time interval set for re-applying for the lock. In the above process, if the lock holding time of the first thread is too long, that is, the lock holding time exceeds the set lock holding time threshold, the waiting time of the second thread is too long, and further the android system is stuck or even the ANR is caused. In order to enable research and development personnel to locate the reason causing the android system stuck or even the ANR problem, a scheme for solving the problem is further provided, so that when the situation that the first thread holds the lock and the second thread fails to apply for the lock is monitored, a call stack of the first thread is printed, and the research and development personnel can find the scheme for solving the problem by analyzing tasks processed by the first thread during the lock holding period.
In one implementation, FIG. 3 is a diagram illustrating a print locktimeout call stack, according to an example embodiment. As shown in fig. 3, based on the related art, if it is detected that thread a applies for a lock at a time point a1, but the lock is already held by thread B, resulting in a failure for thread a to apply for the lock, thread B is printed and the stack is called. Continuing to monitor that thread a applies for a lock at time a2, but the lock is not released by thread B, again resulting in thread a failing to apply for a lock, thread B calls the stack again. Similarly, if thread C is detected to apply for a lock at C1, but the lock is already held by thread B, resulting in a failure of thread C to apply for a lock, then thread B is printed to call the stack. Continuing to monitor that thread C applied for a lock at C2, but the lock was not released by thread B, again resulting in thread C failing to apply for a lock, thread B calls the stack again. Where a1, a2, B1, B2, C1 and C2 are different times on the same time axis, the time interval between the times B1 and B2 is the lock holding duration of the thread B, the times a1, a2 and C1, C2 may be any time from the time B1 to the time B2 of the thread B, and the time a1 may be equal to the time C1, and the time a2 may also be equal to the time C2.
In this embodiment, during the time that thread B holds the lock, if there are other threads (e.g., thread A and/or thread B) that fail the request, the call stack for thread B is printed, rather than simply going into a wait state. Taking thread A as an example, if thread A reappears for a lock from time A1 at a certain time interval to time A2, if reapplication fails, the call stack of thread B may be printed again. Task information processed by the thread B between the time A1 and the time A2 is conveniently obtained, and a basis is provided for related personnel to locate a jam point.
In the embodiment of the disclosure, when it is monitored that the second thread re-applies for the lock and the first thread does not release the lock, which causes the second thread to fail to apply for the lock, the first thread call stack is printed again, so as to obtain a task list executed by the first thread in a process of re-applying for the lock after the second thread passes a set time interval. Through the technical scheme provided by the embodiment of the disclosure, the first thread call stack can be printed when the second thread application lock is monitored and the application lock fails, the second thread re-application lock can be monitored, and the first thread call stack is continuously printed under the condition that the second thread application lock fails again because the first thread does not release the lock.
In this embodiment of the present disclosure, before printing the first thread call stack again, it is necessary to determine whether a time interval between a time when the current second thread application lock fails and a time when the first thread call stack is printed last time meets a preset time interval threshold, and/or whether the number of times the first thread call stack has been printed meets a print number threshold. The value of the time interval between two times of printing the first thread call stack can be set according to the requirement of a user and is used as the time interval threshold. In one embodiment, the first thread call stack may be printed again if a time interval between the time when the second thread applies for the lock failure and the time when the first thread call stack was printed last satisfies a preset time interval threshold. The first thread call stack may also be printed again in the event that the number of times the first thread call stack has been printed is less than the print number threshold. The first thread call stack can be printed again under the condition that the time interval between the current time for printing the first thread call stack and the last time for printing the first thread call stack meets a preset time interval threshold value and the printed times of the first thread call stack are smaller than the printing times threshold value.
It should be noted that the time when the second thread fails to apply for the lock may be the time when the call stack of the first thread is printed. That is, if the time interval between the time when the second thread fails to apply for the lock and the time when the first thread call stack is printed last time meets the time interval threshold, the first thread call stack is printed at the time when the second thread fails to apply for the lock. That is, the time when the current second thread fails to apply for the lock is taken as the time for printing the first thread call stack, that is, the time when the current second thread fails to apply for the lock is taken as the starting time for printing the first thread call stack next time.
And recording a time stamp when the first thread call stack is printed every time, and determining a time interval based on the time stamp of the last printing of the first thread call stack and the time of the current failure of applying for the lock by the second thread. When the second thread is monitored to reapply for the lock and the lock application fails, the time of printing the call stack of the first thread at the last time is obtained, and whether the time interval between the time of applying the lock failure of the second thread at present and the time of printing the call stack of the first thread at the last time meets a preset time interval threshold value or not is judged. And if the time interval between the time when the current second thread fails to apply for the lock and the time when the first thread call stack is printed last time meets the time interval threshold, printing the first thread call stack, otherwise, not printing the first thread call stack. A time interval threshold value between two times of printing of the first thread call stack is preset, and resource loss caused by frequent printing of the first thread call stack is avoided by judging whether the time interval between the time of preparing to print the first thread call stack and the time of printing the first thread call stack last time meets the time interval threshold value. In other words, if the first thread holds the lock, but a plurality of different second threads simultaneously apply for the lock at short intervals and the lock application fails, if the time interval threshold for printing the call stacks of the first thread is not set, the call stacks of the first thread corresponding to the number of the second threads are printed according to the number of the second threads, and frequent printing of the call stacks of the first thread in a short time may result in a longer lock holding time for the first thread. In order to avoid the defect of repeatedly printing the first thread call stack in a short time, before the first thread call stack is printed again, the relation between the time interval and the preset time interval threshold value is judged, if the time interval is determined to meet the preset time interval threshold value, the first thread call stack is printed again until the second thread application lock is successful.
In the embodiment of the present disclosure, a threshold of the number of times of printing of the first thread call stack may also be set, and when the number of times of printing of the first thread call stack is smaller than the threshold of the number of times of printing, the first thread call stack is printed again until the number of times of printing of the first thread call stack is greater than or equal to the threshold of the number of times of printing or the second thread application lock is successful. Thus, the utilization rate of resources can be improved.
In this embodiment, a timeout parameter is added to the synchronization function of each thread for backing off the wait at the second thread wait setting time. In the monitoring process of the android system, if the overtime parameter added in the synchronous function of each thread is monitored to represent overtime, the first thread call stack is printed.
FIG. 4 is a flow diagram illustrating a process control method according to an exemplary embodiment. As shown in FIG. 4, in one embodiment, a thread control method includes the following steps.
In step S21, a timeout parameter is added to the synchronization funex () function where each thread applies for a lock.
In step S22, if the return value of futex () is the connection timeout ETIMEDOUT and the maximum number of prints has not been exceeded, the first thread is requested to print the call stack.
The contents of the return value of funex () are determined and the call stack of the first thread is printed if the return value of funex () is a connection timeout ETIMEDOUT instead of EINTR or EAGAIN.
In step S23, the print first thread call stack needs to hold the thread _ list _ lock and release the thread _ list _ lock in time when the call stack print is complete or an exception occurs.
In step S24, the first Thread records the time stamp of the print call through the TLSDate data structure of the Thread object. And if the time interval is too close, the first thread call stack is not printed.
In step S25, printing the first Thread call stack requires finding the Thread object pointer of the first Thread according to the tid in the Thread list of the application.
In step S26, printing the first thread call stack requires that the execution of the first thread be paused through ScopedObjectAccess.
In step S27, the first Thread call stack is printed by a function such as dumpp javastack () of the first Thread object.
In the thread control method in this embodiment, a lock is applied again after monitoring a second thread interval setting time, and if the lock fails again, the first thread call stack is printed again after determining that a time interval between the current lock application failure time and the last time the first thread call stack is printed satisfies a time interval threshold. And continuously monitoring the lock holding state of each thread until the second thread applies for the lock successfully or the number of times of printing the call stack of the first thread exceeds the threshold value of the number of times of printing.
Based on the same conception, the embodiment of the disclosure also provides a line control device.
It is to be understood that, in order to implement the above functions, the thread control device provided in the embodiments of the present disclosure includes a hardware structure and/or a software module for performing each function. The disclosed embodiments can be implemented in hardware or a combination of hardware and computer software, in combination with the exemplary elements and algorithm steps disclosed in the disclosed embodiments. Whether a function is performed as hardware or computer software drives hardware depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present disclosure.
FIG. 5 is a block diagram illustrating a thread control device according to an exemplary embodiment. Referring to fig. 5, the thread control apparatus 100 includes a monitoring unit 101 and a control unit 102.
The monitoring unit 101 is used for monitoring the lock holding state of the thread; the control unit 102 is configured to print the call stack of the first thread in response to monitoring that the lock is held by the first thread and the lock application failure of the second thread.
In one embodiment, the control unit 102 is configured to:
and printing the first thread call stack again in response to the second thread reapplying the lock and failing to apply the lock.
In one embodiment, the control unit 102 is configured to:
before the first thread call stack is printed again, the time interval is determined to meet a preset time interval threshold value, and/or the printed times of the first thread call stack are smaller than a printing time threshold value, wherein the time interval is the time interval between the time when the current second thread application lock fails and the time when the first thread call stack is printed last time.
In one embodiment, the thread control apparatus further comprises:
a recording unit 103 for recording a time stamp of printing the first thread call stack; the time interval is determined based on the timestamp and a time at which the current second thread failed to apply for the lock.
In one embodiment, the control unit 102 is configured to:
before printing a first thread call stack, determining that the timeout parameter added in the synchronous function of each thread represents timeout.
In one embodiment, the second thread comprises the same thread, or a plurality of different threads.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
FIG. 6 is a block diagram illustrating an apparatus 200 for thread control in accordance with an example embodiment. For example, the apparatus 200 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, an exercise device, a personal digital assistant, and the like.
Referring to fig. 6, the apparatus 200 may include one or more of the following components: a processing component 202, a memory 204, a power component 206, a multimedia component 208, an audio component 210, an input/output (I/O) interface 212, a sensor component 214, and a communication component 216.
The processing component 202 generally controls overall operation of the device 200, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing components 202 may include one or more processors 220 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 202 can include one or more modules that facilitate interaction between the processing component 202 and other components. For example, the processing component 202 can include a multimedia module to facilitate interaction between the multimedia component 208 and the processing component 202.
The memory 204 is configured to store various types of data to support operations at the apparatus 200. Examples of such data include instructions for any application or method operating on the device 200, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 204 may be implemented by any type or combination of volatile or non-volatile memory devices, such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
Power components 206 provide power to the various components of device 200. Power components 206 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for device 200.
The multimedia component 208 includes a screen that provides an output interface between the device 200 and the user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 208 includes a front facing camera and/or a rear facing camera. The front camera and/or the rear camera may receive external multimedia data when the device 200 is in an operating mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 210 is configured to output and/or input audio signals. For example, audio component 210 includes a Microphone (MIC) configured to receive external audio signals when apparatus 200 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may further be stored in the memory 204 or transmitted via the communication component 216. In some embodiments, audio component 210 also includes a speaker for outputting audio signals.
The I/O interface 212 provides an interface between the processing component 202 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor component 214 includes one or more sensors for providing various aspects of status assessment for the device 200. For example, the sensor assembly 214 may detect an open/closed state of the device 200, the relative positioning of components, such as a display and keypad of the device 200, the sensor assembly 214 may also detect a change in the position of the device 200 or a component of the device 200, the presence or absence of user contact with the device 200, the orientation or acceleration/deceleration of the device 200, and a change in the temperature of the device 200. The sensor assembly 214 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 214 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 214 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 216 is configured to facilitate wired or wireless communication between the apparatus 200 and other devices. The device 200 may access a wireless network based on a communication standard, such as WiFi, 4G or 5G, or a combination thereof. In an exemplary embodiment, the communication component 216 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 216 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the apparatus 200 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer readable storage medium comprising instructions, such as memory 204, comprising instructions executable by processor 220 of device 200 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
It is understood that "a plurality" in this disclosure means two or more, and other words are analogous. "and/or" describes the association relationship of the associated objects, meaning that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship. The singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It will be further understood that the terms "first," "second," and the like are used to describe various information and that such information should not be limited by these terms. These terms are only used to distinguish one type of information from another and do not denote a particular order or importance. Indeed, the terms "first," "second," and the like are fully interchangeable. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of the present disclosure.
It will be further understood that, unless otherwise specified, "connected" includes direct connections between the two without the presence of other elements, as well as indirect connections between the two with the presence of other elements.
It is further to be understood that while operations are depicted in the drawings in a particular order, this is not to be understood as requiring that such operations be performed in the particular order shown or in serial order, or that all illustrated operations be performed, to achieve desirable results. In certain environments, multitasking and parallel processing may be advantageous.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is to be limited only by the scope of the appended claims.

Claims (14)

1. A thread control method, comprising:
monitoring the lock holding state of the thread;
and printing the call stack of the first thread in response to the condition that the first thread holds the lock and the second thread fails to apply for the lock.
2. The thread control method according to claim 1, further comprising:
and printing the call stack of the first thread again in response to the second thread reapplying for the lock and failing to apply for the lock.
3. The thread control method of claim 2, wherein prior to reprinting the first thread call stack, the thread control method further comprises:
and determining that a time interval meets a preset time interval threshold, and/or the number of times of printing of the first thread call stack is smaller than a printing number threshold, wherein the time interval is the time interval between the time when the current second thread application lock fails and the time when the first thread call stack is printed last time.
4. The thread control method according to claim 3, further comprising:
recording a time stamp of printing a first thread call stack;
the time interval is determined based on the timestamp and a time at which the current second thread failed to apply for the lock.
5. The thread control method of any of claims 1 to 4, wherein prior to printing the first thread call stack, the thread control method further comprises:
and determining that the timeout parameter added in the synchronous function of each thread represents timeout.
6. The method of claim 1, wherein the second thread comprises a same thread or a plurality of different threads.
7. A line control apparatus, comprising:
the monitoring unit is used for monitoring the locking state of the thread;
and the control unit is used for printing the call stack of the first thread in response to the condition that the first thread holds the lock and the second thread fails to apply for the lock.
8. The thread control apparatus of claim 7, wherein the control unit is configured to:
and printing the call stack of the first thread again in response to the second thread reapplying for the lock and failing to apply for the lock.
9. The thread control apparatus of claim 8, wherein the control unit is configured to:
before the first thread call stack is printed again, determining that a time interval meets a preset time interval threshold value, and/or the number of times of printing of the first thread call stack is smaller than a printing number threshold value, wherein the time interval is the time interval between the time when the current second thread application lock fails and the time when the first thread call stack is printed last time.
10. The thread control apparatus of claim 9, further comprising:
the recording unit is used for recording a time stamp of printing the first thread call stack;
the time interval is determined based on the timestamp and a time at which the current second thread failed to apply for the lock.
11. The thread control apparatus according to any one of claims 7 to 10, wherein the control unit is configured to:
and before the first thread call stack is printed, determining that the overtime parameter added in the synchronous function of each thread represents overtime.
12. The thread control apparatus of claim 7, wherein the second thread comprises a same thread or a plurality of different threads.
13. A line control apparatus, comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to perform the thread control method of any one of claims 1 to 6.
14. A storage medium having stored therein instructions that, when executed by a processor of a mobile terminal, enable the mobile terminal to perform the thread control method of any one of claims 1 to 6.
CN202110954555.XA 2021-08-19 2021-08-19 Thread control method, thread control device, and storage medium Pending CN113778696A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110954555.XA CN113778696A (en) 2021-08-19 2021-08-19 Thread control method, thread control device, and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110954555.XA CN113778696A (en) 2021-08-19 2021-08-19 Thread control method, thread control device, and storage medium

Publications (1)

Publication Number Publication Date
CN113778696A true CN113778696A (en) 2021-12-10

Family

ID=78838432

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110954555.XA Pending CN113778696A (en) 2021-08-19 2021-08-19 Thread control method, thread control device, and storage medium

Country Status (1)

Country Link
CN (1) CN113778696A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024046089A1 (en) * 2022-08-31 2024-03-07 华为技术有限公司 Lock-holding process detection method and related device

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024046089A1 (en) * 2022-08-31 2024-03-07 华为技术有限公司 Lock-holding process detection method and related device

Similar Documents

Publication Publication Date Title
CN105955765B (en) Application preloading method and device
EP3163884A1 (en) Image acquiring method and apparatus, computer program and recording medium
CN109565753B (en) Method and device for controlling beam failure recovery process
US20190250789A1 (en) Method and device for controlling display interface
EP3015983B1 (en) Method and device for optimizing memory
CN107783790B (en) Terminal awakening method and device
CN113703937A (en) Animation switching method and device and storage medium
CN105912204B (en) Method and device for starting application interface
CN108958911B (en) Process control method and device
CN109076595B (en) Random access control method and random access control device
CN113778696A (en) Thread control method, thread control device, and storage medium
CN109076619B (en) Random access control method and random access control device
CN109491655B (en) Input event processing method and device
CN105786561B (en) Method and device for calling process
US10558973B2 (en) Method and apparatus for card activation
CN115604132A (en) Remote control method and device for server, electronic equipment and readable storage medium
CN112286687A (en) Resource processing method and device
CN114661606A (en) Program debugging method and device, electronic equipment and storage medium
CN114860242A (en) Compiling method, compiling device and storage medium
CN112817844A (en) Background process residence test method, device, equipment and storage medium
CN113360254A (en) Task scheduling method and system
CN112231132A (en) Application program jamming positioning method and device, electronic equipment and medium
EP3806544A1 (en) Ac restriction method and device
CN116662028A (en) Information processing method and device, electronic equipment and storage medium
CN114531493B (en) Request processing method and device, electronic equipment and storage 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