WO2021052415A1 - Procédé de planification de ressources et dispositif électronique - Google Patents

Procédé de planification de ressources et dispositif électronique Download PDF

Info

Publication number
WO2021052415A1
WO2021052415A1 PCT/CN2020/115886 CN2020115886W WO2021052415A1 WO 2021052415 A1 WO2021052415 A1 WO 2021052415A1 CN 2020115886 W CN2020115886 W CN 2020115886W WO 2021052415 A1 WO2021052415 A1 WO 2021052415A1
Authority
WO
WIPO (PCT)
Prior art keywords
binder
thread
application
electronic device
threads
Prior art date
Application number
PCT/CN2020/115886
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 WO2021052415A1 publication Critical patent/WO2021052415A1/fr

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • 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/48Program initiating; Program switching, e.g. by interrupt
    • 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
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/48Indexing scheme relating to G06F9/48
    • G06F2209/484Precedence
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/48Indexing scheme relating to G06F9/48
    • G06F2209/486Scheduler internals

Definitions

  • This application relates to the field of terminal technology, and in particular to a resource scheduling method and electronic equipment.
  • the application program in the Android system can run in the form of one or more processes.
  • Application programs may include third-party applications and system applications.
  • the running form of the system application in the Android system is the system service process.
  • system service process there are threads (threads) of various system services, and kernel space resources can be used to provide various system services, for example, window management service (window manager server, WMS), activity management system service (activity manager system) service, AMS), power management service (power manager service, PMS), etc.
  • window management service window manager server, WMS
  • activity management system service activity manager system
  • AMS power management service
  • PMS power management service
  • the running forms of third-party applications and system applications in the Android system are both application processes.
  • an application process needs to call a system service, it needs to initiate a request to the system service process, and let the system service process call the corresponding system service thread to implement the operation.
  • resource conflicts may occur. For example, when both application process 1 and application process 2 need to use the window management service, they need to compete to call the WMS thread in the system service process, thereby occupying the memory resources for providing window management services in the kernel space and obtaining WMS.
  • This application provides a resource scheduling method and electronic equipment, which can increase the probability of higher priority application threads competing for system services, thereby ensuring that higher priority application threads can run smoothly, ensuring the performance of electronic equipment, and improving users’ Use experience.
  • an embodiment of the present application provides a resource scheduling method, which is applied to an electronic device.
  • the method may include: the electronic device runs an application process and a system service process, the application process includes one or more application threads, the one or more application threads include a first thread; the system service process includes: one or more System service thread, multiple binder threads; the electronic device divides the multiple binder threads into multiple binder thread groups, each binder thread group includes different binder threads, at least two binder thread groups have different numbers of binder threads ; Among them, one or more of the application thread corresponds to a binder thread group; at least one high-priority application thread corresponding to the binder thread group contained in the binder thread group, greater than that corresponding to the low-priority application thread The number of binder threads included in the binder thread group; when the first thread calls the first system service, the electronic device generates a binder request of the first thread, and the binder request of the first thread is used to request the electronic device to provide the
  • the system service thread is used to call memory resources and hardware resources to provide system services.
  • the binder thread is used for communication between the application thread and the system service thread.
  • the system service process may include N binder threads, N binder threads, N is a positive integer, and 1 ⁇ N ⁇ 32.
  • Implement the method of the first aspect predefine the priority of each application thread, when the application thread calls the system service provided by the system service thread through the system service process, the electronic device will increase the higher priority application thread to compete to the system service Probability, thereby ensuring that application threads with higher priority can run smoothly first, ensuring the performance of electronic devices, and improving user experience.
  • the frequency that the binder thread in the first binder thread group calls the system service thread is lower than the frequency that the binder thread in the second binder thread group calls the system service thread;
  • the priority of the application thread corresponding to the first binder thread group is lower than the priority of the application thread corresponding to the second binder thread group.
  • the electronic device can further reduce the probability of application threads with lower priority competing for system services, and increase the probability of application threads with higher priority competing for system services. In this way, it can be ensured that the application threads with higher priority can run smoothly first, meet the needs of users for key scenarios, and improve the user experience.
  • the electronic device can execute the method of the first aspect in the following two scenarios:
  • the electronic device After the electronic device is turned on, it automatically executes the resource scheduling method provided in the embodiment of the present application. That is, after the electronic device is turned on, when an application thread calls a system service, the probability that an application thread with a higher priority competes for a system service is increased, thereby ensuring that an application thread with a higher priority can run smoothly first. In this way, the electronic device can ensure that applications with higher priority can run smoothly in all scenarios, thereby ensuring performance and improving user experience.
  • the electronic device executes the resource scheduling method provided in the embodiment of this application.
  • the key scenarios may include: when an electronic device is running an application process, some or all of the application threads in the application process frequently call system services, and this part of the application threads may be application threads with a higher priority.
  • Executing the resource scheduling method provided by the embodiments of the present application in a critical scenario can ensure that application threads with higher priority can preferentially compete for system services and run smoothly, and ensure the real-time performance of electronic devices when processing application threads with higher priority.
  • executing the resource scheduling method provided in the embodiment of the present application only in key scenarios can also save the power consumption of the electronic device.
  • the first binder thread group corresponds to a first waiting queue
  • the first waiting queue is used to store: binder requests of application threads corresponding to the first binder thread group;
  • the binder request in the waiting queue is processed by the binder thread in the first binder thread group.
  • the electronic device may also adjust the number of binder threads in the first waiting queue according to the following strategy: when the number of binder requests in the first waiting queue is greater than the first value, the electronic device increases the binder threads in the first binder thread group When the number of binder requests in the first waiting queue is less than the second value, the electronic device reduces the number of binder threads in the first binder thread group.
  • the electronic device can dynamically adjust the number of binder threads included in each binder thread group according to the actual operating conditions, balance the binder requests initiated by each application thread, and prevent the application thread that initiates the binder request from starving to death.
  • the resource originally allocated to the higher priority application thread can be used to process the binder request, and the memory resources and hardware resources can be dynamically and reasonably scheduled according to the needs of the electronic device .
  • the priority of the application thread is determined according to the user's perception of the service provided by the application thread. The higher the user's perception of the service provided by the application thread, the priority of the application thread The higher the level.
  • an embodiment of the present application provides an electronic device.
  • the electronic device includes one or more processors and a memory; the memory is coupled with the one or more processors, and the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call
  • the computer instructions enable the electronic device to execute the resource scheduling method in the first aspect or any one of the implementation manners of the first aspect.
  • an embodiment of the present application provides an electronic device that includes one or more functional units for correspondingly performing the first aspect or any one of the possible implementation manners of the first aspect. method.
  • the embodiments of the present application provide a computer program product containing instructions.
  • the computer program product When the computer program product is run on an electronic device, the electronic device is caused to perform any possible implementation as in the first aspect and the first aspect. The method described by the method.
  • an embodiment of the present application provides a computer-readable storage medium, including instructions, which when the above instructions run on an electronic device, cause the electronic device to execute the first aspect and any possible implementation manner in the first aspect Described method.
  • FIG. 2 is a schematic diagram of the flow of inter-process communication provided by an embodiment of the present application.
  • FIG. 3A is a schematic flowchart of a resource scheduling method provided by an embodiment of the present application.
  • FIG. 3B is a schematic diagram of a binder thread reading and processing a binder request in a waiting queue according to an embodiment of the present application
  • 4B is a schematic flowchart of a binder request generated by internal processing of an electronic device according to an embodiment of the present application
  • FIG. 4C is a schematic diagram of a flow control process for a binder thread group corresponding to an application thread with a lower priority provided by an embodiment of the present application;
  • FIG. 5 is an interactive flow between various software modules when the electronic device executes the resource scheduling method shown in FIG. 3A;
  • Fig. 6 shows, in a specific example, a schematic diagram of an electronic device executing the resource scheduling method provided in an embodiment of the present application.
  • first and second are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Therefore, the features defined with “first” and “second” may explicitly or implicitly include one or more of these features. In the description of the embodiments of the present application, unless otherwise specified, "plurality" means two or more.
  • the application program installed on the electronic device runs on the operating system in the form of one or more processes to realize the corresponding function.
  • a process is a running activity of an application on a certain data set, and it is the basic unit of the operating system for resource allocation and scheduling.
  • the process can be regarded as the running activity of the CPU in a period of time.
  • Processes can be divided into application processes and system service processes.
  • the system service process includes the running form of the system application on the operating system.
  • the application process includes the running form of the third-party application on the operating system and the running form of the system application on the operating system. In other words, the application process can include the system service process.
  • the process exists in the memory of the electronic device.
  • an electronic device When an electronic device is running a process, it will take up a certain amount of memory to load program code or read and write data.
  • the threads included in the application process may be referred to as application threads, and the threads included in the system service process may be referred to as system service threads.
  • the system service process includes one or more system service threads, which are used to provide corresponding system services for electronic devices.
  • embodiments of the present application provide a resource scheduling method and an electronic device, which can increase the probability of higher priority application threads competing for system services, thereby ensuring higher priority application threads It can give priority to smooth operation, ensure the performance of electronic equipment, and enhance the user experience.
  • the electronic device provided by the embodiment of the present application is first introduced.
  • the electronic devices can be portable electronic devices such as mobile phones, tablet computers, personal digital assistants (PDAs), laptop computers and the like.
  • portable electronic device include a portable electronic device equipped with an Android operating system.
  • the electronic device may not be a portable electronic device, but a desktop computer with a touch-sensitive surface (such as a touch panel), or a smart TV.
  • FIG. 1A shows a schematic structural diagram of an electronic device 100 provided by an embodiment of the present application.
  • the electronic device 100 is configured to execute the resource scheduling method provided in the embodiment of the present application.
  • the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, and an antenna 2.
  • Mobile communication module 150 wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, earphone jack 170D, sensor module 180, buttons 190, motor 191, indicator 192, camera 193, display screen 194, and Subscriber identification module (subscriber identification module, SIM) card interface 195, etc.
  • SIM Subscriber identification module
  • the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, and ambient light Sensor 180L, bone conduction sensor 180M, etc.
  • the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100.
  • the electronic device 100 may include more or fewer components than shown, or combine certain components, or split certain components, or arrange different components.
  • the illustrated components can 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 (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 processing unit (NPU), etc.
  • AP application processor
  • modem processor modem processor
  • 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
  • NPU neural-network processing unit
  • the different processing units may be independent devices or integrated in one or more processors.
  • the controller can generate operation control signals according to the instruction operation code and timing signals to complete the control of fetching and executing instructions.
  • a memory may also be provided in the processor 110 to store instructions and data.
  • the memory in the processor 110 is a cache memory.
  • the memory can store instructions or data that the processor 110 has just used or used cyclically. If the processor 110 needs to use the instruction or data again, it can be directly called from the memory. Repeated accesses are avoided, the waiting time of the processor 110 is reduced, and the efficiency of the system is improved.
  • the processor 110 may include one or more interfaces.
  • the interface can include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, and a universal asynchronous transmitter (universal asynchronous) interface.
  • I2C integrated circuit
  • I2S integrated circuit built-in audio
  • PCM pulse code modulation
  • UART universal asynchronous transmitter
  • MIPI mobile industry processor interface
  • GPIO general-purpose input/output
  • SIM subscriber identity module
  • USB Universal Serial Bus
  • the I2C interface is a bidirectional synchronous serial bus, which includes a serial data line (SDA) and a serial clock line (SCL).
  • the processor 110 may include multiple sets of I2C buses.
  • the processor 110 may couple the touch sensor 180K, the charger, the flash, the camera 193, etc., respectively through different I2C bus interfaces.
  • the processor 110 may couple the touch sensor 180K through an I2C interface, so that the processor 110 and the touch sensor 180K communicate through an I2C bus interface to implement the touch function of the electronic device 100.
  • the I2S interface can be used for audio communication.
  • the processor 110 may include multiple sets of I2S buses.
  • the processor 110 may be coupled with the audio module 170 through an I2S bus to implement communication between the processor 110 and the audio module 170.
  • the audio module 170 may transmit audio signals to the wireless communication module 160 through an I2S interface, so as to realize the function of answering calls through a Bluetooth headset.
  • the PCM interface can also be used for audio communication to sample, quantize and encode analog signals.
  • the audio module 170 and the wireless communication module 160 may be coupled through a PCM bus interface.
  • the audio module 170 may also transmit audio signals to the wireless communication module 160 through the PCM interface, so as to realize the function of answering calls through the Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.
  • the UART interface is a universal serial data bus used for asynchronous communication.
  • the bus can be a two-way communication bus. It converts the data to be transmitted between serial communication and parallel communication.
  • the UART interface is generally used to connect the processor 110 and the wireless communication module 160.
  • the processor 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to realize the Bluetooth function.
  • the audio module 170 may transmit audio signals to the wireless communication module 160 through a UART interface, so as to realize the function of playing music through a Bluetooth headset.
  • the GPIO interface can be configured through software.
  • the GPIO interface can be configured as a control signal or as a data signal.
  • the GPIO interface can be used to connect the processor 110 with the camera 193, the display screen 194, the wireless communication module 160, the audio module 170, the sensor module 180, and so on.
  • the GPIO interface can also be configured as an I2C interface, I2S interface, UART interface, MIPI interface, etc.
  • the USB interface 130 is an interface that complies with the USB standard specification, and specifically may be a Mini USB interface, a Micro USB interface, a USB Type C interface, and so on.
  • the USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transfer data between the electronic device 100 and peripheral devices. It can also be used to connect earphones and play audio through earphones. This interface can also be used to connect to other electronic devices, such as AR devices.
  • the power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110.
  • the power management module 141 receives input from the battery 142 and/or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the display screen 194, the camera 193, and the wireless communication module 160.
  • the power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle times, and battery health status (leakage, impedance).
  • the power management module 141 may also be provided in the processor 110.
  • the power management module 141 and the charging management module 140 may also be provided in the same device.
  • the wireless communication function of the electronic device 100 can be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor, and the baseband processor.
  • the antenna 1 and the antenna 2 are used to transmit and receive electromagnetic wave signals.
  • Each antenna in the electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization.
  • Antenna 1 can be multiplexed as a diversity antenna of a wireless local area network.
  • the antenna can be used in combination with a tuning switch.
  • the mobile communication module 150 can provide a wireless communication solution including 2G/3G/4G/5G and the like applied to the electronic device 100.
  • the mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc.
  • the mobile communication module 150 can receive electromagnetic waves by the antenna 1, and perform processing such as filtering, amplifying and transmitting the received electromagnetic waves to the modem processor for demodulation.
  • the mobile communication module 150 can also amplify the signal modulated by the modem processor, and convert it into electromagnetic wave radiation via the antenna 1.
  • at least part of the functional modules of the mobile communication module 150 may be provided in the processor 110.
  • at least part of the functional modules of the mobile communication module 150 and at least part of the modules of the processor 110 may be provided in the same device.
  • the modem processor may include a modulator and a demodulator.
  • the modulator is used to modulate the low frequency baseband signal to be sent into a medium and high frequency signal.
  • the demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal.
  • the demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing.
  • the application processor outputs a sound signal through an audio device (not limited to the speaker 170A, the receiver 170B, etc.), or displays an image or video through the display screen 194.
  • the modem processor may be an independent device.
  • the modem processor may be independent of the processor 110 and be provided in the same device as the mobile communication module 150 or other functional modules.
  • the wireless communication module 160 can provide applications on the electronic device 100 including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), and global navigation satellites.
  • WLAN wireless local area networks
  • BT wireless fidelity
  • GNSS global navigation satellite system
  • FM frequency modulation
  • NFC near field communication technology
  • infrared technology infrared, IR
  • the wireless communication module 160 may be one or more devices integrating at least one communication processing module.
  • the wireless communication module 160 receives electromagnetic waves via the antenna 2, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110.
  • the wireless communication module 160 may also receive the signal to be sent from the processor 110, perform frequency modulation, amplify it, and convert it into electromagnetic waves to radiate through the antenna 2.
  • the antenna 1 of the electronic device 100 is coupled with the mobile communication module 150, and the antenna 2 is coupled with the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology.
  • 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 (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC , FM, and/or IR technology, etc.
  • the display screen 194 is used to display images, videos, and the like.
  • the display screen 194 includes a display panel.
  • the display panel can use liquid crystal display (LCD), organic light-emitting diode (OLED), active matrix organic light-emitting diode or active-matrix organic light-emitting diode (active-matrix organic light-emitting diode).
  • LCD liquid crystal display
  • OLED organic light-emitting diode
  • active-matrix organic light-emitting diode active-matrix organic light-emitting diode
  • AMOLED flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, quantum dot light-emitting diode (QLED), etc.
  • the electronic device 100 may include one or N display screens 194, and N is a positive integer greater than one.
  • the electronic device 100 can realize a shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, and an application processor.
  • the ISP is used to process the data fed back by the camera 193. For example, when taking a picture, the shutter is opened, the light is transmitted to the photosensitive element of the camera through the lens, the light signal is converted into an electrical signal, and the photosensitive element of the camera transmits the electrical signal to the ISP for processing and is converted into an image visible to the naked eye.
  • ISP can also optimize the image noise, brightness, and skin color. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene.
  • the ISP may be provided in the camera 193.
  • the camera 193 is used to capture still images or videos.
  • the object generates an optical image through the lens and is projected to the photosensitive element.
  • the photosensitive element may be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor.
  • CMOS complementary metal-oxide-semiconductor
  • the photosensitive element converts the optical signal into an electrical signal, and then transfers the electrical signal to the ISP to convert it into a digital image signal.
  • ISP outputs digital image signals to DSP for processing.
  • DSP converts digital image signals into standard RGB, YUV and other formats of image signals.
  • the electronic device 100 may include one or N cameras 193, and N is a positive integer greater than one.
  • Digital signal processors are used to process digital signals. In addition to digital image signals, they can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the energy of the frequency point.
  • Video codecs are used to compress or decompress digital video.
  • the electronic device 100 may support one or more video codecs. In this way, the electronic device 100 can play or record videos in multiple encoding formats, such as: moving picture experts group (MPEG) 1, MPEG2, MPEG3, MPEG4, and so on.
  • MPEG moving picture experts group
  • MPEG2 MPEG2, MPEG3, MPEG4, and so on.
  • NPU is a neural-network (NN) computing processor.
  • NN neural-network
  • applications such as intelligent cognition of the electronic device 100 can be realized, such as image recognition, face recognition, voice recognition, text understanding, and so on.
  • the external memory interface 120 may be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100.
  • the external memory card communicates with the processor 110 through the external memory interface 120 to realize the data storage function. For example, save music, video and other files in an external memory card.
  • the internal memory 121 may be used to store computer executable program code, where the executable program code includes instructions.
  • the internal memory 121 may include a storage program area and a storage data area.
  • the storage program area can store an operating system, at least one application program (such as a sound playback function, an image playback function, etc.) required by at least one function.
  • the data storage area can store data (such as audio data, phone book, etc.) created during the use of the electronic device 100.
  • the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, a universal flash storage (UFS), and the like.
  • the processor 110 executes various functional applications and data processing of the electronic device 100 by running instructions stored in the internal memory 121 and/or instructions stored in a memory provided in the processor.
  • the audio module 170 is used to convert digital audio information into an analog audio signal for output, and is also used to convert an analog audio input into a digital audio signal.
  • the audio module 170 can also be used to encode and decode audio signals.
  • the audio module 170 may be provided in the processor 110, or part of the functional modules of the audio module 170 may be provided in the processor 110.
  • the receiver 170B also called “earpiece” is used to convert audio electrical signals into sound signals.
  • the electronic device 100 answers a call or voice message, it can receive the voice by bringing the receiver 170B close to the human ear.
  • the microphone 170C also called “microphone”, “microphone”, is used to convert sound signals into electrical signals.
  • the user can make a sound by approaching the microphone 170C through the human mouth, and input the sound signal into the microphone 170C.
  • the electronic device 100 may be provided with at least one microphone 170C. In other embodiments, the electronic device 100 may be provided with two microphones 170C, which can implement noise reduction functions in addition to collecting sound signals. In other embodiments, the electronic device 100 may also be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify sound sources, and realize directional recording functions.
  • the earphone interface 170D is used to connect wired earphones.
  • the earphone interface 170D may be a USB interface 130, or a 3.5mm open mobile terminal platform (OMTP) standard interface, or a cellular telecommunications industry association of the USA (CTIA) standard interface.
  • OMTP open mobile terminal platform
  • CTIA cellular telecommunications industry association of the USA
  • the pressure sensor 180A is used to sense the pressure signal and can convert the pressure signal into an electrical signal.
  • the pressure sensor 180A may be provided on the display screen 194.
  • the electronic device 100 detects the intensity of the touch operation according to the pressure sensor 180A.
  • the electronic device 100 may also calculate the touched position according to the detection signal of the pressure sensor 180A.
  • touch operations that act on the same touch position but have different touch operation strengths may correspond to different operation instructions.
  • the gyro sensor 180B may be used to determine the movement posture of the electronic device 100.
  • the angular velocity of the electronic device 100 around three axes ie, x, y, and z axes
  • the gyro sensor 180B can be determined by the gyro sensor 180B.
  • the air pressure sensor 180C is used to measure air pressure.
  • the electronic device 100 calculates the altitude based on the air pressure value measured by the air pressure sensor 180C to assist positioning and navigation.
  • the magnetic sensor 180D includes a Hall sensor.
  • the electronic device 100 may use the magnetic sensor 180D to detect the opening and closing of the flip holster.
  • the acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in various directions (generally three axes). When the electronic device 100 is stationary, the magnitude and direction of gravity can be detected.
  • the electronic device 100 can measure the distance by infrared or laser.
  • the proximity light sensor 180G may include, for example, a light emitting diode (LED) and a light detector such as a photodiode.
  • LED light emitting diode
  • photodiode a light detector
  • the ambient light sensor 180L is used to sense the brightness of the ambient light.
  • the electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the perceived brightness of the ambient light.
  • the ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures.
  • the fingerprint sensor 180H is used to collect fingerprints.
  • the electronic device 100 can use the collected fingerprint characteristics to realize fingerprint unlocking, access application locks, fingerprint photographs, fingerprint answering calls, and so on.
  • the temperature sensor 180J is used to detect temperature.
  • the button 190 includes a power-on button, a volume button, and so on.
  • the button 190 may be a mechanical button. It can also be a touch button.
  • the electronic device 100 may receive key input, and generate key signal input related to user settings and function control of the electronic device 100.
  • the indicator 192 may be an indicator light, which may be used to indicate the charging status, power change, or to indicate messages, missed calls, notifications, and so on.
  • the SIM card interface 195 is used to connect to the SIM card.
  • the SIM card can be inserted into the SIM card interface 195 or pulled out from the SIM card interface 195 to achieve contact and separation with the electronic device 100.
  • the electronic device 100 may support 1 or N SIM card interfaces, and N is a positive integer greater than 1.
  • the SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, etc.
  • the same SIM card interface 195 can insert multiple cards at the same time. The types of the multiple cards can be the same or different.
  • the SIM card interface 195 can also be compatible with different types of SIM cards.
  • the SIM card interface 195 may also be compatible with external memory cards.
  • the electronic device 100 interacts with the network through the SIM card to implement functions such as call and data communication.
  • the electronic device 100 adopts an eSIM, that is, an embedded SIM card.
  • the eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.
  • the software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture.
  • the embodiment of the present application takes an Android system with a layered architecture as an example to illustrate the software structure of the electronic device 100 by way of example.
  • the application framework layer provides an application programming interface (application programming interface, API) and a programming framework for applications in the application layer.
  • the application framework layer includes some predefined functions.
  • the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and so on.
  • the window manager is used to manage window programs.
  • the window manager can obtain the size of the display, determine whether there is a status bar, lock the screen, take a screenshot, etc.
  • the view system includes visual controls, such as controls that display text, controls that display pictures, and so on.
  • the view system can be used to build applications.
  • the display interface can be composed of one or more views.
  • a display interface that includes a short message notification icon may include a view that displays text and a view that displays pictures.
  • the phone manager is used to provide the communication function of the electronic device 100. For example, the management of the call status (including connecting, hanging up, etc.).
  • Android Runtime includes core libraries and virtual machines. Android runtime is responsible for the scheduling and management of the Android system.
  • the core library consists of two parts: one part is the function functions that the java language needs to call, and the other part is the core library of Android.
  • the application layer and the application framework layer run in a virtual machine.
  • the virtual machine executes the java files of the application layer and the application framework layer as binary files.
  • the virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
  • the media library supports playback and recording of a variety of commonly used audio and video formats, as well as still image files.
  • the media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
  • the 3D graphics processing library is used to realize 3D graphics drawing, image rendering, synthesis, and layer processing.
  • the 2D graphics engine is a drawing engine for 2D drawing.
  • the priority of the threads in each application process can be defined according to the priority of the service provided by the application thread.
  • the application process here may include a third-party application process and a system service process.
  • the priority of the application thread is higher.
  • the UI thread main thread
  • the render thread the thread created when the electronic device runs the foreground application, etc., which provide user-perceivable UI display services have a higher priority.
  • the priority of the application thread is lower.
  • a kernel daemon thread such as a garbage collection thread
  • a garbage collection thread that provides convenient services for the smooth running of other threads has a lower priority.
  • each application thread in each application level process can be defined through different fine granularity.
  • the embodiments of the present application do not specifically limit the fine granularity.
  • each application thread can be divided into high and low levels according to priority.
  • each application thread can be divided into three levels: high, medium, and low.
  • each application thread can be divided into five levels: highest, higher, general, lower, and lowest.
  • a quality of service (quality of service, QoS) label may be used to measure the priority of the application thread. The higher the QoS tag value, the higher the priority of the application thread.
  • Table 1 exemplarily shows possible priorities of various application threads through QoS tag values.
  • a foreground application may refer to an application that runs in the foreground of an electronic device and occupies the focus of a display screen
  • a background application may refer to an application that runs in the background of the electronic device.
  • Lock is a mechanism to ensure that only one thread accesses memory resources and/or hardware resources in a certain kernel space at the same time.
  • a thread can access the memory resource and/or hardware resource corresponding to the lock only after acquiring the lock to which the memory resource and/or hardware resource belongs, otherwise the thread will be in a waiting or blocking state.
  • a thread acquires a lock, which can be said to be that the thread holds the lock, that is, holds the lock or holds the lock.
  • the memory resources and hardware resources in the kernel space of the Android system can be used to provide different system services.
  • System services can be divided into core system services and hardware system services.
  • Core system services are the basis for the normal operation of the Android system, including commonly used AMS, WMS, PMS, etc.
  • Hardware system services are services that provide hardware control for applications running on electronic devices, such as telephone services, wifi services, PMS, Bluetooth services ( bluetooth service) and so on.
  • the memory resources in the kernel space of electronic devices may include: memory resources for providing AMS, memory resources for providing PMS, memory resources for providing WMS, memory resources for providing battery management services, and Memory resources used to provide network state management services (network management service, NMS), memory resources used to provide bluetooth service (bluetooth service), memory resources used to provide input method management service (input manager service, IMS), and so on.
  • NMS network management service
  • NMS network management service
  • bluetooth service blue-bluetooth service
  • IMS input method management service
  • the memory resource can be a collection of functions, methods, variables, and other data.
  • the hardware resources of electronic devices may include: hardware resources for providing telephone services (such as microphones, earpieces, speakers), hardware resources for providing WiFi services (such as wireless communication modules), hardware resources for providing Bluetooth services, etc. Etc. (e.g. wireless communication module).
  • Each system service thread in the system service process is used to utilize corresponding memory resources in the kernel space and/or hardware resources to provide various system services for the electronic device.
  • AMS thread is used to provide AMS
  • WMS thread is used to provide WMS and so on.
  • an application thread needs to use a system service, it is necessary to call the memory resource and/or hardware resource in the kernel space through the corresponding system service thread to obtain the system service. At this time, it can be regarded that the application thread holds the lock of the memory resource and/or hardware resource, that is, the application thread has the authority to acquire or use the system service.
  • the multiple application threads need to compete for the lock, and only the application thread holding the lock can obtain the system service.
  • the application thread competing for locks can also be seen as the application thread competing for system services.
  • Binder is a method for communication between processes provided in the Android system.
  • Figure 2 shows the principle of the IPC mechanism. From the perspective of components, IPC includes a client, a server, a service manager, and a binder driver.
  • client is a process that uses system services
  • server is a process that provides system services.
  • the service manager is used to convert the binder name in character form into a reference to the binder in the client, so that the client can obtain a reference to the binder entity in the server through the binder name.
  • the binder driver is responsible for establishing the binder communication between the processes, and supports the data transfer and interaction between the processes at the bottom.
  • the client, server, and service manager are all located in the user space, and the binder driver is located in the kernel space.
  • the IPC mechanism includes the following three processes:
  • Registration service The server first registers the service with the service manager.
  • Obtaining a service Before a client uses a service, it needs to obtain the corresponding service information from the service manager.
  • Service use The client establishes a path between the server that provides the service according to the obtained service information, and then can interact with the server to use the service.
  • the server When the client and server communicate with the binder, the server creates or runs a binder thread to respond to the binder request initiated by the client.
  • the binder request is used to instruct the client to use a certain service.
  • IPC is actually the communication between threads in different processes.
  • S1 needs to start the binder thread T2 in order to process the binder request.
  • thread T1 is in a waiting state for receiving return data.
  • T2 processes the request, it returns the processing result to T1, and T1 is awakened to obtain the processing result.
  • T2 is like T1's agent in process S, performing remote tasks on behalf of T1, and the feeling given to T1 is like crossing into S to execute a piece of code and returning to C.
  • the server process For the same server process, multiple client processes may initiate binder requests to it at the same time. In order to improve efficiency, the server process often opens up a thread pool to concurrently process the received binder requests.
  • the application process can be regarded as a client, and the system process can be regarded as a server.
  • the application process calls the system service thread in the system service process through the binder thread in the system process, thereby calling memory resources and/or hardware resources in the kernel space, and using various system services provided by the system process.
  • the binder thread is a channel through which the application thread calls the system service thread, and can be regarded as a channel through which the application thread obtains system services.
  • the Android system stipulates that a system process can create up to 32 binder threads for data communication between processes.
  • the 32 binder threads call the system service threads in the system service process according to the client's request to access the corresponding memory resources and/or hardware resources in the kernel space.
  • Each binder thread is equivalent to an inter-process channel, and each binder thread can call the system service thread to obtain the corresponding system service in response to the current binder request.
  • Each binder thread can call any system service thread, and there is a fair competition between the binder threads for the system service thread.
  • a binder thread can only process one binder request at a time.
  • the resource scheduling method provided in the embodiment of the present application can be used.
  • the electronic device will increase the probability that application threads with high priority compete for system services, thereby ensuring that application threads with higher priority can run smoothly first, thereby ensuring the performance of electronic devices and improving user experience .
  • the application thread competing for the system service means that the application thread successfully calls the system service thread that provides the system service through the binder thread, and the system service thread occupies the memory in the kernel space that provides the system service. Resources, and/or hardware resources that provide the system service to obtain the corresponding system service.
  • an electronic device when it runs a map application, it will start one or more threads to complete navigation.
  • the one or more threads can perform one or more of the following operations: call the WMS thread through the binder thread, update the window information mWindowMap stored in the memory resource in the kernel space through the WMS thread; call the location manager service through the binder thread Thread calls GPS hardware resources through the location management service thread to obtain location information; calls the audio service thread through the binder thread, and calls audio devices such as speakers through the audio service thread for voice playback.
  • FIG. 3A shows a schematic flowchart of a resource scheduling method provided by an embodiment of the present application.
  • the electronic device After the electronic device is turned on, it automatically executes the resource scheduling method provided in the embodiment of the present application. That is, after the electronic device is turned on, when an application thread calls a system service, the probability that an application thread with a higher priority competes for a system service is increased, thereby ensuring that an application thread with a higher priority can run smoothly first. In this way, the electronic device can ensure that applications with higher priority can run smoothly in all scenarios, thereby ensuring performance and improving user experience.
  • the electronic device executes the resource scheduling method provided in the embodiment of this application.
  • the key scenario may refer to a scenario in which part or all of the application threads in the application process frequently call system services when the electronic device is running an application process, and this part of the application threads may be application threads with a higher priority.
  • the electronic device may monitor the frequency of calling system services by one or more running application threads, and when the frequency of calling system services by the one or more application threads is greater than a preset value, it is determined that it is currently in a critical scenario.
  • the preset value can be set in advance.
  • the frequency with which the application thread calls the system service can be measured by the number of times the application thread calls the system service within a certain period of time. The more the times, the higher the frequency with which the application thread calls the system service.
  • the key scenes may include, but are not limited to: a scene where the electronic device starts an application, a scene where the electronic device switches and displays a user interface, a scene where the electronic device slides up and down to display the user interface, and so on.
  • the activity manager activity manager
  • the components can include workflow (Activity), service (Service), broadcast receiver (Content Provider Broadcast) and content provider (Receiver),
  • the electronic device can identify key scenarios such as application startup and activity switching in the activity startup process of the activity manager.
  • the window manager (window manager) is used to manage the service of the window, and the electronic device can collect the sliding scene in the sliding gesture monitor (FlingGestureDetector) of the window manager.
  • the resource scheduling method may include the following steps:
  • Step S110 The electronic device runs the application process and the system service process.
  • the application process includes one or more application threads.
  • the system service process includes: one or more system service threads and multiple binder threads.
  • an electronic device when an electronic device opens or runs an application program, it usually opens one or more processes to implement various functions of the application program. For example, when an electronic device starts an instant messaging application, it will run a process to implement functions such as a display interface provided by the instant messaging application, playing voice, receiving contact messages, and sending contact messages. Further, these functions can be implemented by different threads in the application process.
  • the system service process is a process that provides system services that can be realized by electronic devices. These system services may include but are not limited to: AMS, PMS, WMS, NMS, IMS, Bluetooth management services, status bar management services, notification bar management services, network status management services, network connection management services, and so on.
  • AMS is used to manage activities running on electronic devices.
  • WMS is used to implement functions related to interfaces or windows on electronic devices, such as starting windows, deleting windows, setting window levels, or animations, and so on.
  • the PMS is responsible for processing the calculations and decisions related to the power supply of the electronic equipment, such as controlling the display screen to turn off, darken, and brighten.
  • Step S120 The electronic device divides the multiple binder threads in the system service process into multiple binder thread groups, each binder thread group includes different binder threads, and at least two binder thread groups have different numbers of binder threads.
  • the electronic device can divide each binder thread in the system service process into multiple binder thread groups, each binder thread group includes different binder threads, and there are at least two binder threads included in the binder thread group The number is different.
  • each binder thread group there is a corresponding relationship between each binder thread group and the application thread.
  • the corresponding relationship specifically includes: one or more application threads correspond to a thread group, and at least one high-priority application thread corresponds to the binder thread group corresponding to the number of binder threads contained in the binder thread group, which is greater than that corresponding to the low-priority application thread The number of binder threads included in the binder thread group.
  • the priority of each application thread can be predefined. For the definition of the application thread priority, please refer to the relevant description in point (1) above, which will not be repeated here.
  • the binder thread in the binder thread group is used to process the binder request initiated by the application thread corresponding to the binder thread group.
  • a binder request initiated by an application thread is processed by the binder thread in the binder thread group corresponding to the application thread.
  • the electronic device may divide each binder thread in the system service process into a first binder thread group and a second binder thread group.
  • the number of binder threads included in the first binder thread group is greater than the number of binder threads included in the second binder thread group.
  • the first binder thread group may include 30 binder thread groups
  • the second binder thread group may include 2 binder thread groups.
  • the first binder thread group can correspond to a higher priority application thread, that is, the binder thread in the first binder thread group is used to process the binder request initiated by the higher priority application thread.
  • the second binder thread group can correspond to a lower priority application thread, that is, the binder thread in the second binder thread group is used to process the binder request initiated by the lower priority application thread.
  • the identifier of the first binder thread group may be the foreground (frontground, FG)
  • the identifier of the second binder thread group may be the background (background, BG).
  • Table 1 the last column in Table 1 exemplarily shows the correspondence between the binder thread group and the application thread.
  • application threads with higher priority ie, application threads with QoS 1, 2, and 3
  • the thread ie, the application thread whose QoS is 0
  • the binder thread group identified as BG corresponds to the binder thread group.
  • binder thread in the system process into two binder thread groups as described in the above example.
  • it can also be divided into more binder thread groups, which is not limited in the embodiment of the present application.
  • one priority application thread may also correspond to a binder thread group, which is not limited in the embodiment of the present application.
  • the electronic device may divide the binder thread into the corresponding binder thread group every time a binder thread is created.
  • the electronic device may divide the binder thread into the corresponding binder thread group every time a binder thread is created.
  • FIG. 4A shows a schematic flow chart of creating a binder thread in an electronic device and dividing the binder thread into a binder thread group. The process shown in FIG. 4A can be completed in the core layer of the electronic device.
  • Step S130 In the application process running on the electronic device, when an application thread calls the system service, the application thread initiates a binder request to the system service process.
  • the application thread in the application process that calls the system service means that when the electronic device runs the application program corresponding to the application process, the implemented function needs to be provided by the system service. For example, when the electronic device is running WeChat and the user interface of WeChat is displayed on the display, the process of WeChat needs to use WMS to draw and display the user interface provided by WeChat on the display. When the user enters a message through the user interface, the WeChat process needs to use IMS to provide input method management services.
  • the application thread Since the application process cannot directly call various system services provided by the electronic device, when an application thread in the application process calls the system service, the application thread needs to obtain or call the system service through the system service process. Specifically, the application thread initiates a binder request to the system service process.
  • the binder request contains the indication information of the system service that needs to be called, and the binder request is used to request the system service process to call the corresponding system service thread to provide the application process with the system service indicated by the indication information.
  • Step S140 In response to the binder request initiated by the application thread, the electronic device calls the system service thread in the system service process through the binder thread in the first binder thread group corresponding to the application thread, and the system service thread is used to provide the The binder requests the requested system service.
  • the electronic device can find the binder thread group corresponding to the application thread that initiated the binder request according to the correspondence between the application thread and the binder thread group, and use the binder thread in the binder thread group to call the system service thread.
  • the electronic device can use the following method to call the system service thread in the system service process through the binder thread in the first binder thread group corresponding to the application thread: in the binder thread group corresponding to the application thread, If there is a binder thread in the idle state, the binder thread in the idle state is used to respond to the binder request initiated by the application thread, and the corresponding system service thread is called to provide the system service requested by the binder request. If there is no binder thread in the idle state in the binder thread group, store the binder request in the waiting queue of the binder thread group corresponding to the application thread that initiated the binder request, and wait for a binder request Process after entering the idle state.
  • each binder thread has two states: idle state and running state.
  • Binder thread in the running state means that the binder thread is responding to a binder request, calling the system service thread corresponding to the system service requested by the binder request, executing the service code of the server, and realizing the corresponding system service.
  • idle state it means that the binder thread is idle without responding to any binder request.
  • each binder thread group has a corresponding waiting queue.
  • the waiting queue is used to store unprocessed binder requests initiated by the application thread corresponding to the binder thread group when all binder threads in the binder thread group are in a running state. If a binder thread in the binder thread group performs a task and switches from the running state to the idle state, the binder thread can obtain a binder request from the waiting queue and perform corresponding operations in response to the binder request.
  • the electronic device may put unprocessed binder requests into the waiting queue of the binder thread group in chronological order, for example, put the newly received binder request into the end of the waiting queue.
  • the binder thread when a binder thread in the binder thread group switches from the running state to the idle state, the binder thread can respond to the binder request in the waiting queue in chronological order, such as responding to the binder request at the top of the queue in the waiting queue Wait. In this way, it can be ensured that the electronic device sequentially processes each binder request in chronological order.
  • FIG. 3B exemplarily shows a schematic diagram of the binder thread group processing the binder request in the system service process.
  • the electronic device divides 32 binder threads into 2 binder thread groups.
  • the binder thread group identified as "FG” includes 30 binder threads from T0 to T29
  • the binder thread group identified as "BG” includes 2 binder threads from T30 to T31.
  • the binder thread group identified as "FG” corresponds to application threads with QoS 1-3
  • the binder thread group identified as "BG” corresponds to application threads with QoS 0.
  • the binder thread group identified as "FG” also has binder threads in an idle state, and there are no pending binder requests in the corresponding waiting queue. There is no binder thread in the idle state in the binder thread group identified as "BG", and its corresponding waiting queue includes pending binder requests 1-3. Each binder thread group will process the binder requests in the waiting queue in turn from the top of the waiting queue.
  • Binder requests 2-3 After a period of time, as shown in the second picture of Figure 3B, there is a binder thread in the binder thread group identified as "BG" that reads and processes binder request 1 from the waiting queue, and there are still some remaining in the corresponding waiting queue Binder requests 2-3.
  • the application thread with QoS 1-3 initiates binder request 4-7
  • the application thread with QoS 0 initiates binder request 8-10
  • the electronic device calls 2 binder threads
  • Each group handles the corresponding binder request.
  • the electronic device uses the binder thread group identified as "FG" to process binder requests 4-7.
  • the idle binder threads T28 and T29 can be used to process binder requests 4-5, and binder requests 6-7 are Put it in the waiting queue.
  • the electronic device uses the binder thread group identified as "BG" to process binder requests 8-10. Since there is no binder thread in the idle state in the binder thread group identified as "BG", the electronic device requests 8-10 from the binder thread.
  • FIG. 4B shows a schematic flow chart of processing the binder request when the binder request is generated internally by the electronic device. The process shown in FIG. 4B can be completed in the core layer of the electronic device.
  • the application thread that initiates the binder request may be called the first thread
  • the system service requested by the binder request may be called the first system service
  • the system that provides the first system service The thread may be referred to as the first system thread
  • the binder thread group corresponding to the first thread may be referred to as the first binder thread group.
  • the waiting queue of the first binder thread group may be referred to as the first waiting queue.
  • the electronic device divides each binder thread in the system service process into multiple binder thread groups, and the electronic device can use the binder thread in the specific binder thread group to process the application thread initiated by the corresponding priority binder request.
  • the number of binder threads in the binder thread group corresponding to the application thread with the higher priority is greater, and the electronic device can use a larger number of binder threads to respond to the application thread with the higher priority.
  • Binder requests use a small number of binder threads to respond to binder requests initiated by low-priority application threads. In this way, it is equivalent to assigning more channels to high-priority application threads in the channels that call system service threads, and assigning fewer channels to low-priority application threads. In this way, the probability of higher priority application threads competing for system services can be increased, thereby ensuring that higher priority application threads can run smoothly first, ensuring the performance of electronic devices, and improving user experience.
  • the electronic device may also perform flow control processing on the binder thread group corresponding to the application thread with a lower priority.
  • flow control processing it is possible to reduce the probability of the binder thread in the binder thread group holding the lock, that is, to reduce the probability of the binder thread in the binder thread group competing or accessing the system service thread.
  • Flow control processing refers to reducing the frequency of the binder thread processing the binder request in the binder thread group corresponding to the lower priority application thread.
  • flow control processing can also refer to reducing the frequency of binder thread processing binder requests in one or more binder thread groups that contain a small number of binder threads.
  • reducing the frequency of the binder thread processing the binder request may refer to extending the time interval in which the binder thread is in an idle state between processing two binder requests.
  • the binder threads in the binder thread group in the system service process process binder requests at the same frequency. For example, they can all process one binder request immediately after processing another binder request.
  • the binder thread in the binder thread group corresponding to one or more application threads with a lower priority that is, the binder thread in one or more binder thread groups with a small number of binder threads
  • processes the binder request The frequency is lower than other binder threads. For example, after processing a binder request, after a period of idle state, the next binder request can be processed.
  • the electronic device can adjust the priority of the first binder thread group and the second binder thread group
  • the frequency of the binder thread calling the system service thread makes the frequency of the binder thread in the first binder thread group calling the system service thread lower than the frequency of the binder thread calling the system service thread in the second binder thread group.
  • FIG. 4C shows a schematic flow diagram of an electronic device performing flow control processing on one or more binder thread groups containing a small number of binder threads. The process shown in FIG. 4C can be completed in the core layer of the electronic device.
  • the electronic device can further reduce the probability of application threads with lower priority competing for system services, and increase the probability of application threads with higher priority competing for system services. In this way, it can be ensured that the application threads with higher priority can run smoothly first, meet the needs of users for key scenarios, and improve the user experience.
  • the electronic device fails to pass the binder thread in the binder thread group corresponding to the application thread within the preset time to call the system service requested by the binder request, then the electronic device The binder request initiated by the application thread can be put into the waiting queue of the binder thread group corresponding to the higher priority application thread.
  • the electronic device fails to call the first system service thread in the system service thread through the binder thread in the first binder thread group corresponding to the first thread, Then the binder request of the first thread is put into the second waiting queue.
  • the priority of the application thread corresponding to the second binder thread group is higher than the priority of the application thread corresponding to the first binder thread group, and the waiting queue of the second binder thread group is called the second waiting queue.
  • the preset time can be set in advance.
  • the reason why the electronic device fails to pass the binder thread in the binder thread group corresponding to the application thread within the preset time to call the system service requested by the binder request may include: the binder thread group corresponding to the application thread There are too many unprocessed binder threads in the waiting queue of the application thread, causing the binder threads in the binder thread group corresponding to the application thread to be in a running state for a long time and cannot process the binder thread.
  • the electronic device can send the binder request 10 Adjust to the waiting queue of the binder thread group identified as "FG".
  • the binder thread group corresponding to the higher priority application thread has more binder thread groups, so the binder request can be responded to faster. In this way, the application thread that initiated the binder request can be prevented from being starved to death.
  • the resources originally allocated to the higher priority application thread can be used to process the binder request, which can be dynamically and reasonably based on the needs of the electronic device Scheduling memory resources and hardware resources.
  • the strategy for the electronic device to adjust the number of binder threads included in each binder thread group may include:
  • the usage rate of binder threads in the binder thread group refers to the proportion of binder threads in the running state in the binder thread group to all binder threads in the binder thread group.
  • the first value, second value, first preset value, second preset value, third preset value, and fourth preset value mentioned in the above strategy can all be preset.
  • the number of binder threads included in each binder thread group can be dynamically adjusted according to the actual operating conditions of the electronic device, and the binder requests initiated by each application thread can be processed in a balanced manner to prevent the application threads that initiate the binder request from starving.
  • FIG. 5 shows several software modules involved in the electronic device and the data interaction between the modules when the electronic device executes the resource scheduling method shown in FIG. 3A.
  • the electronic device may run one or more application processes and system service processes at the application framework layer.
  • the binder driver in the kernel layer can include three modules: a binder request receiving module, a binder request scheduling module, and a binder request storage module. among them:
  • the Binder request storage module is used to store one or more waiting queues, each waiting queue corresponds to a binder thread group, and each waiting queue includes N binder requests. N is an integer greater than or equal to zero.
  • the binder thread can obtain the pending binder request in the waiting queue of the group to which it belongs from the binder request storage module, and call the corresponding system service thread according to the system service requested by the binder request, thereby obtaining the system service.
  • the Binder request receiving module is used to receive the binder request initiated by the application thread.
  • the Binder request scheduling module may also perform flow control processing on the binder thread group corresponding to the application thread with a lower priority.
  • flow control processing refer to the relevant description of the foregoing method embodiment.
  • the computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or a data center integrated with one or more available media.
  • the usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, and a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid state disk).
  • the process can be completed by a computer program instructing relevant hardware.
  • the program can be stored in a computer readable storage medium. , May include the processes of the foregoing method embodiments.
  • the aforementioned storage media include: ROM or random storage RAM, magnetic disks or optical disks and other media that can store program codes.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)
  • Telephone Function (AREA)

