WO2024046089A1 - Procédé de détection de processus de maintien de verrouillage et dispositif associé - Google Patents

Procédé de détection de processus de maintien de verrouillage et dispositif associé Download PDF

Info

Publication number
WO2024046089A1
WO2024046089A1 PCT/CN2023/112510 CN2023112510W WO2024046089A1 WO 2024046089 A1 WO2024046089 A1 WO 2024046089A1 CN 2023112510 W CN2023112510 W CN 2023112510W WO 2024046089 A1 WO2024046089 A1 WO 2024046089A1
Authority
WO
WIPO (PCT)
Prior art keywords
lock
holding
detection method
detection
detection thread
Prior art date
Application number
PCT/CN2023/112510
Other languages
English (en)
Chinese (zh)
Inventor
龚晨
Original Assignee
华为技术有限公司
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 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2024046089A1 publication Critical patent/WO2024046089A1/fr

Links

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/50Allocation of resources, e.g. of the central processing unit [CPU]
    • 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
    • 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/54Interprogram communication

Definitions

  • the present application relates to the field of communications, and in particular to a lock-holding process detection method and related equipment.
  • Existing operating systems (such as Linux systems) generally provide a dimensional testing mechanism to detect whether a process is stuck. When it is detected through the dimension testing mechanism that a process is stuck waiting for a lock (read-write lock, mutex lock, etc.), the operating system can print relevant information about the process. However, developers often need to analyze the information of the lock-holding process to locate the cause of the stuck, rather than the information of the process waiting for the lock, which brings greater difficulties to the developer's troubleshooting work.
  • the first aspect of the embodiment of the present application discloses a lock-holding process detection method, which includes: creating a detection thread, using the detection thread to apply for a lock in a data structure, and the data structure is located in the kernel; while the detection thread is waiting to use the applied lock, obtain Information about the process that holds the lock requested by the detection thread.
  • the lock to be detected can be added to the kernel's data structure in advance, and a detection thread can be created to apply for the lock in the data structure. If the lock applied for by the detection thread is occupied, the detection thread can wait for the applied lock to be used. , continuously obtain relevant information about the process holding the lock, for example, save the relevant information about the process holding the lock to the kernel log, so that developers can analyze based on detection when a process is stuck waiting to use the lock. The relevant information of the process holding the lock obtained by the thread locates the cause of the lock, reducing the developer's troubleshooting workload.
  • the lock-holding process detection method further includes: in response to the application not responding to the event, running the detection thread.
  • the detection thread can be created after the electronic device is started. If the application running on the electronic device does not have an application non-responsive event, the detection thread can be in a dormant state. If the application running on the electronic device has an application non-responsive event, the detection thread can be in a dormant state. When, the detection thread can be awakened to perform the operation of applying for the lock in the data structure.
  • utilizing the detection thread to apply for a lock in the data structure includes: in response to the application not responding to an event, utilizing the detection thread to apply for a lock in the data structure.
  • the detection thread can be created after the electronic device is started. If the application running on the electronic device encounters an event that the application does not respond, the detection thread can be used to apply for a lock in the data structure. If the application running on the electronic device does not respond, the detection thread can apply for a lock in the data structure. When the program is not responding to events, the detection thread can be dormant or always active.
  • using the detection thread to apply for a lock in the data structure includes: obtaining the status of each lock in the data structure based on the detection thread; if the status of the first lock in the data structure is occupied, using the detection thread to apply The first lock in the data structure.
  • the information related to the process includes stack information holding the first lock in the process.
  • the relevant information of the process includes the stack information of the lock held in the process.
  • the stack information contains the function holding the lock, so that the developer can locate the function holding the lock, that is, determine the error caused by waiting for the lock this time. Which function call does the lag occur at? This will help developers optimize the function or function call logic later.
  • obtaining the relevant information of the process holding the lock applied by the detection thread includes: starting a timer, and saving the relevant information of the process holding the lock applied by the detection thread to the kernel log based on the timer.
  • the detection thread while the detection thread is waiting to use the applied lock, it can start a timer, and use the timer to save the relevant information of the process holding the lock applied for by the detection thread to the kernel log.
  • the timer can be set.
  • the printing cycle allows the timer to periodically save the relevant information of the process holding the lock applied for by the detection thread to the kernel log while the detection thread is waiting to use the requested lock, so that developers can subsequently print the information based on the timer. Detect the process-related information of the lock requested by the thread and locate the reason why the waiting lock is stuck.
  • the relevant information of the process holding the lock applied by the detection thread is saved to the kernel log based on the timer, including: using the detection thread to obtain the pointer of the process holding the lock applied by the detection thread, and transmitting it to the timer.
  • the timer is used to run the printing function, and the printing function is used to save the relevant information of the process to the kernel log based on the pointer of the process holding the lock applied by the detection thread.
  • the detection thread while the detection thread is waiting to use the applied lock, it can start a timer and run the print function through the timer to save the relevant information of the process holding the lock applied for by the detection thread to the kernel log, such as printing
  • the function can save process-related information to the kernel log based on the pointer of the process holding the lock applied by the detection thread.
  • the lock-holding process detection method also includes: deleting the timer if the detection thread applies for a lock.
  • the detection thread applies for a lock in the data structure, indicating that the lock in the data structure is not currently occupied, or has been released by the process that previously occupied the lock.
  • the detection thread can delete the previously started timer and stop printing. Information about the process holding the lock.
  • the lock-holding process detection method further includes: if the detection thread applies for a lock, the detection thread releases the lock.
  • the detection thread applies for a lock in the data structure, indicating that the lock in the data structure is not currently occupied, or has been released by the process that previously occupied the lock.
  • the detection thread can release the lock, allowing other devices in the electronic device to The process can apply for the lock normally.
  • the data structure includes the kernel's global linked list or global array.
  • the global linked list or global array in the kernel can be used to store the lock to be detected, which facilitates the detection of the lock in the data structure applied by the thread.
  • the lock-holding process detection method further includes: in response to the application not responding to the event, obtaining the duration of the application not responding to the event; if the duration of the application not responding to the event exceeds the preset time, and the application is The process associated with the event that does not respond applies for the lock, and the process holding the lock is closed.
  • the operating system of the electronic device can forcefully close the process after the freeze occurs for a preset period of time.
  • the process of the lock allows the lock to be forcibly released, so that the process that applies for the lock can successfully apply for the lock, and avoids the problem that the process is stuck on the screen because it is waiting to use the lock, which affects the use of electronic devices by users.
  • the lock-holding process detection method further includes: in response to the application not responding to the event, obtaining the duration of the application not responding to the event; if the duration of the application not responding to the event exceeds the preset time, and the application is The process that does not respond to the event applies for the lock, and the process that applies for the lock is closed.
  • the operating system of the electronic device can forcefully close the application after the freeze occurs and lasts for a preset period of time.
  • the process allows users to touch electronic devices normally and avoids the process waiting to use the lock.
  • the screen freezes all the time, which affects users' use of electronic devices.
  • the kernel is any one of Linux kernel, Android kernel, iOS kernel, Windows kernel, and Hongmeng kernel.
  • electronic devices can include but are not limited to Linux systems, Android systems, iOS systems, Windows systems, and Hongmeng systems.
  • the kernels include but are not limited to Linux kernels, Android kernels, iOS kernels, Windows kernels, and Hongmeng kernels.
  • embodiments of the present application provide a computer-readable storage medium that includes computer instructions.
  • the computer instructions When the computer instructions are run on an electronic device, the electronic device causes the electronic device to execute the lock-holding process detection method described in the first aspect.
  • inventions of the present application provide an electronic device.
  • the electronic device includes a processor and a memory.
  • the memory is used to store instructions, and the processor is used to call instructions in the memory, so that the electronic device performs the lock-holding process as described in the first aspect. Process detection method.
  • embodiments of the present application provide a computer program product, which when the computer program product is run on an electronic device (such as a computer), causes the electronic device to execute the lock-holding process detection method as described in the first aspect.
  • a fifth aspect provides a device having the function of realizing the behavior of the electronic device in the method provided in the first aspect.
  • Functions can be implemented by hardware, or by hardware executing corresponding software.
  • Hardware or software includes one or more modules corresponding to the above functions.
  • the computer-readable storage medium described in the second aspect, the electronic device described in the third aspect, the computer program product described in the fourth aspect, and the device described in the fifth aspect are all the same as the above-mentioned first aspect. Therefore, the beneficial effects that can be achieved can be referred to the beneficial effects in the corresponding methods provided above, and will not be described again here.
  • Figure 1 is a schematic diagram of an electronic device using an existing maintenance mechanism to print out process information waiting for a lock
  • Figure 2 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • Figure 3 is a schematic diagram of the software structure of an electronic device provided by an embodiment of the present application.
  • Figure 4 is a schematic diagram of an application scenario of the lock-holding process detection technology provided by an embodiment of the present application.
  • Figure 5 is a flow chart for implementing lock-holding process detection on an electronic device provided by an embodiment of the present application
  • Figure 6 is a schematic diagram of the lock-holding process information printed by the lock-holding process detection technology provided by an embodiment of the present application;
  • Figure 7 is a schematic diagram of an application scenario of the lock-holding process detection technology provided by another embodiment of the present application.
  • FIG. 8 is a schematic flowchart of a lock-holding process detection method provided by an embodiment of the present application.
  • OS Operating System
  • Kernel Establishes a communication platform between computer software and hardware.
  • the kernel provides system services, such as file management, virtual memory, device input/output (Input/Output, I/O), etc.
  • Process It is a running activity of a program with an independent function on a certain data set.
  • the process is the basic unit of dynamic execution of the operating system. In the traditional operating system, the process is both the basic allocation unit and the basic execution unit.
  • a process can be thought of as an instance of a running program.
  • Thread It is the smallest unit that the operating system can perform calculation scheduling. Threads can be included in processes and are the actual operating units in the process. Multiple threads can run concurrently in a process, and each thread can perform different tasks in parallel.
  • Lock In multi-threaded operations, in order to ensure data consistency and ensure the security of critical code, the operating system introduces a lock mechanism. Through the lock mechanism, it can ensure that in a multi-core multi-process environment, only one thread can enter at a certain point in time. Critical section code to ensure the consistency of operating data in the critical section.
  • the Linux system provides a dimension testing mechanism to detect whether the process is stuck.
  • the dimension testing mechanism is the Hungtask mechanism.
  • the Hungtask mechanism can detect once every the first preset time (such as 30 seconds) Are critical system processes stuck?
  • a second preset time such as 90 seconds
  • Printing the stack information of a process may refer to exporting and saving the stack information of the process to a specified location, so that developers can obtain the stack information of the process from the specified location and analyze the cause of the process being stuck.
  • the init process waits for the mutex lock for more than 90 seconds, triggering the operating system to print information about the init process waiting for the mutex lock.
  • the existing dimensionality testing mechanism can only trigger the operating system to print information about processes waiting for locks, but cannot trigger the operating system to print information about processes holding mutex locks.
  • developers need to analyze the cause of process stuck based on the information of the process holding the lock, rather than the information of the process waiting for the lock, which brings greater difficulties to the developer's troubleshooting work.
  • embodiments of the present application provide a lock-holding process detection method, which can print the information of the lock-holding process when the process is stuck waiting for a lock, which facilitates developers to troubleshoot process stuck and reduces the developer's time. The workload of investigation.
  • the lock-holding process detection method provided by the embodiment of the present application can be applied to electronic devices.
  • Electronic devices of this application may include but are not limited to mobile phones, foldable electronic devices, tablet computers, personal computers (PCs), laptop computers, handheld computers, notebook computers, ultra-mobile personal computers (Ultra-mobile personal computers). , UMPC), netbook, cellular phone, personal digital assistant (PDA), augmented reality (AR) device, virtual reality (VR) device, artificial intelligence (AI) device, At least one of a wearable device, a smart home device, a car device, a smart city device, and a server.
  • the embodiments of this application do not place special restrictions on the specific type of electronic device.
  • the communication network can be a wired network or a wireless network.
  • the communication network can be a local area network (LAN) or a wide area network (WAN), such as the Internet.
  • the communication network may be a wireless fidelity (Wi-Fi) hotspot network, Wi-Fi P2P network, Bluetooth network, zigbee network or near field communication (near field communication) , NFC) network and other short-range communication networks.
  • the communication network may be a 3rd-generation wireless telephone technology (3G) network or a 4th-generation mobile communication technology (4G) network. ) network, fifth-generation mobile communication technology (5th-generation mobile communication technology, 5G) network, future evolved public land mobile network (public land mobile network, PLMN) or the Internet, etc.
  • the electronic device can install one or more APPs (Applications).
  • APP can be referred to as application, which is a software program that can realize one or more specific functions.
  • instant messaging applications may include text message applications, for example.
  • Image shooting applications for example, may include camera applications (system system camera or third-party camera application).
  • Video applications for example, may include Huawei Video.
  • Audio applications for example, may include Huawei Music.
  • the applications mentioned in the following embodiments may be system applications installed when the electronic device leaves the factory, or may be third-party applications downloaded from the Internet or obtained by the user from other electronic devices during the use of the electronic device.
  • Electronic equipment includes but is not limited to carrying Windows or other operating systems.
  • Figure 2 illustrates a schematic structural diagram of an electronic device 10.
  • the electronic device 10 may include a processor 110, an external memory interface 120, an internal memory 121, an antenna 1, an antenna 2, a mobile communication module 130, a wireless communication module 140, an audio module 150, a sensor module 160, a camera module 170, and a display screen 180. wait.
  • the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 10 .
  • the electronic device 10 may include more or fewer components than shown in the figures, or some components may be combined, some components may be separated, or some components may be arranged differently.
  • the components illustrated may be implemented in hardware, software, or a combination of software and hardware.
  • the processor 110 may include one or more processing units.
  • the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processing unit (GPU), and an image signal processor. (image signal processor, ISP), controller, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural network processor (neural-network processing unit, NPU), etc.
  • application processor application processor, AP
  • modem processor graphics processing unit
  • GPU graphics processing unit
  • image signal processor image signal processor
  • ISP image signal processor
  • controller video codec
  • digital signal processor digital signal processor
  • DSP digital signal processor
  • baseband processor baseband processor
  • neural network processor neural-network processing unit
  • the processor 110 may also be provided with a memory for storing instructions and data.
  • the memory in processor 110 may be a cache memory.
  • the memory may store instructions or data that have been used by the processor 110 or are used more frequently. If the processor 110 needs to use the instructions or data, it can be directly called from the memory. Repeated access is avoided and the waiting time of the processor 110 is reduced, thus improving the efficiency of the system.
  • processor 110 may include one or more interfaces. Interfaces may include integrated circuit (inter-integrated circuit, I2C) interface, integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, pulse code modulation (pulse code modulation, PCM) interface, universal asynchronous receiver and transmitter (universal asynchronous receiver/transmitter (UART) interface, mobile industry processor interface (MIPI), general-purpose input/output (GPIO) interface, subscriber identity module (SIM) interface, and /or universal serial bus (USB) interface, etc.
  • the processor 110 can connect to modules such as audio modules, wireless communication modules, displays, and cameras through at least one of the above interfaces.
  • the interface connection relationships between the modules illustrated in the embodiments of the present application are only schematic illustrations and do not constitute a structural limitation on the electronic device 10 .
  • the electronic device 10 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
  • the wireless communication function of the electronic device 10 can be implemented through the antenna 1, the antenna 2, the mobile communication module 130, the wireless communication module 140, the modem processor and the baseband processor.
  • the mobile communication module 130 can provide wireless communication solutions including 2G/3G/4G/5G applied on the electronic device 10 .
  • the mobile communication module 130 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc.
  • at least part of the functional modules of the mobile communication module 130 may be disposed in the processor 110 .
  • at least part of the functional modules of the mobile communication module 130 and at least part of the modules of the processor 110 may be provided in the same device.
  • the wireless communication module 140 may provide a network that is applied to the electronic device 10 including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) network), Bluetooth (bluetooth, BT), and Bluetooth low power. consumption (bluetooth low energy, BLE), ultra wideband (ultra wide band, UWB), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared technology (infrared, IR) and other wireless communications solution.
  • WLAN wireless local area networks
  • Wi-Fi wireless fidelity
  • Bluetooth bluetooth, BT
  • Bluetooth low power consumption
  • BLE ultra wideband (ultra wide band, UWB)
  • GNSS global navigation satellite system
  • FM frequency modulation
  • NFC near field communication
  • IR infrared technology
  • the wireless communication module 140 may be one or more devices integrating at least one communication processing module.
  • electronic device 10 may communicate with networks and other electronic devices through wireless communication technologies.
  • the wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), broadband Code division multiple access (wideband code division multiple access, WCDMA), time division code division multiple access (time-division code division multiple access, TD-SCDMA), long term evolution (long term evolution, LTE), BT, GNSS, WLAN, NFC , FM, and/or IR technology, etc.
  • the GNSS may include global positioning system (GPS), global navigation satellite system (GLONASS), Beidou navigation satellite system (BDS), quasi-zenith satellite system (quasi) -zenith satellite system (QZSS) and/or satellite based augmentation systems (SBAS).
  • GPS global positioning system
  • GLONASS global navigation satellite system
  • BDS Beidou navigation satellite system
  • QZSS quasi-zenith satellite system
  • SBAS satellite based augmentation systems
  • the electronic device 10 can implement display functions through a GPU, a display screen 180, an application processor, and the like.
  • the GPU is an image processing microprocessor and is connected to the display screen 180 and the application processor. GPUs are used to perform mathematical and geometric calculations for graphics rendering.
  • Processor 110 may include one or more GPUs that execute program instructions to generate or alter display information.
  • the camera module 170 includes a camera.
  • the display screen 180 is used to display images, videos, etc.
  • Display 180 includes a display panel.
  • the display panel can use a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active matrix organic light emitting diode or an active matrix organic light emitting diode (active-matrix organic light emitting diode).
  • LED organic light-emitting diode
  • AMOLED organic light-emitting diode
  • FLED flexible light-emitting diode
  • Miniled MicroLed, Micro-oLed, quantum dot light emitting diode (QLED), etc.
  • electronic device 10 may include one or more display screens 180 .
  • the external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 10 .
  • the external memory card communicates with the processor 110 through the external memory interface 120 to implement the data storage function.
  • Internal memory 121 may be used to store computer executable program code, which includes instructions.
  • the internal memory 121 may include a program storage area and a data storage area.
  • the stored program area can store an operating system, at least one application program required for a function (such as a sound playback function, an image playback function, etc.).
  • the storage data area may store data created during use of the electronic device 10 and the like.
  • the internal memory 121 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.
  • the processor 110 executes various functional methods or data processing of the electronic device 10 by executing instructions stored in the internal memory 121 and/or instructions stored in a memory provided in the processor.
  • the audio module 150 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. Audio module 150 may also be used to encode and decode audio signals. In some embodiments, the audio module 150 may be disposed in the processor 110 , or some functional modules of the audio module 150 may be disposed in the processor 110 .
  • the software system of the electronic device 10 may adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture.
  • the embodiment of this application takes the Android system with a layered architecture as an example to illustrate the software structure of the electronic device 10 .
  • FIG. 3 is a software structure block diagram of the electronic device 10 according to an embodiment of the present application.
  • the layered architecture divides the software into several layers, and each layer has clear roles and division of labor.
  • the layers communicate through software interfaces.
  • the Android system is divided into five layers, with application layers from top to bottom.
  • Application layer application framework layer, Android runtime (ART) and native C/C++ library, hardware abstraction layer (HAL) and kernel layer.
  • ART Android runtime
  • HAL hardware abstraction layer
  • the application layer can include a series of application packages.
  • the application package can include camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message and other applications.
  • the application framework layer provides an application programming interface (API) and programming framework for applications in the application layer.
  • API application programming interface
  • the application framework layer includes some predefined functions.
  • the application framework layer can include window manager, content provider, view system, resource manager, notification manager, activity manager, input manager, etc.
  • the window manager provides window management service (Window Manager Service, WMS).
  • WMS can be used for window management, window animation management, surface management, and as a transfer station for the input system.
  • Content providers are used to store and retrieve data and make this data accessible to applications.
  • Said data can include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
  • the view system includes visual controls, such as controls that display text, controls that display pictures, etc.
  • a view system can be used to build applications.
  • the display interface can be composed of one or more views.
  • a display interface including a text message notification icon may include a view for displaying text and a view for displaying pictures.
  • the resource manager provides various resources to applications, such as localized strings, icons, pictures, layout files, video files, etc.
  • the notification manager allows applications to display notification information in the status bar, which can be used to convey notification-type messages and can automatically disappear after a short stay without user interaction.
  • the notification manager is used to notify download completion, message reminders, etc.
  • the notification manager can also be notifications that appear in the status bar at the top of the system in the form of charts or scroll bar text, such as notifications for applications running in the background, or notifications that appear on the screen in the form of conversation windows. For example, text information is prompted in the status bar, a beep sounds, the electronic device vibrates, the indicator light flashes, etc.
  • the input manager can provide input management service (Input Manager Service, IMS).
  • IMS can be used to manage system input, such as touch screen input, key input, sensor input, etc.
  • IMS takes out events from the input device node and distributes the events to appropriate windows through interaction with WMS.
  • the Android runtime includes core libraries and Android runtime.
  • the Android runtime is responsible for converting source code into machine code.
  • the Android runtime mainly includes the use of ahead of time (ahead or time, AOT) compilation technology and just in time (just in time, JIT) compilation technology.
  • the core library is mainly used to provide basic Java class library functions, such as basic data structures, mathematics, IO, tools, databases, networks and other libraries.
  • the core library provides APIs for users to develop Android applications.
  • Native C/C++ libraries can include multiple function modules. For example: surface manager (surface manager), media framework (Media Framework), libc, OpenGL ES, SQLite, Webkit, etc.
  • the surface manager is used to manage the display subsystem and provides the integration of 2D and 3D layers for multiple applications.
  • the media framework supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc.
  • the media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
  • OpenGL ES provides the drawing and manipulation of 2D graphics and 3D graphics in applications. SQLite provides a lightweight relational database for electronic device 10 applications.
  • the hardware abstraction layer runs in user space, encapsulates the kernel layer driver, and provides a calling interface to the upper layer.
  • the kernel layer is the layer between hardware and software.
  • the kernel layer contains at least display driver, camera driver, audio driver, and sensor driver.
  • the electronic device 10 is introduced using a mobile phone as an example.
  • the electronic device 10 is installed with an operating system.
  • the electronic device 10 is also installed with multiple APPs.
  • the electronic device 10 can create a corresponding application process, and the application process can realize various functions of the corresponding APP.
  • the electronic device creates a Huawei Video APP process.
  • the user can use the Huawei Video APP process to watch videos online in full screen or watch videos offline.
  • the Huawei Video APP When the process of the Huawei Video APP needs to wait for a lock because it accesses certain data (such as data in a shared memory), if the waiting time for the lock exceeds the threshold set by the system, the Huawei Video APP displayed on the user interface of the electronic device 10 will get stuck. action, for example, it prompts that Huawei video is not responding.
  • the threshold can be set according to actual requirements, which is not limited in this application. For example, the threshold can be 5 seconds.
  • the embodiment of this application provides a maintenance and testing mechanism that can obtain the process holding the lock applied for by Huawei Video when the process of the Huawei Video APP is stuck waiting for the lock, and print the relevant information of the process holding the lock. It is convenient for developers to investigate the reasons why the Huawei Video APP process is stuck.
  • FIG. 5 it is a flow chart for implementing lock-holding process detection for the electronic device of the present application.
  • the operating system installed on the electronic device 10 is a Linux system as an example for explanation.
  • developers can add locks to be detected to the data structure of the kernel according to actual needs.
  • This application does not limit the locks to be detected, for example, they can be mutex locks, mmap_sem locks, etc.
  • This application does not limit the data structure of the kernel, which can be used to store locks to be detected.
  • the data structure of the kernel can be a global linked list of the kernel, a global array of the kernel, etc.
  • S52 Create a detection thread, and use the detection thread to apply for a lock in the data structure.
  • the detection thread may refer to a kernel thread, and the kernel thread is used to apply for a lock located in a data structure of the kernel.
  • the detection thread can be created after the electronic device 10 is started. After the detection thread is created, it performs an operation of applying for a lock in the data structure.
  • the data structure can be added with multiple locks to be detected, and the detection thread can apply for multiple locks to be detected in a preset method.
  • the preset method can be set according to actual needs. This application does not limit this. For example, it can be based on Each lock is applied in sequence in the order in which it is added to the data structure, or each lock in the data structure can be applied in sequence according to custom rules.
  • the detection thread After executing the operation of applying for the lock in the data structure once, the detection thread can perform the operation of applying for the lock in the data structure again at a third preset time interval, or it can immediately perform the operation of applying for the lock in the data structure again without interruption.
  • the third preset time can be set according to actual needs, and this application does not limit this.
  • the detection thread has completed an operation of applying for a lock in the data structure, which may mean that the detection thread has completed an operation of applying for each lock in the data structure.
  • the detection thread may also perform the operation of applying for a lock in the data structure in response to a preset event after creation.
  • the preset events can be set according to actual needs, and this application does not limit this.
  • the preset event may be detecting that the electronic device 10 freezes or freezes during operation.
  • the preset event may be an Application Not Response (ANR) event occurring in the APP running on the electronic device 10.
  • ANR Application Not Response
  • the running detection thread applies for a lock in the data structure.
  • the detection thread is in a dormant state, or when the APP running on the electronic device 10 does not have an ANR event, the detection thread does not execute the application data structure although it is in an active state (active state). lock operation.
  • the purpose of using the detection thread to apply for a certain lock in the data structure is to detect the process holding the lock and analyze why the process holding the lock does not release the lock for a long time, causing other processes to wait to use the lock. And stuck.
  • the detection thread will keep trying to apply until the application is successful.
  • the first lock is a lock to be detected.
  • the developer can add the first lock to the data structure in advance.
  • the first lock is a mutex lock. If the first lock in the data structure applied for by the detection thread is in the occupied state, the detection thread can start a timer and use the timer to continuously print relevant information about the process holding the first lock while the detection thread is waiting to use the first lock. .
  • the timer prints the relevant information of the process holding the first lock by specifying a timer to run a print function and saving the relevant information of the process to a specified location, such as a kernel log.
  • the timer can set a printing cycle, and the timer can periodically print information related to the process holding the first lock based on the preset printing cycle.
  • the timer can periodically print the relevant information of the process holding the first lock by specifying the timer to run a print function, and save the relevant information of the process holding the first lock to the kernel log through the print function.
  • the detection thread can obtain the pointer of the process holding the first lock and pass it to the timer.
  • the timer can periodically run the printing function based on the printing cycle.
  • the printing function Information about the process that holds the first lock can be printed based on the pointer of the process.
  • the related information of the process may include stack information holding the first lock in the process.
  • the stack information contains the function that holds the first lock, so that developers can locate the function that holds the first lock, that is, determine which function call occurred when the APP was stuck while waiting for the lock, which is convenient for developers. Subsequent optimization of the function or function calling logic will be carried out.
  • the kernel when the kernel creates a process, the kernel assigns a unique process identification number (PID) to the process.
  • PID process identification number
  • the detection thread can obtain the process holding the first lock based on the PID of the process holding the first lock.
  • a pointer to the process that holds the lock. The pointer can refer to the first address saved by the process in the system memory.
  • the detection thread deletes the timer.
  • the detection thread can delete the previously started timing
  • the processor stops printing information about the process holding the first lock.
  • the detection thread applies for the first lock in the data structure, it can release the first lock so that other processes can apply for the first lock.
  • the electronic device 10 is installed with Huawei Video APP, and the detection thread can be automatically created after the electronic device 10 is turned on.
  • the Huawei Video APP process may have to wait for a certain lock to be used when accessing certain data (for example, Lock1), and the waiting time for the lock exceeds the threshold set by the system, the Huawei Video APP will be stuck in the user interface of the electronic device 10, for example, a prompt box pops up indicating that Huawei Video is unresponsive.
  • the electronic device 10 can apply for lock Lock1 through the detection thread. While the detection thread is waiting to use lock Lock1, timer T1 is started, and timer T1 runs the printing function, using the timer T1 period. Continuously save the stack information of the process holding lock Lock1 to the kernel In the log, it is convenient for developers to analyze the reason why the process holding lock Lock1 does not release lock Lock1 for a long time based on the information saved in the kernel log, so as to make targeted improvements. That is, developers can analyze the information saved to the kernel log by timer T1. The analysis revealed the reason why the time the Huawei Video APP process waits for using Lock1 exceeds the threshold set by the system.
  • the operating system can forcefully close the APP after the lag occurs and lasts for a preset period of time.
  • the operating system of the electronic device 10 can forcefully close the Huawei Video APP process. , so that the user can touch the electronic device 10 normally, or close the process holding the lock Lock1, so that the process of the Huawei Video APP can apply for the lock Lock1.
  • the fourth preset time can be set according to actual needs, and this application does not limit this. For example, as shown in Figure 7, the process of Huawei Video APP is stuck due to waiting for Lock 1 to be used. The duration exceeds the fourth preset time or the waiting time for lock exceeds the fourth preset time, and the operating system of the electronic device 10 is forced to shut down. The process of Huawei Video APP returns to the main interface.
  • an embodiment of the present application provides a lock process detection method, which is applied to the electronic device 10 .
  • the lock-holding process detection method may include:
  • the data structure is located in the kernel.
  • This application does not limit the data structure. It can be used to store the lock to be detected.
  • the data structure can be a global linked list of the kernel, a global array of the kernel, etc. This application does not limit the kernel. Since the operating systems installed on the electronic device 10 are different, the kernels are also different.
  • the kernel can be any one of Linux kernel, Android kernel, iOS kernel, Windows kernel, and Hongmeng kernel.
  • the detection thread can be created after the electronic device 10 is started. After the detection thread is created, it performs an operation of applying for a lock in the data structure.
  • the data structure can be added with multiple locks to be detected, and the detection thread can apply for multiple locks to be detected in a preset way.
  • the preset way can be set according to actual needs. This application does not limit this. For example, it can be based on Each lock is applied in sequence in the order in which it is added to the data structure, or each lock in the data structure can be applied in sequence according to custom rules.
  • the detection thread may also perform the operation of applying for a lock in the data structure in response to a preset event after creation.
  • the preset events can be set according to actual needs, and this application does not limit this.
  • the preset event may be detecting that the electronic device 10 is stuck or stuck during operation.
  • the preset event may be that an ANR event occurs in the APP running on the electronic device 10 .
  • the running detection thread applies for a lock in the data structure.
  • no ANR occurs in the APP running on the electronic device 10
  • the detection thread is in a dormant state, or when the APP running on the electronic device 10 does not experience an ANR event, although the detection thread is in an active state, it does not perform the operation of applying for a lock in the data structure.
  • the purpose of using the detection thread to apply for a certain lock in the data structure is to detect the process holding the lock and analyze why the process holding the lock does not release the lock for a long time, causing other processes to wait to use the lock. And stuck.
  • the detection thread can start a timer, and while the detection thread is waiting to use the lock, the timer can be used to continuously print information about the process holding the lock.
  • Process-related information may include stack information that holds the lock in the process. stack letter The information contains the function that holds the lock, so that developers can locate the function that holds the lock, and can determine which function call occurred when waiting to use the lock and caused the APP to get stuck, which is convenient for developers to follow up. Optimize the function or function calling logic.
  • the detection thread starts a timer
  • you can configure a scheduled printing cycle and the timer periodically prints the stack information of the process holding the lock based on the preset printing cycle.
  • the timer periodically prints the stack information of the process holding the lock.
  • the detection thread can obtain the pointer of the process holding the lock and pass it to the timer.
  • the timer can run the printing function periodically based on the printing cycle, and the printing function can run the printing function based on the printing cycle.
  • the pointer to the process holding the lock saves its stack information to the kernel log.
  • the kernel when the kernel creates a process, the kernel assigns a unique PID to the process.
  • the detection thread can obtain the pointer of the process holding the lock based on the PID of the process holding the lock, and will hold the process.
  • the pointer of the process that holds the lock is passed to the timer.
  • the detection thread can delete the previously started timer and stop printing.
  • the stack information of the process holding the lock if the detection thread applies for a lock in the data structure, indicating that the lock in the data structure is not occupied or has been released by the process that previously occupied the lock, the detection thread can delete the previously started timer and stop printing. The stack information of the process holding the lock.
  • the detection thread after the detection thread applies for a lock in the data structure, it can release the lock so that other processes can apply for the lock.
  • the operating system of the electronic device 10 can also continue to preset when the jam occurs. After a certain period of time, the process of APP A1 is forced to close or the process holding the lock is closed to prevent the process of APP A1 from being stuck on the screen because it is waiting to use the lock, which affects the normal use of the electronic device 10 by the user. For example, if the duration of the ANR event of the process of APP A1 exceeds the fourth preset time, and the process of APP A1 triggers the ANR event because it is waiting to use the lock, the operating system can forcefully close the process of APP A1.
  • the process of APP A1 triggers the ANR event because it is waiting to use a lock, and the lock is being held by another process of APP A2,
  • the operating system can forcefully close the process of APP A2 holding the lock.
  • the internal memory 121 can be used to store instructions, and the processor 110 can be used to call instructions in the internal memory 121, so that the electronic device 10 executes the above related method steps to implement the lock-holding process detection in the above embodiment. method.
  • Embodiments of the present application also provide a computer storage medium that stores computer instructions.
  • the electronic device 10 causes the electronic device 10 to execute the above related method steps to achieve the above embodiments. Lock-holding process detection method.
  • An embodiment of the present application also provides a computer program product.
  • the computer program product When the computer program product is run on an electronic device, it causes the electronic device to perform the above related steps to implement the lock-holding process detection method in the above embodiment.
  • inventions of the present application also provide a device.
  • This device may be a chip, a component or a module.
  • the device may include a connected processor and a memory.
  • the memory is used to store computer execution instructions.
  • the processor can execute computer execution instructions stored in the memory, so that the chip executes the lock-holding process detection method in each of the above method embodiments.
  • the computer storage media, computer program products or chips provided by the embodiments of the present application are all used to execute the corresponding methods provided above. Therefore, the beneficial effects they can achieve can be referred to the corresponding methods provided above. The beneficial effects will not be repeated here.
  • the disclosed devices and methods can be Implemented in other ways.
  • the device embodiments described above are schematic.
  • the division of modules or units is a logical function division.
  • multiple units or components may be combined or can be integrated into another device, or some features can be ignored, or not implemented.
  • the coupling or direct coupling or communication connection between each other shown or discussed may be through some interfaces, and the indirect coupling or communication connection of the devices or units may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated.
  • the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place, or they may be distributed to multiple different places. . Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • each functional unit in each embodiment of the present application can be integrated into one processing unit, each unit can exist physically alone, or two or more units can be integrated into one unit.
  • the above integrated units can be implemented in the form of hardware or software functional units.
  • the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in a readable storage medium.
  • the storage medium includes a number of instructions to cause a device (which can be a microcontroller, a chip, etc.) or a processor to execute all or part of the steps of the methods described in various embodiments of this application.
  • the aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other media that can store program code. .

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

