Thread scheduling priority processing method and display equipment
By marking and prioritizing critical threads in display devices, the problem of slow interaction response speed is solved, and faster user operation response is achieved.
Patent Information
- Application Number
- CN202510149921.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-08
- Publication Date
- 2025-07-04
AI Technical Summary
The interactive response speed of the display device is not fast enough, which affects the user experience.
By detecting that the target method is called during the running of the display device, the key thread corresponding to the target method is marked, its execution status is obtained, and the thread priority in the wake-up chain is raised when the critical thread has been completed, and the thread priority in the lock queue is raised when the critical thread is not completed.
Improve the response speed of interactive operations and improve the speed and efficiency of user operations.
Smart Images

Figure CN120256041A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of display devices, and particularly to a thread scheduling priority processing method and a display device. Background Art
[0002] With the rapid development of display devices, the functions that display devices can provide for users are becoming increasingly rich. Users can perform various interactive operations on the display device, such as button operations, starting application operations, controlling audio and video playback status operations, etc. How to improve the response speed of interactive operations is an urgent problem to be solved. Summary of the Invention
[0003] This application provides a thread scheduling priority processing method and a display device to solve the problem that the response speed of interactive operations is not fast enough.
[0004] In a first aspect, some embodiments provide a thread scheduling priority processing method, including:
[0005] When it is detected that a target method is called during the operation of the display device, mark the key thread corresponding to the target method;
[0006] Obtain the execution status of the marked key thread;
[0007] When the marked key thread has been executed, obtain the thread wake-up chain where the marked key thread is located, and increase the priority of the threads after the marked key thread in the wake-up chain;
[0008] When the marked key thread has not been executed, obtain the lock queue of the data resources operated by the marked key thread, and increase the priority of the threads before the marked key thread in the lock queue.
[0009] In some embodiments, the target method is a response method triggered by a button, and the key threads corresponding to the target method include at least one of the main thread of the foreground application, the rendering thread of the foreground application, the input reading thread, or the input distribution thread;
[0010] Or;
[0011] The target method is a response method for starting an application, and the key threads corresponding to the target method include at least one of the main thread of the foreground application, the main thread of the target application to be started, or the rendering thread of the target application;
[0012] Or;
[0013] The target method is a response method for entering the playback state, and the key threads corresponding to the target method include at least one of the playback thread or the codec thread of the foreground application.
[0014] In some embodiments, the method further includes:
[0015] Inserting a hook point into the response method corresponding to at least one interaction operation; and using each response method with the inserted hook point as a target method;
[0016] Detecting whether the corresponding target method is called through the inserted hook point.
[0017] In some embodiments, obtaining the execution status of the marked critical thread includes:
[0018] Putting the marked critical thread into the critical thread queue;
[0019] In the case where there are multiple marked critical threads in the critical thread queue, obtaining the execution status of each marked critical thread.
[0020] In some embodiments, the method further includes:
[0021] Enabling a scheduling event monitoring service during the startup process of the display device, and extracting scheduling-related events from all events recorded by the kernel tracing tool through the scheduling event monitoring service. The scheduling-related events include at least one of a scheduling switch event, a scheduling wake-up event, or a wake-up status event;
[0022] Obtaining the thread wake-up chain where the marked critical thread is located, including:
[0023] Performing thread wake-up analysis on the scheduling-related events to obtain the thread wake-up chain where the marked critical thread is located.
[0024] In some embodiments, the method further includes:
[0025] Inserting a hook point into the locking method and unlocking method corresponding to each data resource;
[0026] Enabling a lock queue monitoring service during the startup process of the display device. The lock queue monitoring service detects the lock status of each data resource through the inserted hook point and updates the lock queue of each data resource based on the lock status;
[0027] Obtaining the lock queue of the data resource operated by the marked critical thread, including:
[0028] Obtaining the lock queue of the data resource operated by the marked critical thread from the lock queue monitoring service.
[0029] In some embodiments, the method further includes:
[0030] Putting the marked critical thread into the critical thread queue;
[0031] When the target method is the response method for starting an application, after the target application requested to start is successfully started, the main thread of the foreground application is removed from the critical thread queue;
[0032] When the target method is the response method for entering the playback state, when it is detected that the playback state is exited, the playback thread and the codec thread of the foreground application are removed from the critical thread queue.
[0033] In a second aspect, a display device is provided, including: at least one processor configured to execute instructions to cause the display device to:
[0034] When it is detected during the operation of the display device that the target method is called, based on the pre-set correspondence between the method and the critical thread, the critical thread corresponding to the target method is marked;
[0035] Obtain the execution status of the marked critical thread;
[0036] When the marked critical thread has been executed, obtain the thread wake-up chain where the marked critical thread is located, and promote the priority of the threads after the marked critical thread in the wake-up chain;
[0037] When the marked critical thread has not been executed, obtain the lock queue of the data resources operated by the marked critical thread, and promote the priority of the threads before the marked critical thread in the lock queue.
[0038] In a third aspect, a display device is provided, including: a memory and a processor, the memory stores a computer program, and when the processor executes the computer program, the method provided in the first aspect is implemented.
[0039] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the method provided in the first aspect is implemented.
[0040] In a fifth aspect, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the method provided in the first aspect is implemented.
[0041] The above thread scheduling priority processing method, electronic device, computer-readable storage medium, and computer program product mark a key thread corresponding to a target method when it is detected that the target method is called during the operation of a display device; obtain the execution status of the marked key thread; when the marked key thread has been executed, obtain the thread wake-up chain in which the marked key thread is located, and boost the priority of the threads after the marked key thread in the wake-up chain; when the marked key thread has not been executed, obtain the lock queue of the data resources operated by the marked key thread, and boost the priority of the threads before the marked key thread in the lock queue. This can improve the quick response of the interaction operation corresponding to the target method. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] To more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following briefly introduces the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0043] Figure 1 Schematic diagram of the operation scenario between a display device and a control device provided by some embodiments of the present application;
[0044] Figure 2 Schematic diagram of the hardware configuration of a display device provided by some embodiments of the present application;
[0045] Figure 3 Schematic diagram of the hardware configuration of a control device provided by some embodiments of the present application;
[0046] Figure 4 Schematic diagram of the software configuration of a display device provided by some embodiments of the present application;
[0047] Figure 5 Schematic diagram of the flow of the thread scheduling priority processing method provided by some embodiments of the present application;
[0048] Figure 6 Schematic diagram of the system framework provided by some embodiments of the present application;
[0049] Figure 7 Schematic diagram of the logic of the thread scheduling priority processing method provided by some embodiments of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0050] Embodiments will be described in detail below, and examples thereof are shown in the accompanying drawings. When the following description refers to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following examples do not represent all embodiments consistent with the present application. They are merely examples of systems and methods consistent with some aspects of the present application detailed in the claims.
[0051] It should be noted that the brief description of the terms in this application is only for the convenience of understanding the embodiments described next, rather than intending to limit the embodiments of the present application. Unless otherwise specified, these terms should be understood in their ordinary and common meanings.
[0052] The terms "first", "second", "third", etc. in the specification, claims and the above-mentioned drawings of this application are used to distinguish similar or like objects or entities, and do not necessarily mean to limit a specific order or sequence, unless otherwise noted. It should be understood that such terms can be interchanged under appropriate circumstances.
[0053] The terms "comprising" and "having" and any variations thereof are intended to cover but not exclude inclusion. For example, a product or device comprising a series of components does not have to be limited to all the components clearly listed, but may include other components not clearly listed or inherent to these products or devices.
[0054] The term "module" refers to any known or later developed hardware, software, firmware, artificial intelligence, fuzzy logic or a combination of hardware or / and software code that can perform functions related to that element.
[0055] In the embodiments of the present application, the display device 200 generally refers to a device with the ability to display images and process data. For example, the display device 200 includes but is not limited to smart TVs, mobile terminals, computers, monitors, advertising screens, wearable devices, virtual reality devices, augmented reality devices, etc.
[0056] Figure 1 It is a schematic diagram of the operation scenario between the display device and the control device provided for some embodiments of the present application. As Figure 1 shown, the user can operate the display device 200 through touch operations, the mobile terminal 300 and the control device 100. For example, the control device 100 can be a remote control, a stylus, a handle, etc.
[0057] The mobile terminal 300 can be used as a control device to perform human-computer interaction between the user and the display device 200. The mobile terminal 300 can also be used as a communication device to establish a communication connection with the display device 200 for data interaction. In some embodiments, software applications can be installed on the mobile terminal 300 and the display device 200, and the connection communication can be achieved through network communication protocols to achieve the purpose of one-to-one control operations and data communication. It is also possible to transmit the audio and video content displayed on the mobile terminal 300 to the display device 200 to achieve the synchronous display function.
[0058] As Figure 1 also shown in, the display device 200 also performs data communication with the server 400 through various communication methods. The display device 200 is allowed to establish a communication connection through a local area network (LAN), a wireless local area network (WLAN), and other networks.
[0059] The display device 200 can provide a broadcast receiving television function, and can also additionally provide an intelligent network television function with computer support functions, including but not limited to, network television, smart television, Internet Protocol Television (IPTV), etc.
[0060] Figure 2 For some embodiments of this application Figure 1 The hardware configuration block diagram of the display device 200 in
[0061] In some embodiments, the display device 200 may include at least one of a tuner demodulator 210, a communication device 220, a detector 230, a device interface 240, a controller 250, a display 260, an audio output device 270, a memory, a power supply, and a user input interface.
[0062] In some embodiments, the detector 230 is used to collect signals from the external environment or interact with the outside. For example, the detector 230 includes a light receiver, a sensor for collecting the intensity of environmental light; or, the detector 230 includes an image collector, such as a camera, which can be used to collect external environmental scenes, user attributes, or user interaction gestures. Or, the detector 230 includes a sound collector, such as a microphone, etc., for receiving external sounds.
[0063] In some embodiments, the display 260 includes a display function component for presenting a picture and a driving component for driving image display. The display 260 is used to receive the image signal output from the controller 250 for display. For example, the display 260 can be used to display video content, image content, components of a menu manipulation interface, and a user manipulation UI interface, etc.
[0064] In some embodiments, the communication device 220 is a component for communicating with an external device or server 400 according to various communication protocol types. The display device 200 may be provided with a plurality of communication devices 220 according to different supported communication methods. For example, when the display device 200 supports wireless network communication, the display device 200 may be provided with a communication device 220 including a WiFi function. When the display device 200 supports Bluetooth connection communication, the display device 200 needs to be provided with a communication device 220 including a Bluetooth function.
[0065] The communication device 220 can enable the display device 200 to communicate with an external device or server 400 through a wireless or wired connection. Among them, the wired connection can connect the display device 200 with an external device through components such as a data cable and an interface. The wireless connection can connect the display device 200 with an external device through a wireless signal or a wireless network. The display device 200 can directly establish a connection relationship with an external device, or indirectly establish a connection relationship through a gateway, a router, a connection device, etc.
[0066] In some embodiments, the controller 250 may include at least one of a central processing unit, a video processor, an audio processor, a graphics processor, and a power processor, and the first interface to the nth interface for input / output. The controller 250 controls the operation of the display device and responds to user operations through various software control programs stored in the memory. The controller 250 controls the overall operation of the display device 200.
[0067] In some embodiments, the controller 250 and the tuner demodulator 210 may be located in different split devices, that is, the tuner demodulator 210 may also be in an external device of the main device where the controller 250 is located, such as an external set-top box, etc.
[0068] In some embodiments, the user can input a user command on the graphical user interface (Graphical User Interface, GUI) displayed on the display 260, and then the user input interface receives the user input command through the graphical user interface (GUI).
[0069] In some embodiments, the audio output device 270 may be a built-in speaker of the display device 200, or an external audio output device connected to the display device 200. Among them, for the external audio output device connected to the display device 200, the display device 200 may also be provided with an external audio output terminal, and the audio output device can be connected to the display device 200 through the external audio output terminal to output the sound of the display device 200.
[0070] In some embodiments, the user input interface 280 can be used to receive instructions from user input.
[0071] Figure 3 For some embodiments of the present application Figure 1 The hardware configuration block diagram of the control device in. As Figure 3 shown, the control device 100 may include: a controller 110, a communication interface 130, a user input / output interface, a memory, and a power supply.
[0072] The control device 100 is configured to control the display device 200, and can receive input operation instructions from the user, and convert the operation instructions into instructions recognizable and responsive by the display device 200, playing an intermediary role in the interaction between the user and the display device 200.
[0073] In some embodiments, the control device 100 can be an intelligent device. For example: the control device 100 can install various applications for controlling the display device 200 according to user needs.
[0074] In some embodiments, as Figure 1 shown, after the mobile terminal 300 or other intelligent electronic devices install the application for controlling the display device 200, they can perform functions similar to those of the control device 100.
[0075] The controller 110 includes a processor 112, a RAM 113, a ROM 114, a communication interface 130, and a communication bus. The controller 110 is used to control the operation and operation of the control device 100, as well as the communication and cooperation between internal components and the data processing functions inside and outside.
[0076] Under the control of the controller 110, the communication interface 130 realizes the communication of control signals and data signals with the display device 200. The communication interface 130 may include at least one of a WiFi chip 131, a Bluetooth module 132, an NFC module 133, and other near-field communication modules.
[0077] The user input / output interface 140, where the input interface includes at least one of a microphone 141, a touchpad 142, a sensor 143, a button 144, and other input interfaces.
[0078] In some embodiments, the control device 100 includes at least one of the communication interface 130 and the input / output interface 140. The communication interface 130 is configured in the control device 100. For example: modules such as WiFi, Bluetooth, and NFC can encode user input instructions through the WiFi protocol, or the Bluetooth protocol, or the NFC protocol, and send them to the display device 200.
[0079] The memory 190 is used to store various operating programs, data, and applications for driving and controlling the control device 100 under the control of the controller. The memory 190 can store various control signal instructions input by the user.
[0080] The power supply 180 is used to provide operating power support for each component of the control device 100 under the control of the controller.
[0081] In order to perform user interaction, in some embodiments, the display device 200 may run an operating system. The operating system is a computer program for managing and controlling hardware resources and software resources in the display device 200. The operating system may (control the display device) provide a user interface, allow the user to interact with the display device 200, and support the running of various application programs.
[0082] It should be noted that the operating system can be a native operating system based on a specific operating platform, a third-party operating system deeply customized based on a specific operating platform, or an independent operating system specially developed for the display device.
[0083] The operating system can be divided into different modules or layers according to the functions implemented, such as Figure 4 As shown, in some embodiments, the system is divided into four layers, from top to bottom, namely, the application layer (Applications layer) (referred to as "application layer"), the application framework layer (Application Framework layer) (referred to as "framework layer"), the system library layer and the kernel layer.
[0084] In some embodiments, the application layer is used to provide services and interfaces for applications so that the display device 200 can run applications and interact with users based on applications. At least one application can be run in the application layer, and these applications can be window programs, system settings programs, clock programs, etc. that come with the operating system; they can also be applications developed by third-party developers. In specific implementations, the application packages in the application layer are not limited to the above examples.
[0085] The framework layer provides application programming interfaces (APIs) and programming frameworks for applications. The application framework layer includes some predefined functions. The application framework layer is equivalent to a processing center that determines the actions of applications in the application layer. Applications can access system resources and obtain system services during execution through the API interface.
[0086] like Figure 4As shown, in the embodiment of the present application, the application framework layer includes a view system (View System), managers, content providers, etc. Among them, the view system can design and implement the interface and interaction of the application. The view system includes lists, grids, text boxes, buttons, etc. The managers include at least one of the following modules: The Activity Manager is used to interact with all the activities running in the system; the Location Manager is used to provide access to the system location service for system services or applications; the Package Manager is used to retrieve various information related to the application packages currently installed on the device; the Notification Manager is used to control the display and clearing of notification messages; the Window Manager is used to manage icons, windows, toolbars, wallpapers, and desktop widgets on the user interface.
[0087] In some embodiments, the Activity Manager is used to manage the life cycle of each application and the usual navigation back function, such as controlling the exit, opening, and backward of the application. The Window Manager is used to manage all window programs, such as obtaining the display screen size, determining whether there is a status bar, locking the screen, taking screenshots, and controlling the change of the display window. For example, shrinking the display window, jittering the display, distorting the display, etc.
[0088] In some embodiments, the system runtime layer can provide support for the framework layer. When the framework layer is used, the operating system will run the instruction library contained in the system runtime layer, such as the C / C++ instruction library, to implement the functions that the framework layer needs to achieve.
[0089] In some embodiments, the kernel layer is a functional layer between the hardware and software of the display device 200. The kernel layer can implement functions such as hardware abstraction, multitasking, and memory management. For example, as Figure 4 shown, hardware drivers can be configured in the kernel layer. The drivers included in the kernel layer can be at least one of the following drivers: audio driver, display driver, Bluetooth driver, camera driver, WIFI driver, USB driver, HDMI driver, sensor drivers (such as fingerprint sensors, temperature sensors, pressure sensors, etc.), and power drivers, etc.
[0090] It should be noted that the above examples are only simple divisions of the functions of the operating system, and do not limit the specific form of the operating system of the display device 200 in the embodiments of the present application. Depending on factors such as the functions of the display device and the type of operating system, the number of levels and the specific level types included in the operating system can be in other forms.
[0091] In some embodiments, the display device has relevant configurations for implementing a thread scheduling priority processing method. The implementation steps of this thread scheduling priority processing method are introduced below. Refer to Figure 5 As shown, the thread scheduling priority processing method includes the following steps:
[0092] Step 501: When it is detected that the target method is called during the operation of the display device, mark the key thread corresponding to the target method.
[0093] Among them, the user can send a start instruction to the display device in various ways such as voice, remote control, and display device switch. After receiving the start instruction, the display device performs start-up processing. After the display device is successfully started, the user can normally use the various functions provided by the display device, and the display device enters the running process.
[0094] Among them, after the display device is started, for any operation input by the user to the display device, the display device will call the corresponding method to implement the response to the operation.
[0095] Exemplarily, the user inputs a key trigger operation to the display device. The key trigger operation is, for example, a pressing operation on the up button, down button, left button, or right button on the remote control. The display device will call the response method for key trigger, such as methods like intercept Key Before Queueing in the IP Multimedia Subsystem (IMS for short) in the Android standard framework.
[0096] Exemplarily, the user inputs an operation to start an application. For example, the display device provides multiple applications, and the user inputs the voice to control the opening of a certain application. The display device will call the response method for starting the application, such as methods like startProcess Locked in the Activity Manager Service (AMS for short) in the Android standard framework.
[0097] Exemplarily, the user inputs an operation to control the audio to enter the playing state. For example, there are multiple audios on a certain page provided by the display device, and the user inputs a voice to control the playing of a certain audio. The display device will call the response method to enter the playing state. For example, methods such as audioPlayer Active State Changed / request Audio Focus in Audio under the Android standard framework.
[0098] Optionally, in the case of wanting to improve the response speed of a certain interaction operation, the response method corresponding to the operation can be used as the target method. Exemplarily, assuming that it is desired to improve the response speed of the key trigger operation, the operation of starting an application, and the operation of controlling the audio to enter the playing state, then the response methods for key trigger, starting an application, and entering the playing state can all be used as target methods.
[0099] Optionally, the Hook point can be used to detect whether the target method is called.
[0100] Optionally, the critical threads corresponding to each target method can be set in advance. Exemplarily, the response methods for key trigger, starting an application, and entering the playing state are all target methods. The critical threads corresponding to the response method for key trigger can be set as: the main thread of the foreground application, the rendering thread of the foreground application, the input reading thread, and the input distribution thread. The critical threads corresponding to the response method for starting an application can be set as: the main thread of the foreground application, the main thread of the target application to be started, and the rendering thread of the target application. The critical threads corresponding to the response method for entering the playing state can be set as: the playing thread and the codec thread that mark the foreground application.
[0101] Among them, in the case of detecting that the target method is called, the critical threads corresponding to the target method can be marked. Exemplarily, in the case of detecting that the response method for key trigger is called, the main thread of the foreground application, the rendering thread of the foreground application, the input reading thread, and the input distribution thread can be marked. In the case of detecting that the response method for starting an application is called, the main thread of the foreground application, the main thread of the target application to be started, and the rendering thread of the target application can be marked. In the case of detecting that the response method for entering the playing state is called, the playing thread and the codec thread of the foreground application can be marked.
[0102] Step 502, obtain the execution status of the marked critical threads.
[0103] Optionally, the kernel tracing ftrace tool is used to record various events, such as function calls, system calls, interrupt events, timer events, etc. During the startup process of the display device, the scheduling event monitoring service can be enabled. From all the events recorded by the kernel tracing ftrace tool through the scheduling event monitoring service, scheduling-related events are extracted, such as: scheduling switch events (sched_switch events), scheduling wake-up events (sched_wakeup events), and wake-up status events (sched_waking events).
[0104] Among them, regarding the sched_switch event, when thread scheduling occurs, the sched_switch event will be triggered. Specifically, when there is a thread switch (from one thread to another), this event will be triggered. The main information of the sched_switch event includes the thread ID before the switch and the ID of the next thread to run. Therefore, it is possible to check whether there is a marked critical thread among the thread IDs before the switch included in all the sched_switch events extracted by the scheduling event monitoring service. If it exists, it means that the marked critical thread; if it does not exist, it means that the marked critical thread has not been executed completely.
[0105] Step 503, in the case where the marked critical thread has been executed completely, obtain the thread wake-up chain where the marked critical thread is located, and increase the priority of the threads after the marked critical thread in the wake-up chain.
[0106] Among them, in the case where the marked critical thread has been executed completely, based on the scheduling-related events extracted by the scheduling event monitoring service, the thread wake-up chain where the marked critical thread is located can be analyzed, and the priority of the threads after the marked critical thread in the wake-up chain is increased, so that the interaction operation corresponding to the target method can be quickly responded to.
[0107] Among them, the sched_wakeup event and / or the sched_waking event can be analyzed to determine the thread wake-up chain where the marked critical thread is located.
[0108] Among them, after obtaining the thread wake-up chain where the marked critical thread is located, the priority of the threads after the marked critical thread in the wake-up chain can be increased. Exemplarily, the threads after the marked critical thread in the wake-up chain can be adjusted to RT scheduling, and after these threads are executed, their priority settings are restored.
[0109] Step 504, in the case where the marked critical thread has not been executed completely, obtain the lock queue of the data resources operated by the marked critical thread, and increase the priority of the threads before the marked critical thread in the lock queue.
[0110] Among them, the display device includes a plurality of data resources. The data resources can be, for example, files. Each data resource has a corresponding lock. When a thread wants to operate on a certain data resource, it needs to hold the lock of the data resource to operate on it. The operations on the data resource can be, for example, addition, deletion, modification, query, etc. The embodiments of the present application do not limit this.
[0111] Among them, for each data resource, there is a corresponding lock queue, and the lock queue contains threads waiting in line for the lock of the data resource.
[0112] Among them, in the case where the marked critical thread has not finished execution, if the marked critical thread needs to operate on a certain data resource, the lock queue of the data resource operated by the marked critical thread can be obtained, and the threads in the lock queue that are before the marked critical thread are promoted in priority; in this way, the execution speed of these threads can be accelerated, so that the marked critical thread can quickly obtain the lock, and the interaction operation corresponding to the target method can be quickly responded to. If the marked critical thread does not need to operate on any data resource, the subsequent steps may not be executed, and just wait for the marked critical thread to finish execution.
[0113] Optionally, the threads in the lock queue that are before the marked critical thread can be adjusted to RT scheduling, and after these threads finish execution, their priority settings are restored.
[0114] In the above embodiments, when it is detected that the target method is called during the operation of the display device, the critical thread corresponding to the target method is marked; in the case where the marked critical thread has finished execution, the thread wake-up chain where the marked critical thread is located is obtained, and the threads after the marked critical thread in the wake-up chain are promoted in priority; in the case where the marked critical thread has not finished execution, the lock queue of the data resource operated by the marked critical thread is obtained, and the threads in the lock queue that are before the marked critical thread are promoted in priority; so that the interaction operation corresponding to the target method can be quickly responded to.
[0115] In some embodiments, the target method is a response method triggered by a button. The critical threads corresponding to the target method include at least one of the main thread of the foreground application, the rendering thread of the foreground application, the input reading thread, or the input distribution thread; or; the target method is a response method for starting an application. The critical threads corresponding to the target method include at least one of the main thread of the foreground application, the main thread of the target application to be started, or the rendering thread of the target application; or; the target method is a response method for entering the playing state. The critical threads corresponding to the target method include at least one of the playing thread or the codec thread of the foreground application.
[0116] As described above, when it is desired to improve the response speed of a certain interaction operation, the response method corresponding to the operation can be used as the target method. Exemplarily, the response methods triggered by buttons, the response methods for starting applications, and the response methods for entering the playback state can all be used as target methods. The key threads corresponding to each target method can be preset. Exemplarily, the key threads corresponding to the response method triggered by a button can include one or more of the main thread of the foreground application, the rendering thread of the foreground application, the input reading thread, and the input distribution thread; the key threads corresponding to the response method for starting an application can include one or more of the main thread of the foreground application, the main thread of the target application to be started, and the rendering thread of the target application; the key threads corresponding to the response method for entering the playback state can include one or more of the playback thread of the foreground application and the codec thread.
[0117] In the above embodiments, when it is detected that the response method triggered by a button is called, at least one of the main thread of the foreground application, the rendering thread of the foreground application, the input reading thread, or the input distribution thread can be marked, and the response speed of the button trigger can be accelerated through subsequent priority elevation; when it is detected that the response method for starting an application is called, at least one of the main thread of the foreground application, the main thread of the target application to be started, or the rendering thread of the target application can be marked, and the response speed of starting the application can be accelerated through subsequent priority elevation; when it is detected that the response method for entering the playback state is called, at least one of the playback thread of the foreground application or the codec thread can be marked, and the response speed of the user's trigger to enter the playback state can be accelerated through subsequent priority elevation.
[0118] In some embodiments, the thread scheduling priority processing method provided by the embodiments of the present application further includes the following steps: inserting hook points in the response methods corresponding to at least one interaction operation; using each of the response methods with inserted hook points as target methods; and detecting whether the corresponding target methods are called through the inserted hook points.
[0119] Among them, when it is desired to improve the response speed of certain interaction operations, hook points can be inserted in the response methods corresponding to these interaction operations; each of the response methods with inserted hook points can be used as a target method. The number of response methods with inserted hook points can be one or multiple, and the embodiments of the present application do not limit this.
[0120] Optionally, at least one interaction operation may include a key triggering operation, an operation to start an application, and an operation to control audio to enter the playback state. Therefore, hook points can be inserted respectively in the response method for key triggering, the response method for starting an application, and the response method for entering the playback state, and these response methods with inserted hook points are all used as target methods.
[0121] Among them, the hook points in the target method can monitor the behavior of the target method being called. Therefore, it is possible to detect whether the corresponding target method is called through the inserted hook points.
[0122] In the above embodiments, by inserting hook points to detect whether the target method is called, and performing subsequent operations in the case of being called, the response speed of the interaction operation corresponding to the target method can be greatly improved.
[0123] In some embodiments, obtaining the execution status of the marked critical thread includes the following steps: putting the marked critical thread into the critical thread queue; in the case where there are multiple marked critical threads in the critical thread queue, for each marked critical thread, obtain the execution status of the marked critical thread.
[0124] Among them, the marked critical thread may be one or multiple. The marked critical thread can be put into the critical thread queue; in the case where there are multiple marked critical threads in the critical thread queue, it is necessary to obtain the execution status of each marked critical thread. In the case where the marked critical thread has been executed, obtain the thread wake-up chain where the marked critical thread is located, and promote the priority of the threads after the marked critical thread in the wake-up chain; in the case where the marked critical thread has not been executed, obtain the lock queue of the data resources operated by the marked critical thread, and promote the priority of the threads before the marked critical thread in the lock queue.
[0125] In the above embodiments, putting the marked critical thread into the critical thread queue and performing corresponding priority promotion processing for each marked critical thread in the critical thread queue can greatly improve the response speed of the interaction operation corresponding to the target method.
[0126] In some embodiments, the thread scheduling priority processing method provided by the embodiments of the present application further includes the following steps: enabling a scheduling event monitoring service during the startup process of the display device, extracting scheduling-related events from all events recorded by the kernel tracing tool through the scheduling event monitoring service, and the scheduling-related events include at least one of: a scheduling switch event, a scheduling wake-up event, or a wake-up state event; obtaining the thread wake-up chain where the marked critical thread is located, including: performing thread wake-up analysis on the scheduling-related events to obtain the thread wake-up chain where the marked critical thread is located.
[0127] Among them, the display device is provided with a kernel tracing ftrace tool, and the kernel tracing ftrace tool is used to record various events. During the startup process of the display device, a scheduling event monitoring service is enabled. The scheduling event monitoring service can extract scheduling-related events from all the events recorded by the kernel tracing tool, such as: scheduling switch events (sched_switch events), scheduling wake-up events (sched_wakeup events), and wake-up status events (sched_waking events).
[0128] Among them, thread wake-up analysis can be performed on the scheduling-related events to obtain the thread wake-up chain where the marked critical thread is located.
[0129] Optionally, regarding the sched_wakeup event, when a thread is awakened from the sleep state and placed in the run queue, the sched_wakeup event will be triggered. The main information of the sched_wakeup event includes: the ID of the awakened thread, the ID of the thread that performs the wake-up operation, etc. Among all the sched_wakeup events extracted by the scheduling event monitoring service, find the sched_wakeup event that contains the ID of the marked critical thread. If in the found sched_wakeup event, the ID of the marked critical thread is the ID of the awakened thread, then use the thread that performs the wake-up operation in the corresponding sched_wakeup event as the previous thread of the marked critical thread; if in the found sched_wakeup event, the ID of the marked critical thread is the ID of the thread that performs the wake-up operation, then use the awakened thread in the corresponding sched_wakeup event as the next thread of the marked critical thread. Use the same method to find the thread before the previous thread and the thread after the next thread, so as to obtain a thread wake-up chain, and this thread wake-up chain is the thread wake-up chain where the marked critical thread is located.
[0130] In the above embodiment, the scheduling event monitoring service extracts scheduling-related events from all the events recorded by the kernel tracing tool, performs thread wake-up analysis on the scheduling-related events, and obtains the thread wake-up chain where the marked critical thread is located. Subsequently, the threads after the marked critical thread in the wake-up chain can be promoted in priority, so as to accelerate the response speed of the interaction operation corresponding to the target method.
[0131] In some embodiments, the thread scheduling priority processing method provided by the embodiments of the present application further includes the following steps: inserting hook points in the locking method and unlocking method corresponding to each data resource; starting a lock queue monitoring service during the startup process of the display device, and the lock queue monitoring service detects the lock status of each data resource through the inserted hook points, and updates the lock queue of each data resource based on the lock status; obtaining the lock queue of the data resources operated by the marked critical threads, including: obtaining the lock queue of the data resources operated by the marked critical threads from the lock queue monitoring service.
[0132] Among them, the display device is provided with an Android Runtime (ART) virtual machine, and the ART virtual machine contains the locking method and unlocking method corresponding to each data resource. The locking method can be, for example, Monitor::lock; the unlocking method can be, for example, Monitor::unlock. Hook points can be inserted in the locking method and unlocking method corresponding to each data resource.
[0133] As described above, the display device includes multiple data resources, and each data resource has a corresponding lock. When a thread wants to operate a certain data resource, it needs to hold the lock of the data resource to operate it. For each data resource, there is a corresponding lock queue, and the lock queue contains the threads queuing up to wait for the lock of the data resource.
[0134] Among them, the hook point in the locking method can monitor the behavior of the locking method being called, and the hook point in the unlocking method can monitor the behavior of the unlocking method being called. When the locking method corresponding to a certain data resource is called by a certain thread, the current lock-holding thread can be detected through the hook point in the locking method. When the unlocking method corresponding to a certain data resource is called by a certain thread, the thread that releases the corresponding lock can be obtained through the hook point in the unlocking method, and the thread can be further removed from the lock queue of the data resource, so as to realize the update of the lock queue.
[0135] Among them, the lock queue monitoring service can be started during the startup process of the display device, and the lock queue monitoring service executes the steps of detecting the lock status of each data resource through the inserted hook points and updating the lock queue of each data resource based on the lock status. In the case where the marked critical thread has not been completed, the lock queue of the data resources operated by the marked critical thread can be obtained from the lock queue monitoring service. The priority of the threads queued in front of the marked critical thread in the lock queue is increased.
[0136] In the above embodiments, the lock queue of the data resources operated by the marked critical threads can be obtained from the lock queue monitoring service, and the priority of the threads in the lock queue that are before the marked critical threads can be promoted, so as to accelerate the response speed of the interaction operation corresponding to the target method.
[0137] In some embodiments, the thread scheduling priority processing method provided by the embodiments of the present application further includes the following steps: putting the marked critical threads into the critical thread queue; in the case where the target method is the response method for starting an application, after the target application requested to start is successfully started, removing the main thread of the foreground application from the critical thread queue; in the case where the target method is the response method for entering the playing state, when it is detected that the playing state is exited, removing the playing thread and the codec thread of the foreground application from the critical thread queue.
[0138] Among them, the marked critical threads may be one or more. The marked critical threads can be put into the critical thread queue.
[0139] Among them, in the case where the target method is the response method for starting an application, the critical thread queue includes the main thread of the foreground application, the main thread of the target application requested to start, and the rendering thread of the target application; after the target application requested to start is successfully started, removing the main thread of the foreground application from the critical thread queue.
[0140] Among them, in the case where the target method is the response method for entering the playing state, the critical thread queue includes the playing thread and the codec thread of the foreground application, and when it is detected that the playing state is exited, removing both the playing thread and the codec thread of the foreground application from the critical thread queue.
[0141] In the above embodiments, in the case where the target method is the response method for starting an application, after the target application requested to start is successfully started, the target application becomes the foreground application, so the main thread of the original foreground application can be removed from the critical thread queue; in the case where the target method is the response method for entering the playing state, when it is detected that the playing state is exited, since the playing scenario has ended, the playing thread and the codec thread of the foreground application can be removed from the critical thread queue, realizing the real-time update of the threads in the critical thread queue and avoiding the resource waste caused by the preferential scheduling of non-critical threads.
[0142] In some embodiments, refer to Figure 6As shown in the figure, a system framework diagram is provided, including the Android standard framework and the key thread management module. The Android standard framework includes AMS, IMS, Media, WindowManager Service (abbreviated as WMS), virtual machine, etc. Media includes Audio. The virtual machine includes the ART virtual machine. The key thread management module includes a key thread identification module, an ftrace event analysis module, a wake-up relationship analysis module, a virtual machine lock queue monitoring module, a lock wait queue analysis module, and a priority setting module.
[0143] Optionally, when it is detected that the target method is called during the operation of the display device, the key thread identification module is used to mark the key thread corresponding to the target method; when the marked key thread has been executed, the ftrace event analysis module and the wake-up relationship analysis module are used to obtain the thread wake-up chain where the marked key thread is located, and the priority setting module is used to increase the priority of the threads after the marked key thread in the wake-up chain. When the marked key thread has not been executed, the virtual machine lock queue monitoring module and the lock wait queue analysis module are used to obtain the lock queue of the data resources operated by the marked key thread, and the priority setting module is used to increase the priority of the threads before the marked key thread in the lock queue.
[0144] Optionally, the target method is a response method triggered by a key press, and the key threads corresponding to the target method include at least one of the main thread of the foreground application, the rendering thread of the foreground application, the input reading thread, or the input distribution thread; or; the target method is a response method for starting an application, and the key threads corresponding to the target method include at least one of the main thread of the foreground application, the main thread of the target application to be started, or the rendering thread of the target application; or; the target method is a response method for entering the playback state, and the key threads corresponding to the target method include at least one of the playback thread or the codec thread of the foreground application.
[0145] Optionally, the above system may further include a Hook point detection module, which is used to insert a hook Hook point into the response methods corresponding to at least one interaction operation; regard each response method with the inserted hook Hook point as the target method; detect whether the corresponding target method is called through the inserted hook Hook point.
[0146] Optionally, the key thread identification module is further used to put the marked key thread into the key thread queue; when there are multiple marked key threads in the key thread queue, for each marked key thread, obtain the execution state of the marked key thread.
[0147] Optionally, the ftrace event analysis module is used to extract scheduling-related events from all events recorded by the kernel tracing tool. The scheduling-related events include at least one of the following: scheduling switch event, scheduling wake-up event, or wake-up status event. The wake-up relationship analysis module is used to perform thread wake-up analysis on the scheduling-related events to obtain the thread wake-up chain in which the marked critical thread is located.
[0148] Optionally, the virtual machine lock queue monitoring module is used to detect the lock status of each data resource through the inserted hook point. The lock wait queue analysis module is used to update the lock queue of each data resource based on the lock status and obtain the lock queue of the data resource operated by the marked critical thread.
[0149] Optionally, the critical thread identification module is further used to put the marked critical thread into the critical thread queue. When the target method is the response method for starting an application, after the target application requested to start is successfully started, the main thread of the foreground application is removed from the critical thread queue. When the target method is the response method for entering the playback state, when it is detected that the playback state is exited, the playback thread and the codec thread of the foreground application are removed from the critical thread queue.
[0150] Specifically, when methods such as intercept Key Before Queueing in IMS are called, it can be determined that a key trigger operation has occurred. When methods such as start Process Locked in AMS are called, it can be determined that an operation to start an application has occurred. When methods such as audio Player Active State Changed / request AudioFocus in Audio are called, it can be determined that an operation to control the audio to enter the playback state has occurred. After determining the interaction operation, the critical thread identification module can mark the corresponding critical thread. When the marked critical thread has been executed, the ftrace event analysis module extracts scheduling-related events from all events recorded by the kernel tracing tool, and the wake-up relationship analysis module performs thread wake-up analysis on the scheduling-related events to obtain the thread wake-up chain in which the marked critical thread is located. The priority setting module raises the priority of the threads after the marked critical thread in the wake-up chain. When the marked critical thread has not been executed, the virtual machine lock queue monitoring module detects the lock status of each data resource through the inserted hook point, the lock wait queue analysis module updates the lock queue of each data resource based on the lock status and obtains the lock queue of the data resource operated by the marked critical thread, and the priority setting module raises the priority of the threads before the marked critical thread in the lock queue.
[0151] In some embodiments, a method for processing thread scheduling priorities is provided, such asFigure 7 As shown, there are hook points inserted in the three methods of intercept KeyBefore Queueing, start Process Locked, and audio Player Active State Changed. When the user inputs a key trigger operation to the display device, the display device calls intercept Key Before Queueing. After detecting that this method is called through the hook point in this method, the main thread of the foreground application, the rendering thread of the foreground application, the input reading thread, and the input distribution thread are marked as critical threads. When the user inputs an operation to start an application to the display device, the display device calls start Process Locked. After detecting that this method is called through the hook point in this method, the main thread of the foreground application, the main thread of the target application to be started, and the rendering thread of the target application are marked as critical threads. When the user inputs an operation to control the audio to enter the playing state to the display device, the display device calls audio Player Active State Changed. After detecting that this method is called through the hook point in this method, the playback thread and the codec thread of the foreground application are marked as critical threads. It should be noted that the above several interaction operations are only examples, and there can be other interaction operations. After detecting that the corresponding method is called, critical threads are marked, which will not be shown one by one in this application. The marked critical threads can be put into the critical thread queue, and each thread in the critical thread queue enters the waiting for wake-up state. For each waiting for wake-up thread (marked critical thread), it is judged whether the waiting for wake-up thread has completed execution. If it has completed execution, the thread wake-up chain where the marked critical thread is located is obtained, and the threads after the marked critical thread in the wake-up chain are promoted in priority. Among them, the scheduling event monitoring service can extract scheduling-related events from all events recorded by the kernel tracing tool. Thread wake-up analysis can be performed on the scheduling-related events to obtain the thread wake-up chain where the marked critical thread is located. If it has not completed execution, it is judged whether the marked critical thread is waiting for a locked thread to wake up. If so, the lock queue of the data resource operated by the marked critical thread is obtained, and the threads in front of the marked critical thread in the lock queue are promoted in priority. Among them, there are hook points inserted in the Lock and unlock methods in the ART virtual machine. The lock queue monitoring service can detect the lock state of each data resource through the hook points and update the lock queue of each data resource based on the lock state. The lock queue of the data resource operated by the marked critical thread can be obtained from the lock queue monitoring service.
[0152] In some embodiments, a display device is provided, which includes: at least one processor configured to execute instructions to cause the display device to: when it is detected that a target method is called during the operation of the display device, mark the critical thread corresponding to the target method based on the pre-set correspondence between the method and the critical thread; obtain the execution status of the marked critical thread; when the marked critical thread has been executed, obtain the thread wake-up chain where the marked critical thread is located, and promote the priority of the threads after the marked critical thread in the wake-up chain; when the marked critical thread has not been executed, obtain the lock queue of the data resources operated by the marked critical thread, and promote the priority of the threads in front of the marked critical thread in the lock queue. For the detailed implementation process, please refer to the above text.
[0153] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some or all of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
[0154] For the sake of explanation, the above description has been made in conjunction with specific embodiments. However, the above exemplary discussions are not intended to be exhaustive or to limit the embodiments to the specific forms disclosed above. According to the above teachings, various modifications and variations can be obtained. The selection and description of the above embodiments are for better explaining the principles and practical applications, so that those skilled in the art can better use the embodiments and various different modified embodiments suitable for specific use considerations.
Claims
1. A method for processing thread scheduling priorities, characterized in that, Including: When it is detected that the target method is called during the operation of the display device, mark the key thread corresponding to the target method; Obtain the execution status of the marked key thread; When the marked key thread has been executed, obtain the thread wake-up chain where the marked key thread is located, and promote the priority of the threads after the marked key thread in the wake-up chain; When the marked key thread has not been executed, obtain the lock queue of the data resources operated by the marked key thread, and promote the priority of the threads before the marked key thread in the lock queue.
2. The method according to claim 1, wherein: The target method is a response method triggered by a key press, and the key threads corresponding to the target method include at least one of the main thread of the foreground application, the rendering thread of the foreground application, the input reading thread, or the input distribution thread; Or; The target method is a response method for starting an application, and the key threads corresponding to the target method include at least one of the main thread of the foreground application, the main thread of the target application to be started, or the rendering thread of the target application; Or; The target method is a response method for entering the playback state, and the key threads corresponding to the target method include at least one of the playback thread or the codec thread of the foreground application.
3. The method according to claim 1, characterized in that, The method further includes: Insert a hook point in the response methods corresponding to at least one interaction operation; regard each response method with the inserted hook point as the target method; Detect whether the corresponding target method is called through the inserted hook point.
4. The method according to claim 1, wherein The obtaining the execution status of the marked key thread includes: Put the marked key thread into the key thread queue; When there are multiple marked key threads in the key thread queue, for each marked key thread, obtain the execution status of the marked key thread.
5. The method according to claim 1, wherein The method further includes: During the startup process of the display device, start the scheduling event monitoring service, and extract scheduling-related events from all events recorded by the kernel tracing tool through the scheduling event monitoring service. The scheduling-related events include at least one of a scheduling switch event, a scheduling wake-up event, or a wake-up status event; The obtaining the thread wake-up chain where the marked key thread is located includes: Perform thread wake-up analysis on the scheduling-related events to obtain the thread wake-up chain where the marked key thread is located.
6. The method according to claim 1, wherein The method further includes: Insert a hook point in the locking method and unlocking method corresponding to each data resource; During the startup process of the display device, start the lock queue monitoring service, and the lock queue monitoring service detects the lock status of each data resource through the inserted hook point, and updates the lock queue of each data resource based on the lock status; The obtaining the lock queue of the data resources operated by the marked key thread includes: Obtain the lock queue of the data resources operated by the marked key thread from the lock queue monitoring service.
7. The method according to claim 2, wherein The method further includes: Put the marked key thread into the key thread queue; When the target method is the response method for starting an application, after the target application requested to start is successfully started, the main thread of the foreground application is removed from the critical thread queue; When the target method is the response method for entering the playback state, when it is detected that the playback state is exited, the playback thread and the codec thread of the foreground application are removed from the critical thread queue.
8. A display device, characterized in that, Comprising: At least one processor, configured to execute instructions to cause the display device to: When it is detected that a target method is called during the operation of the display device, based on the pre-set correspondence between the method and the critical thread, mark the critical thread corresponding to the target method; Obtain the execution state of the marked critical thread; When the marked critical thread has been executed, obtain the thread wake-up chain where the marked critical thread is located, and promote the priority of the threads after the marked critical thread in the wake-up chain; When the marked critical thread has not been executed, obtain the lock queue of the data resources operated by the marked critical thread, and promote the priority of the threads before the marked critical thread in the lock queue.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.
Citation Information
Cited By
Thread scheduling method and device, electronic equipment, storage medium and program product
CN122285301A