Abstract

Procédé de planification de ressources et dispositif électronique. Dans le procédé, un dispositif électronique répond, en utilisant un grand nombre de fils de liaison, à une demande de liant initiée par un fil d'application ayant une priorité élevée, et répond, en utilisant un petit nombre de fils de liaison, à une demande de liant initiée par un fil d'application ayant une faible priorité, de manière à améliorer la probabilité que le fil d'application ait une priorité élevée, ce qui permet d'obtenir un service de système par compétition, ce qui garantit que le fil d'application ayant une priorité élevée peut fonctionner de manière préférentielle et sans à-coups, garantissant la performance du dispositif électronique, et améliorant l'expérience d'utilisation d'un utilisateur.
PCT/CN2020/115886 2019-09-19 2020-09-17 Procédé de planification de ressources et dispositif électronique WO2021052415A1 (fr)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910888922.3A CN112527476B (zh) 2019-09-19 2019-09-19 资源调度方法及电子设备
CN201910888922.3 2019-09-19

Publications (1)

Publication Number Publication Date
WO2021052415A1 true WO2021052415A1 (fr) 2021-03-25

Family

ID=74883401

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/115886 WO2021052415A1 (fr) 2019-09-19 2020-09-17 Procédé de planification de ressources et dispositif électronique

Country Status (2)