Les modes de réalisation de la présente demande se rapportent au domaine des communications. L'invention concerne un procédé de détection de processus de maintien de verrouillage et un dispositif associé. Le procédé de détection de processus de maintien de verrou consiste à : créer un fil de détection et demander un verrou dans une structure de données à l'aide du fil de détection, la structure de données étant située dans un noyau; et pendant que le fil de détection attend d'utiliser le verrou demandé, acquérir des informations associées d'un processus, qui maintient le verrou pour lequel le fil de détection s'applique. Selon la présente demande, un fil de détection s'applique pour un verrou à soumettre à une détection et tandis que le fil de détection attend d'utiliser le verrou, des informations associées d'un processus, qui maintient le verrou, sont acquises, de telle sorte que, sur la base des informations associées du processus, qui maintient le verrou, un développeur peut ensuite analyser la raison pour laquelle un autre processus est bloqué en raison de l'attente d'utilisation du verrou.
PCT/CN2023/112510 2022-08-31 2023-08-11 Procédé de détection de processus de maintien de verrouillage et dispositif associé WO2024046089A1 (fr)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211059212.8A CN117667430A (zh) 2022-08-31 2022-08-31 持锁进程检测方法及相关设备
CN202211059212.8 2022-08-31

Publications (1)

Publication Number Publication Date
WO2024046089A1 true WO2024046089A1 (fr) 2024-03-07