Country Link
CN (1) CN112527476B (fr)
WO (1) WO2021052415A1 (fr)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114816703A (zh) * 2022-04-26 2022-07-29 北京奥星贝斯科技有限公司 一种任务处理方法、装置、设备及介质
CN117707718A (zh) * 2023-06-29 2024-03-15 荣耀终端有限公司 进程管理的方法、电子设备及可读存储介质

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113535362B (zh) * 2021-07-26 2023-07-28 北京计算机技术及应用研究所 一种分布式调度系统架构和微服务工作流调度方法
CN115729684B (zh) * 2021-08-25 2023-09-19 荣耀终端有限公司 输入输出请求处理方法和电子设备
CN116048771B (zh) * 2022-08-15 2023-10-20 荣耀终端有限公司 一种资源调度方法及相关设备
CN116048833B (zh) * 2022-08-31 2023-10-20 荣耀终端有限公司 一种线程处理方法、终端设备及芯片系统
CN116661985B (zh) * 2022-10-25 2024-05-14 荣耀终端有限公司 一种垃圾回收的守护线程的管理方法、装置及电子设备
CN116578422B (zh) * 2023-06-15 2024-06-14 荣耀终端有限公司 资源分配方法和电子设备

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107861817A (zh) * 2017-11-30 2018-03-30 努比亚技术有限公司 基于线程阻塞的内存优化方法、移动终端及可读存储介质
CN108924128A (zh) * 2018-06-29 2018-11-30 Oppo(重庆)智能科技有限公司 一种移动终端及其进程间通信的限制方法、存储介质
CN108984321A (zh) * 2018-06-29 2018-12-11 Oppo(重庆)智能科技有限公司 一种移动终端及其进程间通信的限制方法、存储介质
CN109032812A (zh) * 2018-06-29 2018-12-18 Oppo(重庆)智能科技有限公司 一种移动终端及其进程间通信的限制方法、存储介质
CN109992400A (zh) * 2017-12-29 2019-07-09 广东欧珀移动通信有限公司 资源分配方法、装置、移动终端及计算机可读存储介质

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9715406B2 (en) * 2013-06-14 2017-07-25 Microsoft Technology Licensing, Llc Assigning and scheduling threads for multiple prioritized queues
CN109002364B (zh) * 2018-06-29 2021-03-30 Oppo(重庆)智能科技有限公司 进程间通信的优化方法、电子装置以及可读存储介质
CN109117280B (zh) * 2018-06-29 2020-10-02 Oppo(重庆)智能科技有限公司 电子装置及其限制进程间通信的方法、存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107861817A (zh) * 2017-11-30 2018-03-30 努比亚技术有限公司 基于线程阻塞的内存优化方法、移动终端及可读存储介质
CN109992400A (zh) * 2017-12-29 2019-07-09 广东欧珀移动通信有限公司 资源分配方法、装置、移动终端及计算机可读存储介质
CN108924128A (zh) * 2018-06-29 2018-11-30 Oppo(重庆)智能科技有限公司 一种移动终端及其进程间通信的限制方法、存储介质
CN108984321A (zh) * 2018-06-29 2018-12-11 Oppo(重庆)智能科技有限公司 一种移动终端及其进程间通信的限制方法、存储介质
CN109032812A (zh) * 2018-06-29 2018-12-18 Oppo(重庆)智能科技有限公司 一种移动终端及其进程间通信的限制方法、存储介质

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114816703A (zh) * 2022-04-26 2022-07-29 北京奥星贝斯科技有限公司 一种任务处理方法、装置、设备及介质
CN117707718A (zh) * 2023-06-29 2024-03-15 荣耀终端有限公司 进程管理的方法、电子设备及可读存储介质