Family

ID=90064945

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/112510 WO2024046089A1 (fr) 2022-08-31 2023-08-11 Procédé de détection de processus de maintien de verrouillage et dispositif associé

Country Status (2)

Country Link
CN (1) CN117667430A (fr)
WO (1) WO2024046089A1 (fr)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2010139260A1 (fr) * 2009-06-04 2010-12-09 中兴通讯股份有限公司 Procédé et dispositif de détection d'arrêt fatal de mécanisme de verrouillage de transaction de base de données
CN107247630A (zh) * 2017-06-05 2017-10-13 努比亚技术有限公司 线程检测方法、终端及计算机可读存储介质
CN111045926A (zh) * 2019-11-05 2020-04-21 北京字节跳动网络技术有限公司 一种应用程序卡顿的检测方法、装置、介质和电子设备
CN112099960A (zh) * 2020-09-21 2020-12-18 天津神舟通用数据技术有限公司 一种基于路径推进的分布式死锁检测方法
CN112579307A (zh) * 2020-12-10 2021-03-30 腾讯科技(深圳)有限公司 一种物理锁资源的分配检测方法、装置及电子设备
CN113778696A (zh) * 2021-08-19 2021-12-10 北京小米移动软件有限公司 线程控制方法、线程控制装置及存储介质
CN114064300A (zh) * 2021-11-01 2022-02-18 上海浦东发展银行股份有限公司 线程死锁检测方法、装置、设备、介质和计算机程序产品
CN114625545A (zh) * 2020-12-10 2022-06-14 华为技术有限公司 进程持锁检测方法及其电子设备和可读介质

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2010139260A1 (fr) * 2009-06-04 2010-12-09 中兴通讯股份有限公司 Procédé et dispositif de détection d'arrêt fatal de mécanisme de verrouillage de transaction de base de données
CN107247630A (zh) * 2017-06-05 2017-10-13 努比亚技术有限公司 线程检测方法、终端及计算机可读存储介质
CN111045926A (zh) * 2019-11-05 2020-04-21 北京字节跳动网络技术有限公司 一种应用程序卡顿的检测方法、装置、介质和电子设备
CN112099960A (zh) * 2020-09-21 2020-12-18 天津神舟通用数据技术有限公司 一种基于路径推进的分布式死锁检测方法
CN112579307A (zh) * 2020-12-10 2021-03-30 腾讯科技(深圳)有限公司 一种物理锁资源的分配检测方法、装置及电子设备
CN114625545A (zh) * 2020-12-10 2022-06-14 华为技术有限公司 进程持锁检测方法及其电子设备和可读介质
CN113778696A (zh) * 2021-08-19 2021-12-10 北京小米移动软件有限公司 线程控制方法、线程控制装置及存储介质
CN114064300A (zh) * 2021-11-01 2022-02-18 上海浦东发展银行股份有限公司 线程死锁检测方法、装置、设备、介质和计算机程序产品

Also Published As

Publication number Publication date
CN117667430A (zh) 2024-03-08

Similar Documents

Publication Publication Date Title
US11922100B2 (en) System and method for energy usage accounting in software applications
US20200057660A1 (en) Method and system for rendering user interfaces
US11210109B2 (en) Method and system for loading resources
JP6333965B2 (ja) ウェイクロック使用を追跡する技術
US11036568B1 (en) Enabling execution of program instructions in the background
CN104076903B (zh) 推迟挂起
JP5753908B2 (ja) コンピューティングオブジェクトのコンテキストの履歴
US9619304B2 (en) Automatic connections between application components
EP3992796A1 (fr) Procédé, appareil et dispositif de communication inter-processus
US9274913B2 (en) Event pages for web applications and extensions
US20180052723A1 (en) Middleware Interface and Middleware Interface Generator
WO2019128588A1 (fr) Procédé et appareil de traitement de processus, dispositif électronique et support d'informations lisible par ordinateur
WO2023065916A1 (fr) Procédé de traitement de notification, puce, dispositif électronique et support de stockage lisible par ordinateur
US20180196584A1 (en) Execution of multiple applications on a device
WO2019128574A1 (fr) Procédé et dispositif de traitement d'informations, dispositif informatique et support d'informations lisible par ordinateur
CN114625545A (zh) 进程持锁检测方法及其电子设备和可读介质
WO2019128573A1 (fr) Procédé de traitement d'informations, appareil, dispositif informatique et support d'informations lisible par ordinateur
WO2021027772A1 (fr) Procédé pour commuter l'exécution d'une application et dispositif
CN116257262A (zh) 内核升级方法、芯片、电子设备及计算机可读存储介质
WO2024046088A1 (fr) Procédé de planification de tâches et dispositif associé
WO2024046089A1 (fr) Procédé de détection de processus de maintien de verrouillage et dispositif associé
CN114816031B (zh) 终端设备的省电方法、终端设备及介质
WO2019128545A1 (fr) Procédé de gestion de processus, dispositif électronique et support d'informations lisible par ordinateur
WO2023173896A1 (fr) Procédé de communication, dispositif électronique et support d'enregistrement lisible
WO2024027391A1 (fr) Procédé de gestion de tâche et dispositif associé

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23859123

Country of ref document: EP

Kind code of ref document: A1