Also Published As

Publication number Publication date
CN112527476B (zh) 2024-03-26
CN112527476A (zh) 2021-03-19

Similar Documents

Publication Publication Date Title
WO2021052415A1 (fr) Procédé de planification de ressources et dispositif électronique
US11573829B2 (en) Task processing method and apparatus, terminal, and computer readable storage medium
WO2021052263A1 (fr) Procédé et dispositif d'affichage d'assistant vocal
WO2021017889A1 (fr) Procédé d'affichage d'appel vidéo appliqué à un dispositif électronique et appareil associé
WO2021213164A1 (fr) Procédé d'interaction entre des interfaces d'application, dispositif électronique et support de stockage lisible par ordinateur
WO2020134869A1 (fr) Procédé de fonctionnement d'un dispositif électronique et dispositif électronique
WO2021036770A1 (fr) Procédé de traitement d'écran partagé et dispositif terminal
WO2021185244A1 (fr) Procédé d'interaction avec le dispositif et dispositif électronique
WO2022068483A1 (fr) Procédé et appareil de démarrage d'application, et dispositif électronique
EP4280056A1 (fr) Procédé d'application d'opération de dessin et dispositif électronique
US20230351048A1 (en) Application Permission Management Method and Apparatus, and Electronic Device
WO2021052204A1 (fr) Procédé de découverte de dispositif basé sur un carnet d'adresses, procédé de communication audio et vidéo, et dispositif électronique
WO2021078032A1 (fr) Procédé d'affichage d'interface utilisateur et dispositif électronique
WO2022017393A1 (fr) Système d'interaction d'affichage, procédé d'affichage, et dispositif
WO2022127632A1 (fr) Procédé de gestion et de commande de ressources, et dispositif
WO2021052070A1 (fr) Procédé d'identification de fréquence de trames et dispositif électronique
WO2022037726A1 (fr) Procédé d'affichage à écran partagé et dispositif électronique
WO2021104000A1 (fr) Procédé d'affichage d'écran et dispositif électronique
WO2021218429A1 (fr) Procédé de gestion d'une fenêtre d'application, dispositif terminal et support de stockage lisible par ordinateur
WO2021031865A1 (fr) Procédé et appareil d'appel
WO2022100141A1 (fr) Procédé, système et appareil de gestion de module d'extension
WO2022078105A1 (fr) Procédé de gestion de mémoire, dispositif électronique et support de stockage lisible par ordinateur
EP4152782A1 (fr) Procédé et appareil de poussée de message
WO2022017474A1 (fr) Procédé de traitement de tâches et appareil associé
CN117130773B (zh) 资源分配方法、装置和设备

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: 20865956

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20865956

Country of ref document: EP

Kind code of ref document: A1