Process scheduling method, device and electronic equipment

By dynamically adjusting the scheduling weight value and virtual running time, priority is given to scheduling processes holding memory locks, which solves the problem of processes blocking due to inability to hold locks under high load states, and improves the user interface response speed and user experience.

CN117707720BActive Publication Date: 2025-01-03HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310991089.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-07
Publication Date
2025-01-03
Estimated Expiration
2043-08-07

AI Technical Summary

Technical Problem

When the electronic device is in a high load state, the lock-holding process may not be allocated to the processor resources, resulting in other processes being blocked due to the inability to hold the memory lock, affecting the user interface display and user experience.

Method used

By dynamically adjusting the scheduling weight value and virtual running time of the target process group, priority is given to the target process holding the memory lock to release the memory lock as soon as possible, reducing the probability that other processes will be blocked due to the inability to hold the lock.

Benefits of technology

It effectively reduces the probability of other processes blocking due to the lock-holding process being in the runnable state for a long time, and improves the user interface response speed and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117707720B_ABST
    Figure CN117707720B_ABST
Patent Text Reader

Abstract

The present application discloses a process scheduling method, device and electronic device, belonging to the field of scheduling technology, the method comprising: when the memory pressure value of the electronic device is greater than the pressure threshold, obtaining the scheduling weight value of each process in the scheduling queue; determining the lock status of each process in the scheduling queue; when the scheduling queue includes a process whose scheduling weight value is a first value and whose lock status is a process holding a memory lock, setting the virtual runtime vruntime of the target process to a first time value; scheduling each process in the scheduling queue based on the size of the vruntime of each process in the scheduling queue. In the method, if it is determined that the scheduling queue includes a process that holds a memory lock and belongs to the target process group, the target process is scheduled first so that the target process releases the memory lock as soon as possible, thereby solving the problem of process blocking caused by the inability to hold the memory lock for a long time in processes of other process groups.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of scheduling technology, and in particular, relates to a process scheduling method, device and electronic equipment. Background Art

[0002] In computer science, a memory lock is a concurrent access mechanism used to protect shared memory resources. A memory lock can only be held by one process at a time. When a process obtains a memory lock, it can safely access shared resources, while other processes need to wait for the memory lock to be released. In this way, memory locks can solve the problem of memory resource competition in a concurrent environment, ensure exclusive access to shared memory resources, and avoid inconsistent or erroneous results caused by multiple processes modifying shared data at the same time.

[0003] However, when the electronic device is under high load, the lock-holding process may not be allocated processor resources, which may cause other processes to be blocked because they cannot hold the memory lock. Summary of the invention

[0004] The present application provides a process scheduling method, device and electronic device, which can reduce the probability that other processes are in a blocked state because they cannot hold a memory lock due to the lock-holding process being in a runnable state for a long time.

[0005] In a first aspect, the present application provides a process scheduling method, which is applied to an electronic device, and the method includes: when the memory pressure value of the electronic device is greater than a pressure threshold, obtaining the scheduling weight value of each process in the scheduling queue; the scheduling queue includes M processes in an executable state, M is a positive integer greater than or equal to 1; determining the locking state of the M processes; when the scheduling queue includes a target process, setting the virtual runtime vruntime of the target process to a first time value; wherein the target process is a process whose scheduling weight value is a first value and whose locking state is a process holding a memory lock; the scheduling weight value corresponding to other processes in the foreground application of the electronic device except the drawing process and the rendering process is a first value, and the scheduling weight value corresponding to the drawing process and the rendering process in the foreground application is a second value, and the first value and the second value are different; the first time value is the minimum value of the vruntime of all processes in the scheduling queue; and scheduling each process in the scheduling queue based on the size of the vruntime of each process in the scheduling queue.

[0006] In this way, since the scheduling weight values ​​corresponding to the processes of the top-app process group (i.e., other processes in the foreground application except the drawing process and the rendering process) and the processes of other process groups (i.e., the drawing process and the rendering process in the foreground application) are different, when the memory pressure value of the electronic device is greater than the pressure threshold, it can be determined based on the scheduling weight value of each process whether the scheduling queue includes processes belonging to the top-app process group.

[0007] Since the fair scheduling algorithm schedules each process in the scheduling queue in ascending order of vruntime, that is, each time it schedules, the fair scheduling algorithm will select the process with the smallest vruntime among all processes for scheduling. In this way, since the target process is included in the scheduling queue, the vruntime of the target process is set to the minimum value of the vruntime of all processes, the target process with the smallest vruntime will be scheduled first. In this way, the target process that belongs to the top-app process group and holds the lock can be scheduled first to release the memory lock as soon as possible, avoiding blocking of other process groups due to the inability to hold the memory lock for a long time.

[0008] In one achievable manner, the method further includes: monitoring the memory pressure value of the electronic device; when the memory pressure value is greater than the pressure threshold, determining the scheduling weight value of the target process group as a first value; the target process group includes other processes in the foreground application except the drawing process and the rendering process; when the memory pressure value is less than or equal to the pressure threshold, determining the scheduling weight value of the target process group as a second value; wherein the first value is different from the second value.

[0009] In this way, by dynamically adjusting the scheduling weight value (shares value) of the target process group based on the memory pressure state of the electronic device, on the one hand, the scheduling module can distinguish the target process group from other process groups based on the shares value of each process. On the other hand, the scheduling module can also determine whether the electronic device is in a high-load state through the shares value. For example, if the scheduling queue includes a process whose shares value is a first value, it indicates that the electronic device is in a high-load state; if the scheduling queue does not include a process whose shares value is the first value, it indicates that the electronic device is in a low-load state.

[0010] In addition, since the shares value parameter is the same in different electronic devices, the present application can be compatible with different electronic devices by adjusting the shares value of the target process group to distinguish the target process group from other process groups, which is more conducive to code maintenance.

[0011] In one achievable manner, the second value is a default value of the scheduling weight value of the target process group, and an absolute value of a difference between the first value and the second value is less than a preset value.

[0012] In this way, the running time of the process is related to the shares value of the process. Therefore, in order to avoid affecting the running time of the process, the modification of the shares value is as small as possible. Based on this consideration, the modification range of the shares value can be set, that is, the absolute value of the difference between the first value and the second value is set to be less than the preset value. For example, the preset value is 1. In this way, the first value can be 1023 or 1025, and the second value can be the default value 1024.

[0013] In one implementable manner, the first value is 1023 or 1025, and the second value is 1024.

[0014] In one implementable manner, when the memory pressure value of the electronic device is greater than a pressure threshold, obtaining the scheduling weight value of each process in the scheduling queue includes: when the memory pressure value of the electronic device is greater than the pressure threshold and the foreground application of the electronic device includes a drawing process and a rendering process, obtaining the scheduling weight value of each process in the scheduling queue.

[0015] In the case where the foreground application of an electronic device includes a drawing process and a rendering process, it usually involves the user interface display. If the drawing process and the rendering process in the foreground application are in a blocked state for a long time, the display of the user interface is affected, and the user will perceive a jam, thereby affecting the user experience. Therefore, in order to avoid the drawing process and the rendering process being in a blocked state for a long time, when it is identified that the foreground application of the electronic device includes a drawing process and a rendering process, the process scheduling method provided in the first aspect of the present application is executed, so that the target process belonging to the top-app process group and holding a lock can be scheduled preferentially to release the memory lock as soon as possible, so as to avoid other process groups from being blocked due to the inability to hold the memory lock for a long time.

[0016] In one implementable manner, before setting the virtual runtime vruntime of the target process to the first time value, it also includes: when the target process is included in the scheduling queue, determining the virtual runtime vruntime of the target process; when the virtual runtime vruntime of the target process is not the minimum value of the vruntime of all processes in the scheduling queue, setting the virtual runtime vruntime of the target process to the first time value.

[0017] In this way, before setting the virtual runtime vruntime of the target process to the first time value, it can be determined whether the vruntime of the target process is the minimum value of the vruntime of all processes in the scheduling queue. If the vruntime of the target process is the minimum value of the vruntime of all processes in the scheduling queue, the vruntime of the target process may not be modified. If the vruntime of the target process is not the minimum value of the vruntime of all processes in the scheduling queue, the vruntime of the target process is modified to the first time value.

[0018] In one achievable manner, the first time value is the difference between the second time value and the rotation period, the second time value is the vruntime of the target process before modification, and the rotation period is the time required for all processes in the scheduling queue to run one round.

[0019] In this way, subtracting the rotation cycle from the original vruntime (i.e., the second time value) of the target process is equivalent to the scheduling module reducing the vruntime of the target process by one rotation cycle. In this way, the modified vruntime value of the target process must be the minimum value of the vruntime of all processes in the scheduling queue. In addition, this modification method does not require the introduction of other parameters in the fair scheduling algorithm, and can directly call the original rotation cycle parameters and modify the vruntime of the target process based on the rotation cycle.

[0020] In one achievable manner, the method further includes: when the process holds a memory lock, setting the lock holding mark of the process to a first mark, the first mark being used to characterize the lock holding state of the process as holding a memory lock; when the process has released the memory lock, setting the lock holding mark of the process to a second mark, the second mark being used to characterize the lock holding state of the process as releasing the memory lock.

[0021] In this way, by adding a lock mark to the process structure, the scheduling module can easily identify the lock status of the process.

[0022] In one implementable manner, determining the locking status of the M processes includes: obtaining the locking marks of the M processes; determining that the locking status of the process whose locking mark is a first mark is holding a memory lock; and determining that the locking status of the process whose locking mark is a second mark is releasing a memory lock.

[0023] In one achievable manner, setting the lock holding flag of the process to a first flag when the process holds a memory lock includes: setting the value of the lock holding flag of the process to a third value when the process holds the memory lock.

[0024] In one achievable manner, setting the lock mark of the process to a second mark when the process has released the memory lock includes: setting the value of the lock mark of the process to a fourth value when the process has released the memory lock, wherein the fourth value is different from the third value.

[0025] In a second aspect, the present application provides a process scheduling device, the device comprising:

[0026] An acquisition module, used for acquiring a scheduling weight value of each process in a scheduling queue when a memory pressure value of the electronic device is greater than a pressure threshold; the scheduling queue includes M processes in an executable state, where M is a positive integer greater than or equal to 1;

[0027] A lock status determination module, used to determine the lock status of the M processes;

[0028] A vruntime setting module is used to set the virtual runtime vruntime of the target process to a first time value when the target process is included in the scheduling queue; wherein the target process is a process whose scheduling weight value is a first value and whose lock state is a process holding a memory lock; the scheduling weight values ​​corresponding to other processes in the foreground application of the electronic device except the drawing process and the rendering process are a first value, and the scheduling weight values ​​corresponding to the drawing process and the rendering process in the foreground application are a second value, and the first value and the second value are different; the first time value is the minimum value of the vruntime of all processes in the scheduling queue;

[0029] The scheduling module is used to schedule each process in the scheduling queue based on the size of the vruntime of each process in the scheduling queue.

[0030] In a third aspect, the present application provides an electronic device, comprising a memory and a processor; the memory and the processor are coupled; the memory is used to store computer program code, the computer program code comprises computer instructions, and when the processor executes the computer instructions, the electronic device executes a method as described in any one of the first aspects.

[0031] In a fourth aspect, the present application provides a computer-readable storage medium, wherein a computer program or instructions are stored in the computer-readable storage medium. When the computer program or instructions are executed on a computer, the computer executes the method as described in any one of the first aspects. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0033] Figure 1 A schematic diagram of a process state of an application provided in an embodiment of the present application;

[0034] Figure 2 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;

[0035] Figure 3 A schematic diagram of a software framework of an electronic device provided in an embodiment of the present application;

[0036] Figure 4 A schematic diagram of a framework for implementing a process scheduling method provided in an embodiment of the present application;

[0037] Figure 5 A flowchart of a process scheduling method provided in an embodiment of the present application;

[0038] Figure 6 A flowchart of a method for determining a target process group provided in an embodiment of the present application;

[0039] Figure 7 A module interaction diagram of a process scheduling method provided in an embodiment of the present application;

[0040] Figure 8 A schematic diagram of the structure of a process scheduling device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0041] In computer science, a memory lock is a mechanism used to protect concurrent access to shared memory resources. A memory lock is a mutex object that can only be held by one process at a time. When a process acquires a memory lock, it can safely access shared resources, while other processes need to wait for the memory lock to be released. In this way, memory locks can solve the problem of memory resource competition in a concurrent environment, ensure exclusive access to shared memory resources, and avoid inconsistent or erroneous results caused by multiple processes modifying shared data at the same time.

[0042] The basic operations of memory lock usually include two types: locking and unlocking.

[0043] Lock: When a process attempts to obtain a memory lock, if the memory lock is not currently held, it can successfully obtain the memory lock and become the holder of the memory lock. At this time, other processes need to wait for the memory lock to be released. In this case, the lock state of the process that successfully obtains the memory lock is holding the memory lock.

[0044] Unlock: After the holder of the memory lock has finished using the shared resource, he releases the memory lock, allowing other processes to acquire the memory lock and access the shared resource. In this case, the lock state of the process that has released the memory lock is released memory lock.

[0045] The running of a process depends on memory resources and processor (such as central processing unit CPU) resources. When a process holds a memory lock, it queues in the scheduling queue and waits for the scheduling module to allocate processor resources to run the process. At this time, the process is in the runnable state, which means that the process is ready and can run on the CPU.

[0046] However, the inventors have found that in some cases, the main process of the application is a process of the vip process group that is in a blocked state for a long time, which causes a response delay of the main process of the application, a freeze phenomenon, and affects the user experience.

[0047] Furthermore, by analyzing the reasons for the process blocking of the vip process group, it was found that: Figure 1 As shown, process 1 is a process of the vip process group, and process 2, process 3, and process 4 are all processes of the top-app process group. Process 1 is in a blocked state most of the time during the 0.0s-6.0s period because it cannot obtain the memory lock. For example, process 1 is in a blocked state during time periods T1, T2, and T3. Further tracking of the lock-holding processes revealed that: during the 0.0s-6.0s period, the memory lock was mainly held by processes of the top-app process group in different time periods. Specifically, in time period T1, the memory lock was held by process 2; in time period T2, the memory lock was held by process 3; in time period T3, the memory lock was held by process 4.

[0048] However, since the electronic device is under high load, after process 2, process 3 and process 4 hold the lock, they cannot be allocated processor resources, which causes process 2, process 3 and process 4 to be in the runnable state for a long time and cannot get the opportunity to run. Since the locked process is in the runnable state for a long time and cannot release the memory lock, process 1 is blocked because it cannot obtain the memory lock.

[0049] It can be seen that when the electronic device is under high load, the lock-holding process of the top-app process group may not be allocated processor resources, resulting in the lock-holding process being in the runnable state for a long time and not getting the opportunity to run. In this way, the process of the vip process group will be in a blocked state because it cannot hold the memory lock.

[0050] Among them, the vip process group includes the drawing (UI) thread and rendering (Render) thread in the foreground application. The top-app process group includes other threads in the foreground application except the UI thread and the Render thread. The UI thread and the Render thread are usually used to handle user interface-related tasks, such as creating and displaying forms, processing user input, and updating the UI. Therefore, if the process of the vip process group is in a blocked state for a long time, it will affect the display of the user interface, and the user will feel the lag, which will affect the user experience.

[0051] To solve the above problems, an embodiment of the present application provides a process scheduling method. In this method, if it is determined that the scheduling queue includes a process that holds a memory lock and belongs to a target process group (such as a top-app process group), the process is scheduled preferentially so that the process releases the memory lock as soon as possible, thereby solving the problem that the processes of the vip process group are in a blocked state due to the inability to hold the memory lock for a long time.

[0052] The process scheduling method provided in the embodiment of the present application can be applied to electronic devices. Optionally, the electronic devices include but are not limited to mobile phones, tablet computers, personal computers, workstation devices, large-screen devices (for example, smart screens, smart TVs, etc.), handheld game consoles, home game consoles, virtual reality devices, augmented reality devices, mixed reality devices, in-vehicle smart terminals, etc.

[0053] Figure 2 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 2As shown, 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, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. 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 light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

[0054] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or separate some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0055] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.

[0056] The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of instruction fetching and execution.

[0057] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0058] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

[0059] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple groups of I2C buses. The processor 110 may be coupled to the touch sensor 180K, the charger, the flash, the camera 193, etc. through different I2C bus interfaces. For example: the processor 110 may be coupled to the touch sensor 180K through the I2C interface, so that the processor 110 communicates with the touch sensor 180K through the I2C bus interface, thereby realizing the touch function of the electronic device 100.

[0060] The I2S interface can be used for audio communication. In some embodiments, the processor 110 can include multiple I2S buses. The processor 110 can be coupled to the audio module 170 via the I2S bus to achieve communication between the processor 110 and the audio module 170. In some embodiments, the audio module 170 can transmit an audio signal to the wireless communication module 160 via the I2S interface to achieve the function of answering a call through a Bluetooth headset.

[0061] The PCM interface can also be used for audio communication, sampling, quantizing and encoding analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 can be coupled via a PCM bus interface. In some embodiments, the audio module 170 can also transmit audio signals to the wireless communication module 160 via the PCM interface to realize the function of answering calls via a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.

[0062] The UART interface is a universal serial data bus for asynchronous communication. The bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, the UART interface is generally used to connect the processor 110 and the wireless communication module 160. For example, the processor 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to implement the Bluetooth function. In some embodiments, the audio module 170 can transmit an audio signal to the wireless communication module 160 through the UART interface to implement the function of playing music through a Bluetooth headset.

[0063] The MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 194 and the camera 193. The MIPI interface includes a camera serial interface (CSI), a display serial interface (DSI), etc. In some embodiments, the processor 110 and the camera 193 communicate via the CSI interface to implement the shooting function of the electronic device 100. The processor 110 and the display screen 194 communicate via the DSI interface to implement the display function of the electronic device 100.

[0064] The GPIO interface can be configured by software. The GPIO interface can be configured as a control signal or as a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 with the camera 193, the display 194, the wireless communication module 160, the audio module 170, the sensor module 180, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.

[0065] The USB interface 130 is an interface that complies with the USB standard specification, and specifically can be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. 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 a peripheral device. It can also be used to connect headphones to play audio through the headphones. The interface can also be used to connect other electronic devices, such as AR devices, etc.

[0066] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present invention is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0067] The charging management module 140 is used to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from a wired charger through the USB interface 130. In some wireless charging embodiments, the charging management module 140 may receive wireless charging input through a wireless charging coil of the electronic device 100. While the charging management module 140 is charging the battery 142, it may also power the electronic device through the power management module 141.

[0068] 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 number, battery health status (leakage, impedance), etc. In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.

[0069] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.

[0070] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.

[0071] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.

[0072] The modem processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-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. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to a speaker 170A, a receiver 170B, etc.), or displays an image or video through a display screen 194. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be set in the same device as the mobile communication module 150 or other functional modules.

[0073] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0074] In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to 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), 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. The GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and / or a satellite based augmentation system (SBAS).

[0075] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.

[0076] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.

[0077] The electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.

[0078] ISP is used to process the data fed back by camera 193. For example, when taking a photo, the shutter is opened, and the light is transmitted to the camera photosensitive element through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to ISP for processing and converts it into an image visible to the naked eye. ISP can also perform algorithm optimization on the noise, brightness, and skin color of the image. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, ISP can be set in camera 193.

[0079] The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the ISP to be converted into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.

[0080] The digital signal processor is used to process digital signals, and can process not only digital image signals but also other digital signals. For example, when the electronic device 100 is selecting a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.

[0081] Video codecs are used to compress or decompress digital videos. The electronic device 100 may support one or more video codecs. Thus, the electronic device 100 may play or record videos in a variety of coding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.

[0082] NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can also continuously self-learn. Through NPU, applications such as intelligent cognition of electronic device 100 can be realized, such as image recognition, face recognition, voice recognition, text understanding, etc.

[0083] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function, such as storing music, video and other files in the external memory card.

[0084] The internal memory 121 can be used to store computer executable program codes, which include instructions. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, 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 disk storage device, a flash memory device, a universal flash storage (UFS), etc. 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.

[0085] The electronic device 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.

[0086] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be arranged in the processor 110, or some functional modules of the audio module 170 can be arranged in the processor 110.

[0087] The speaker 170A, also called a "speaker", is used to convert an audio electrical signal into a sound signal. The electronic device 100 can listen to music or listen to a hands-free call through the speaker 170A. A plurality of speakers 170A can be provided in the electronic device 100. For example, a speaker 170A can be provided on the top of the electronic device 100, and a speaker 170A can also be provided on the bottom, and so on.

[0088] The receiver 170B, also called a "receiver", is used to convert audio electrical signals into sound signals. When the electronic device 100 receives a call or voice message, the receiver 170B can be placed close to the human ear to receive the voice. In some embodiments, the speaker 170A and the receiver 170B can also be set as one component, which is not limited in the present application.

[0089] Microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak by putting their mouth close to microphone 170C to input the sound signal into microphone 170C. The electronic device 100 can be provided with at least one microphone 170C. In other embodiments, the electronic device 100 can be provided with two microphones 170C, which can not only collect sound signals but also realize noise reduction function. In other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify the sound source, realize directional recording function, etc.

[0090] The earphone interface 170D is used to connect a wired earphone and can be a USB interface 130 or a 3.5 mm open mobile terminal platform (OMTP) standard interface or a cellular telecommunications industry association of the USA (CTIA) standard interface.

[0091] The pressure sensor 180A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A can be set on the display screen 194. There are many types of pressure sensors 180A, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc. The capacitive pressure sensor can be a parallel plate including at least two conductive materials. When a force acts on the pressure sensor 180A, the capacitance between the electrodes changes. The electronic device 100 determines the intensity of the pressure according to the change in capacitance. When a touch operation acts on the display screen 194, the electronic device 100 detects the touch operation intensity according to the pressure sensor 180A. The electronic device 100 can also calculate the touch position according to the detection signal of the pressure sensor 180A. In some embodiments, touch operations acting on the same touch position but with different touch operation intensities can correspond to different operation instructions. For example: when a touch operation with a touch operation intensity less than the first pressure threshold acts on the short message application icon, an instruction to view the short message is executed. When a touch operation with a touch operation intensity greater than or equal to the first pressure threshold acts on the short message application icon, an instruction to create a new short message is executed.

[0092] The gyro sensor 180B can be used to determine the motion posture of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 around three axes (i.e., x, y, and z axes) can be determined by the gyro sensor 180B. The gyro sensor 180B can be used for anti-shake shooting. For example, when the shutter is pressed, the gyro sensor 180B detects the angle of the electronic device 100 shaking, calculates the distance that the lens module needs to compensate based on the angle, and allows the lens to offset the shaking of the electronic device 100 through reverse movement to achieve anti-shake. The gyro sensor 180B can also be used for navigation and somatosensory game scenes.

[0093] The air pressure sensor 180C is used to measure air pressure. In some embodiments, the electronic device 100 calculates the altitude through the air pressure value measured by the air pressure sensor 180C to assist positioning and navigation.

[0094] The magnetic sensor 180D includes a Hall sensor. The electronic device 100 can use the magnetic sensor 180D to detect the opening and closing of the flip leather case. In some embodiments, when the electronic device 100 is a flip phone, the electronic device 100 can detect the opening and closing of the flip cover according to the magnetic sensor 180D. Then, according to the detected opening and closing state of the leather case or the opening and closing state of the flip cover, the flip cover can be automatically unlocked.

[0095] The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in all directions (generally three axes). When the electronic device 100 is stationary, the magnitude and direction of gravity can be detected. It can also be used to identify the posture of the electronic device and is applied to applications such as horizontal and vertical screen switching and pedometers.

[0096] The distance sensor 180F is used to measure the distance. The electronic device 100 can measure the distance by infrared or laser. In some embodiments, when shooting a scene, the electronic device 100 can use the distance sensor 180F to measure the distance to achieve fast focusing.

[0097] The proximity light sensor 180G may include, for example, a light emitting diode (LED) and a light detector, such as a photodiode. The light emitting diode may be an infrared light emitting diode. The electronic device 100 emits infrared light outward through the light emitting diode. The electronic device 100 uses a photodiode to detect infrared reflected light from nearby objects. When sufficient reflected light is detected, it can be determined that there is an object near the electronic device 100. When insufficient reflected light is detected, the electronic device 100 can determine that there is no object near the electronic device 100. The electronic device 100 can use the proximity light sensor 180G to detect that the user holds the electronic device 100 close to the ear to talk, so as to automatically turn off the screen to save power. The proximity light sensor 180G can also be used in leather case mode and pocket mode to automatically unlock and lock the screen.

[0098] The ambient light sensor 180L is used to sense the ambient light brightness. The electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the perceived ambient light brightness. The ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures. The ambient light sensor 180L can also cooperate with the proximity light sensor 180G to detect whether the electronic device 100 is in a pocket to prevent accidental touches.

[0099] The fingerprint sensor 180H is used to collect fingerprints. The electronic device 100 can use the collected fingerprint characteristics to implement fingerprint unlocking, access application locks, fingerprint photography, fingerprint call answering, etc.

[0100] The temperature sensor 180J is used to detect temperature. In some embodiments, the electronic device 100 uses the temperature detected by the temperature sensor 180J to execute a temperature processing strategy. For example, when the temperature reported by the temperature sensor 180J exceeds a threshold, the electronic device 100 reduces the performance of a processor located near the temperature sensor 180J to reduce power consumption and implement thermal protection. In other embodiments, when the temperature is lower than another threshold, the electronic device 100 heats the battery 142 to avoid abnormal shutdown of the electronic device 100 due to low temperature. In other embodiments, when the temperature is lower than another threshold, the electronic device 100 performs a boost on the output voltage of the battery 142 to avoid abnormal shutdown caused by low temperature.

[0101] The touch sensor 180K is also called a "touch control device". The touch sensor 180K can be set on the display screen 194. The touch sensor 180K and the display screen 194 form a touch screen, also called a "touch control screen". The touch sensor 180K is used to detect touch operations acting on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor 180K can also be set on the surface of the electronic device 100, which is different from the position of the display screen 194.

[0102] The bone conduction sensor 180M can obtain a vibration signal. In some embodiments, the bone conduction sensor 180M can obtain a vibration signal of a vibrating bone block of the vocal part of the human body. The bone conduction sensor 180M can also contact the human pulse to receive a blood pressure beat signal. In some embodiments, the bone conduction sensor 180M can also be set in an earphone and combined into a bone conduction earphone. The audio module 170 can parse out a voice signal based on the vibration signal of the vibrating bone block of the vocal part obtained by the bone conduction sensor 180M to realize a voice function. The application processor can parse the heart rate information based on the blood pressure beat signal obtained by the bone conduction sensor 180M to realize a heart rate detection function.

[0103] The key 190 includes a power key, a volume key, etc. The key 190 may be a mechanical key or a touch key. 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.

[0104] Motor 191 can generate vibration prompts. Motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, audio playback, etc.) can correspond to different vibration feedback effects. For touch operations acting on different areas of the display screen 194, motor 191 can also correspond to different vibration feedback effects. Different application scenarios (for example: time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.

[0105] Indicator 192 may be an indicator light, which may be used to indicate charging status, power changes, messages, missed calls, notifications, etc.

[0106] The SIM card interface 195 is used to connect a SIM card. The SIM card can be connected to and separated from the electronic device 100 by inserting it into the SIM card interface 195 or pulling it out from the SIM card interface 195. The electronic device 100 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, and the like. Multiple cards can be inserted into the same SIM card interface 195 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 can also be compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to implement functions such as calls and data communications. In some embodiments, the electronic device 100 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.

[0107] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. In the embodiment of the present invention, the Android system of the layered architecture is taken as an example to exemplify the software structure of the electronic device 100.

[0108] Figure 3 It is a software structure block diagram of the electronic device 100 according to an embodiment of the present application.

[0109] The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: the application layer, the application framework layer, the Android runtime and system library, and the kernel layer.

[0110] The application layer can include a series of application packages.

[0111] like Figure 3 As shown, the application package may include games, cameras, galleries, calendars, calls, maps, navigation, WLAN, Bluetooth, music, videos, short messages and other applications.

[0112] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.

[0113] like Figure 3 As shown, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, a system resource pressure monitoring module, and the like.

[0114] In the embodiment of the present application, the system resource pressure monitoring module can be used to monitor the pressure of system resources. Specifically, the system resource pressure monitoring module can monitor the memory pressure of the system through a memory pressure monitoring module set in the kernel layer to determine the load state of the electronic device.

[0115] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.

[0116] Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.

[0117] The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.

[0118] The phone manager is used to provide communication functions of the electronic device 100, such as management of call status (including connecting, hanging up, etc.).

[0119] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.

[0120] The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications of applications running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is displayed in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.

[0121] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.

[0122] The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.

[0123] 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.

[0124] The system library may include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.

[0125] The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.

[0126] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.

[0127] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.

[0128] A 2D graphics engine is a drawing engine for 2D drawings.

[0129] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, and sensor driver.

[0130] like Figure 4As shown, in the embodiment of the present application, the kernel layer also includes a memory lock, a pressure monitoring module, a process structure, a shares value modification node and a scheduling module. Among them, the memory lock can only be held by one process at the same time. When a process obtains the memory lock, it can safely access shared resources, and other processes need to wait for the release of the memory lock. The pressure monitoring module can be used to monitor the memory pressure of the electronic device. Under different memory pressures, the shares value modification node can be used to modify or maintain the shares value of the top-app process group. The process structure can include information about each process in progress. For example, if the shares value of the top-app process group is modified to a first value, the shares value corresponding to each process in the top-app process group is correspondingly updated to the first value. The scheduling module can be used to manage processor resources, allocate processor resources to each process, and determine the next process to run during scheduling. In the embodiment of the present application, the scheduling queue can obtain the lock mark and shares value of each process in the scheduling queue from the process structure. If the scheduling queue includes a process that holds a memory lock and belongs to the top-app process group, the scheduling module will prioritize the scheduling of the process.

[0131] The following takes the electronic device as a mobile phone, which can include a configuration memory lock, a pressure monitoring module, a process structure, a shares value modification node and a scheduling module as an example. Figure 4 and attached Figure 5 , the process scheduling method provided in the embodiment of the present application is described in detail. Figure 5 A schematic diagram of a process scheduling method provided in an embodiment of the present application. Figure 5 As shown, the process scheduling method may include the following steps S201 to S204.

[0132] S201, when the memory pressure value of the electronic device is greater than the pressure threshold, obtaining the scheduling weight value of each process in the scheduling queue.

[0133] Taking the video application currently running in the electronic device as an example, the video application includes a vip process group and a top-app process group. The embodiment of the present application mainly performs scheduling optimization on the target process group (such as the top-app process group) that causes the process of the vip process group to be blocked, so as to reduce the probability of blocking the process of the vip process group. Therefore, firstly, the scheduling module must be able to identify the process group to which each process in the scheduling queue belongs, so as to determine whether the scheduling queue includes the process belonging to the target process group.

[0134] In some embodiments, Figure 6 As shown, the method in which the scheduling module determines the process group to which each process in the scheduling queue belongs can be implemented by following the steps S2011 to S2015.

[0135] S2011, the pressure monitoring module monitors the memory pressure value of the electronic device.

[0136] In the embodiment of the present application, a pressure monitoring module may be provided in the kernel layer of the electronic device, so that the pressure monitoring module may poll and read the memory pressure value of the electronic device.

[0137] S2012, the pressure monitoring module determines whether the memory pressure value is greater than the pressure threshold.

[0138] S2013: When the memory pressure value is greater than the pressure threshold, the shares value of the target process group is determined as a first value.

[0139] S2014: When the memory pressure value is less than or equal to the pressure threshold, the shares value of the target process group is set to a second value; wherein the first value is different from the second value.

[0140] If the memory pressure value of the electronic device is greater than the pressure threshold, it indicates that the electronic device is in a high-load state. If the memory pressure value of the electronic device is less than or equal to the pressure threshold, it indicates that the electronic device is in a low-load state. In the embodiment of the present application, when the electronic device is in a high-load state, the process optimization scheme for the target process group is executed. When the electronic device is in a low-load state, the process optimization scheme for the target process group may not be executed.

[0141] Control group (Cgroup) is a mechanism used in Linux operating systems to limit, control, and isolate process groups. It allows system administrators to allocate resources to process groups and monitor and limit their resource usage. The shares value is the scheduling weight value assigned by Cgroup to each process group. In the scheduling algorithm, the scheduler will allocate CPU time to each process based on the shares value. Processes with higher shares values ​​will get more CPU time slices, that is, they will be allocated more running time.

[0142] Among them, in terminal systems, by default, the shares value of each process group is the same, and the general default value is 1024.

[0143] Thus, in the embodiment of the present application, by modifying the shares value of the target process group, the modified shares value is different from the default value, and the shares values ​​of other process groups are kept unchanged. Thus, the scheduling module can distinguish the target process group from other process groups by the shares value.

[0144] For example, taking the target process group as the top-app process group, when the memory pressure value is greater than the pressure threshold, the shares value of the top-app process group can be determined as the first value. When the memory pressure value is less than or equal to the pressure threshold, the shares value of the top-app process group is set to the second value. In this way, the scheduling module can distinguish the top-app process group from other process groups by the shares value.

[0145] In an embodiment of the present application, the pressure monitoring module can poll and monitor the memory pressure value of the electronic device. For example, the pressure monitoring module can poll the memory pressure node / proc / pressure / memory under the proc file system to perform memory pressure sampling. In this way, when the memory pressure value of the current polling cycle is greater than the pressure threshold, and the memory pressure value of the previous polling cycle is also greater than the pressure threshold, the shares value of the target process group is maintained as the first value, and the shares value of other process groups is maintained as the second value. When the memory pressure value of the current polling cycle is greater than the pressure threshold, and the memory pressure value of the previous polling cycle is less than or equal to the pressure threshold, the shares value of the target process group is modified from the second value to the first value, and the shares value of other process groups is maintained as the second value. Taking the target process group as the top-app process group as an example, the pressure monitoring module can modify the value of the shares value modification node / dev / cpuctl / top-app / cpu.shares.

[0146] Similarly, when the memory pressure value of the current polling cycle is less than or equal to the pressure threshold, and the memory pressure value of the previous polling cycle is also less than or equal to the pressure threshold, the shares value of the target process group and the shares value of other process groups are maintained at the second value. When the memory pressure value of the current polling cycle is less than or equal to the pressure threshold, and the memory pressure value of the previous polling cycle is greater than the pressure threshold, the shares value of the target process group is modified from the first value to the second value, and the shares value of other process groups is maintained at the second value.

[0147] It can be seen that the embodiment of the present application always keeps the shares value of other process groups except the target process group unchanged, and modifies the shares value of the target process group accordingly according to the memory pressure of the electronic device.

[0148] It should be noted that, in the embodiment of the present application, the main function of modifying the shares value of the target process group is to distinguish the target process group from other process groups. Therefore, the modified first value is based on not affecting the competition for CPU resources among the processes and the performance of the processes.

[0149] The running time of each process on the CPU satisfies the following relation (1):

[0150] Process running time = scheduling period × process shares value / sum of all process shares values ​​(1)

[0151] Among them, the scheduling period is a constant.

[0152] It can be seen that the running time of a process is related to the shares value of the process. Therefore, in order to avoid affecting the running time of the process, the smaller the modification of the shares value is, the better. Based on this consideration, the modification range of the shares value can be set, that is, the absolute value of the difference between the first value and the second value is set to be less than the preset value. For example, the preset value is 1. In this way, the first value can be 1023 or 1025, and the second value can be the default value 1024.

[0153] S2015, the scheduling module obtains the shares value of each process in the scheduling queue.

[0154] In the embodiment of the present application, the scheduling queue refers to a queue of processes in an executable state, and each process in the scheduling queue queues and waits for the scheduling module to allocate processor resources to run on the processor. The scheduling queue may include M processes in an executable state, where M is a positive integer greater than or equal to 1. The process groups to which the M processes belong may be different. For example, the scheduling queue may include processes of the top-app process group, processes of the vip process group, and the like.

[0155] In the embodiment of the present application, each process group may include one or more processes, and the shares value of each process in the same process group is the same. For example, when the shares value of the top-app process group is the first value, the shares value of each process in the top-app process group is the first value. For another example, when the shares value of the top-app process group is the second value, the shares value of each process in the top-app process group is the second value. The shares value of the vip process group is always the second value, and the shares value of each process in the corresponding vip process group is also always the second value.

[0156] In this way, the scheduling module can obtain the shares value of each process in the scheduling queue, and based on the shares value of each process in the scheduling queue, determine whether the scheduling queue includes the process in the target process group. Specifically, the process group described by the process whose shares value is the first value is the top-app process group, and the process group described by the process whose shares value is the second value is not the top-app process group.

[0157] In one implementation, the process structure includes a structure pointer, which is used to indicate the process group corresponding to the process, and each process group corresponds to a shares value. In this way, the scheduling module can determine the shares value corresponding to each process based on the structure pointer corresponding to each process in the scheduling queue.

[0158] The embodiment of the present application mainly optimizes the scheduling of the target process group (such as the top-app process group) that causes the main process of the application to be blocked, so as to reduce the probability of blocking the main process of the application. Therefore, in the embodiment of the present application, the scheduling module can separate the target process group from other process groups without identifying which process group the other processes specifically belong to.

[0159] Specifically, the scheduling module may determine that the process group to which the process whose shares value is the first value belongs is the target process group, and the process group to which the process whose shares value is the second value belongs is the non-target process group. The non-target process group refers to any process group other than the target process group. The non-target process group may include one or more process groups.

[0160] The above-mentioned method of dynamically adjusting the shares value of the target process group based on the memory pressure value of the electronic device, on the one hand, the scheduling module can identify the process of the target process group based on the shares value of each process. On the other hand, the scheduling module can also determine whether the electronic device is in a high-load state through the shares value. For example, if the scheduling queue includes a process whose shares value is a first value, it indicates that the electronic device is in a high-load state; if the scheduling queue does not include a process whose shares value is the first value, it indicates that the electronic device is in a low-load state. In addition, since the parameters of the shares value are the same in different electronic devices, the embodiment of the present application can be compatible with different electronic devices by adjusting the shares value of the target process group to distinguish the target process group from other process groups, which is more conducive to code maintenance.

[0161] In other embodiments, the method for the scheduling module to determine the process group to which each process in the scheduling queue belongs can also be implemented in the following manner: the pressure monitoring module monitors the memory pressure value of the electronic device and determines whether the memory pressure value is greater than the pressure threshold. When the memory pressure value is greater than the pressure threshold, the scheduling module first obtains the process ID of each process in the scheduling queue. Then, the scheduling module determines the process group to which each process belongs based on the process ID of each process.

[0162] In the embodiment of the present application, Cgroup can configure a unique identification process group ID for each process group to characterize each process group. In this way, each process in the process group can carry the process group ID to which it belongs to indicate the process group to which the process belongs. In other words, the process group and the process group ID are in a one-to-one correspondence. In this way, the scheduling module can obtain the ID of each process in the scheduling queue, and determine the process group to which each process belongs based on the correspondence between the ID and the process group.

[0163] S202, determining the lock status of M processes in the scheduling queue.

[0164] The locking state of a process includes two states: holding a memory lock and releasing a memory lock.

[0165] In some embodiments, in order to facilitate the scheduling module to determine the locking state of the process, a locking mark can be added to the structure of the process, and the locking state of the process is represented by the locking mark. Correspondingly, when the process holds a memory lock, the locking mark of the process is set to a first mark, and the first mark is used to represent that the locking state of the process is holding the memory lock. When the process has released the memory lock, the locking mark of the process is set to a second mark, and the second mark is used to represent that the locking state of the process is releasing the memory lock. The first mark and the second mark are different marks, so that the scheduling module can identify the locking state of the process through the first mark and the second mark.

[0166] Correspondingly, the scheduling module can obtain the lock mark of each process in the scheduling queue, and if the lock mark of the process is the first mark, the scheduling module determines that the lock state of the process is holding the memory lock. If the lock mark of the process is the second mark, the scheduling module determines that the lock state of the process is releasing the memory lock.

[0167] Exemplarily, a lock flag field, such as in_mmap_lock, may be added to the structure of each process. Thus, when a process holds a memory lock, the value of the lock flag in_mmap_lock of the current process is set to 1 in the lock interface. After the process accesses the memory area, the value of the lock flag in_mmap_lock of the current process is set to 0 in the native interface for releasing the lock. Thus, the scheduling module can identify whether each process in the scheduling queue holds a memory lock by setting the lock flag of each process to 0 or 1.

[0168] It should be noted that the above embodiment is only exemplified by using the lock flag as 0 or 1, and does not limit the lock flag. For example, when the process holds a memory lock, the value of the lock flag of the process can be set to a third value. When the process has released the memory lock, the value of the lock flag of the process can be set to a fourth value, where the fourth value is different from the third value.

[0169] S203: When the target process is included in the scheduling queue, set the virtual runtime vruntime of the target process to a first time value.

[0170] The target process is a process in the scheduling queue whose scheduling weight value is the first value and whose lock state is holding a memory lock. In other words, the target process is a process in the scheduling queue that holds a memory lock and belongs to the top-app process group.

[0171] Virtual runtime (vruntime) is a parameter used in the fair scheduling algorithm to measure the running time of a process. vruntime is a relative time concept, indicating the time that a process has been running on the CPU. The smaller the value of vruntime, the shorter the time that the process has been running on the CPU.

[0172] The fair scheduling algorithm adjusts according to the vruntime value of the process, so that each process has the opportunity to obtain a fair CPU time slice. When a process obtains CPU execution, its vruntime value will gradually increase, indicating that it has consumed a certain amount of execution time. Processes with smaller vruntime values ​​are more likely to be selected to run in the next scheduling to balance the execution time among various processes. This mechanism helps to ensure fairness among different processes and avoid situations where some processes occupy the CPU for a long time and other processes cannot be executed.

[0173] That is to say, the fair scheduling algorithm selects the next process to run by constantly comparing the vruntime of each process. Each time it schedules, the fair scheduling algorithm selects the process with the smallest vruntime value to obtain the CPU time slice to run. This method ensures fair distribution of running time for all processes.

[0174] In the embodiment of the present application, when it is determined that the target process is included in the scheduling queue, the scheduling module can set the vruntime value of the target process so that the set vruntime is the minimum value of the vruntime of all processes in the scheduling queue. In this way, when the scheduling module schedules, the fair scheduling algorithm in the scheduling module will select the target process with the minimum vruntime value to obtain the CPU time slice operation, that is, select the target process as the next process to be run. In this way, the target process releases the memory lock as soon as possible, reducing the probability of other processes being blocked due to the inability to hold the lock.

[0175] In some embodiments, setting the virtual runtime vruntime of the target process to the first time value can be implemented in the following manner: the scheduling module can calculate the vruntime value of each process in the scheduling queue. Then, the scheduling module calculates the minimum value of the vruntime of all processes. If the vruntime of the target process is the minimum value of the vruntime of all processes, the vruntime of the target process is maintained. If the vruntime of the target process is not the minimum value of the vruntime of all processes, the scheduling module modifies the vruntime of the target process to a value less than the minimum value of the vruntime of all processes, so that the modified vruntime of the target process is the minimum value of the vruntime of all processes in the scheduling queue.

[0176] For example, the scheduling queue includes five processes, and the vruntimes corresponding to the five processes are T1, T2, T3, T4, and T5, respectively, where T1>T2>T3>T4>T5. Assuming that the vruntime corresponding to the target process is T3, the vruntime corresponding to the target process is modified to T3' before scheduling, where T1>T2>T4>T5>T3'.

[0177] In other embodiments, setting the virtual runtime vruntime of the target process to the first time value may be implemented in the following manner: the scheduling module may calculate the vruntime value of each process in the scheduling queue, and then the scheduling module subtracts the rotation period from the calculated vruntime value of the target process, so that the modified vruntime of the target process is the difference between the vruntime of the target process before modification (i.e., the second time value) and the rotation period.

[0178] The round-robin period is the time required for all tasks in the runnable state in the fair scheduling algorithm to run one round. Therefore, subtracting the round-robin period from the calculated vruntime value of the target process is equivalent to the scheduling module reducing the target process by one round-robin period. In this way, the modified vruntime value must be the minimum value of the vruntime of all processes in the scheduling queue.

[0179] This implementation method, on the one hand, does not need to calculate the minimum value of vruntime of all processes to reduce the amount of calculation. On the other hand, it does not need to introduce other parameters in the fair scheduling algorithm. The original rotation cycle parameters can be directly called and the vruntime of the target process can be modified based on the rotation cycle.

[0180] In the fair scheduling algorithm, the red-black tree can be used to store the information of the process to be run, including the vruntime value of the process and other scheduling-related attribute information. By using the red-black tree as a data structure, the fair scheduling algorithm can efficiently find and select the next process that should be run, so that the scheduling module can achieve fair and efficient process scheduling.

[0181] The red-black tree includes multiple nodes, each node represents a process, and the value of the node can represent the vruntime value of the process, so that the red-black tree can be sorted and managed according to the vruntime value of the process. In the red-black tree, the leftmost node always represents the process with the smallest vruntime.

[0182] Step 204, scheduling each process in the scheduling queue based on the size of the vruntime of each process in the scheduling queue.

[0183] When the scheduling module schedules, the fair scheduling algorithm in the scheduling module will select the target process with the smallest vruntime value to obtain the CPU time slice to run, that is, select the target process as the next process to run. In this way, the target process releases the memory lock as soon as possible, reducing the probability of other processes being blocked due to being unable to hold the lock.

[0184] After the vruntime of the target process is modified in the embodiment of the present application, the modified vruntime can be interpolated to the leftmost node of the red-black tree. In this way, the scheduling module can prioritize the target process based on the principle of prioritizing the process corresponding to the leftmost node in the red-black tree.

[0185] In the embodiment of the present application, each time the vruntime of the target process is modified, the operation of making the scheduling module prioritize the target process only acts on the current scheduling adjustment strategy and does not affect the scheduling strategy at other times. In this way, by modifying the vruntime value, the scheduling module prioritizes the target process, which will not cause other negative effects on the overall scheduling strategy of the scheduling module, ensuring the stable operation of the system.

[0186] It should be noted that if the main process of the currently running application is a process that will not be perceived by the user, the process of the target process group can be scheduled and optimized, that is, the execution of the above steps S201 to S204 is not triggered. If the main process of the currently running application is a process that will be perceived by the user (for example, when the foreground application includes a drawing process and a rendering process), the process of the target process group can be scheduled and optimized, that is, the execution of the above steps S201 to S204 is triggered.

[0187] Exemplarily, the current application scenario of the electronic device is first determined, and steps S201 to S204 are triggered only when the current application scenario is at least one of a cold start scenario, a hot start scenario, and an in-application sliding scenario, and the memory pressure value of the electronic device is greater than the pressure threshold. Otherwise, the above steps S201 to S204 are not triggered.

[0188] Among them, cold start means that when the application is started, there is no background process of the application. At this time, the system will recreate a new process and assign it to the application. This startup method is called cold start. During cold start, the application process usually needs to load and initialize various resources, including files, databases, network connections, etc.

[0189] Hot start means that when you start an application, there is already a process of the application in the background (for example, when you press the home button to return to the desktop, the process of the application will still remain in the background and can be viewed in the task list). Therefore, in the case of an existing process, this startup will start the application from the existing process. This startup method is called hot start. During hot start, the application process is already running, but some resources may need to be reloaded or specific operations may need to be performed.

[0190] The in-app sliding scenario refers to the scenario where sliding operations are performed on the app interface, such as pull-down refresh, scrolling lists, page switching, etc. The in-app sliding scenario may involve reading or displaying data.

[0191] It can be seen that, generally, cold start, hot start and in-app sliding scenarios all include drawing process and rendering process. The response of the electronic device to cold start, hot start and in-app sliding scenarios can be perceived by the user. If the response time of cold start, hot start and in-app sliding scenarios is long, the user can perceive that the electronic device is stuck.

[0192] In addition, in the cold start, hot start and in-app sliding scenarios, since some resources may need to be loaded or data may be read or updated, the main application process corresponding to the cold start, hot start and in-app sliding scenarios generally needs to access the shared memory resources to perform read and write operations on the shared memory resource area. In this way, the main application process corresponding to the cold start, hot start or in-app sliding scenarios needs to compete with multiple processes for the memory lock of the same shared memory resource.

[0193] That is to say, in the cold start, hot start and in-application sliding scenarios, if the main process of the application is blocked, the user may feel that the electronic device is stuck. And in this scenario, the reason why the main process of the application is blocked is most likely because the lock holding process of the top-app process group holds the memory lock for a long time, causing the main process of the application to be unable to obtain the memory lock and be in a blocked state. Therefore, in the cold start, hot start and in-application sliding scenarios, the progress scheduling method provided by the embodiment of the present application can reduce the probability of the main process of the application being blocked, thereby improving the user experience.

[0194] To facilitate the understanding of the embodiment of the present application, the target process group is taken as the top-app process group as an example. Figure 7 A process scheduling method provided in an embodiment of the present application is exemplarily described. Figure 7 As shown, the method may include the following steps:

[0195] S301, the process of the top-app process group holds the memory lock.

[0196] S302: Set the lock flag of the process holding the memory lock to a first flag.

[0197] S303, the process of the top-app process group releases the memory lock.

[0198] S304: Set the lock flag of the process that has released the memory lock to a second flag.

[0199] In this way, by adding a lock mark in the process structure, each process has a different lock mark according to the different lock states. For example, when a process in the top-app process group holds a memory lock, the lock mark of the process is 1. When a process in the top-app process group releases the memory lock, the lock mark of the process is 0.

[0200] In this way, the scheduling module can obtain the lock holding flag of each process from the process structure, and determine the lock holding state of each process based on the lock holding flag of each process.

[0201] S305: The pressure monitoring module polls and reads the pressure value in the memory of the electronic device.

[0202] S306: The pressure monitoring module determines whether the memory pressure value is greater than a pressure threshold.

[0203] S307: If the memory pressure value is greater than the pressure threshold, the pressure monitoring module determines the shares value of the top-app process group as the first value.

[0204] S308: If the memory pressure value is less than or equal to the pressure threshold, the pressure monitoring module maintains the shares value of the top-app process group as the default value.

[0205] The first value is different from the default value.

[0206] In this way, the shares value of the top-app process group is dynamically adjusted according to the memory pressure status, so that when the memory pressure is high, the shares value of the top-app process group is different from the shares value of other process groups. For example, when the memory pressure is high, the shares value of the top-app process group is 1025, and the shares value of other process groups is 1024.

[0207] In this way, the scheduling module can distinguish the top-app process group from other process groups based on the shares value of the process. In addition, the scheduling module can also determine the current memory pressure state of the electronic device based on the shares value of the process.

[0208] S309, update the shares value of the top-app process group.

[0209] The process structure includes a structure pointer, which is used to indicate the process group corresponding to the process. The process group includes its own corresponding shares value. Therefore, after modifying the shares value of the top-app process group, the shares value corresponding to the structure pointer of the process of the top-app process group in the process structure is updated. In this way, the scheduling module can determine the shares value corresponding to the process through the structure pointer in the process structure.

[0210] S310, the scheduling module obtains the shares value and lock flag of each process in the scheduling queue.

[0211] S311, when the scheduling queue includes a target process whose shares value is a first value and whose lock mark is a first mark, set the vruntime of the target process to a first time value.

[0212] The scheduling module can obtain the shares value and lock mark corresponding to each process through the structure corresponding to each process in the scheduling queue. If the scheduling queue does not include a process with a shares value of the first value, that is, the shares values ​​of each process in the scheduling queue are all default values, it means that the scheduling queue does not include processes in the top-app process group. If the scheduling queue does not include a process with a lock mark of the first mark, it means that the scheduling queue does not include a process with a lock state of holding a memory lock.

[0213] The modified first time value is the minimum value of the vruntime of all processes in the scheduling queue.

[0214] S312, scheduling each process in the scheduling queue based on the size of the vruntime of each process in the scheduling queue.

[0215] In this way, the scheduling optimization solution for the processes of the top-app process group provided by the embodiment of the present application, when a process that holds a memory lock and belongs to the top-app process group is included in the scheduling queue, gives priority to scheduling the process so that the process releases the memory lock as soon as possible, thereby solving the problem that the processes of the vip process group are in a blocked state due to the inability to hold the memory lock for a long time.

[0216] It should be noted that the above embodiment only takes the target process group as the top-app process group, determines the top-app process group based on the shares value, determines the lock state based on the lock mark, and preferentially schedules the processes that meet the conditions by modifying the vruntime as an example for illustrative explanation, and does not represent a limitation on the above specific implementation method. For example, if it is other process groups rather than the top-app process group that cause the vip process group to be blocked, then the target process group can be determined as the other process groups that cause the vip process group to be blocked. For another example, this solution can also determine the top-app process group based on the ID of each process. For details, please refer to the description of step 201, which will not be repeated here.

[0217] The various method embodiments described in this document may be independent solutions or may be combined according to internal logic, and these solutions all fall within the protection scope of this application.

[0218] It can be understood that, in the above-mentioned various method embodiments, the methods and operations implemented by the electronic device can also be implemented by components (such as chips or circuits) that can be used in the electronic device.

[0219] The above embodiments introduce the process scheduling method provided by the present application. It is understandable that, in order to realize the above functions, the electronic device includes a hardware structure and / or software module corresponding to each function. Those skilled in the art should easily realize that, in combination with the units and algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present application.

[0220] Figure 8is a schematic diagram of a process scheduling device provided in an embodiment of the present application. In one embodiment, the electronic device can Figure 8 The software device shown in the figure realizes the corresponding functions. Figure 8 As shown, the process scheduling device 400 may include: an acquisition module 401 , a lock state determination module 402 , a vruntime setting module 403 and a scheduling module 404 .

[0221] The acquisition module 401 is used to acquire the scheduling weight value of each process in the scheduling queue when the memory pressure value of the electronic device is greater than the pressure threshold; the scheduling queue includes M processes in an executable state, where M is a positive integer greater than or equal to 1;

[0222] A lock status determination module 402, used to determine the lock status of the M processes;

[0223] The vruntime setting module 403 is used to set the virtual runtime vruntime of the target process to a first time value when the target process is included in the scheduling queue; wherein the target process is a process in the scheduling queue whose scheduling weight value is a first value and whose lock state is a process holding a memory lock; the scheduling weight values ​​corresponding to other processes in the foreground application of the electronic device except the drawing process and the rendering process are a first value, and the scheduling weight values ​​corresponding to the drawing process and the rendering process in the foreground application are a second value, and the first value and the second value are different; the first time value is the minimum value of the vruntime of all processes in the scheduling queue;

[0224] The scheduling module 404 is used to schedule each process in the scheduling queue based on the size of the vruntime of each process in the scheduling queue.

[0225] In an implementable manner, the process scheduling device 400 further includes a memory pressure monitoring module. The memory pressure monitoring module is used to monitor the memory pressure value of the electronic device; when the memory pressure value is greater than the pressure threshold, the scheduling weight value of the target process group is determined to be a first value; when the memory pressure value is less than or equal to the pressure threshold, the scheduling weight value of the target process group is determined to be a second value; wherein the first value is different from the second value.

[0226] In one achievable manner, the second value is a default value of the scheduling weight value of the target process group, and an absolute value of a difference between the first value and the second value is less than a preset value.

[0227] In one implementable manner, the first numerical value is 1023 or 1025, and the default value is 1024.

[0228] In one implementable manner, the acquisition module 401 is specifically used to obtain the scheduling weight value of each process in the scheduling queue when the memory pressure value of the electronic device is greater than the pressure threshold and the foreground application of the electronic device includes a drawing process and a rendering process.

[0229] In one implementable manner, the vruntime setting module 403 is specifically used to determine the virtual runtime vruntime of the target process when the target process is included in the scheduling queue; and to set the virtual runtime vruntime of the target process to a first time value when the virtual runtime vruntime of the target process is not the minimum value of the vruntime of all processes in the scheduling queue.

[0230] In one achievable manner, the first time value is the difference between the second time value and the rotation period, the second time value is the vruntime of the target process before modification, and the rotation period is the time required for all processes in the scheduling queue to run one round.

[0231] In one achievable embodiment, the process scheduling device 400 also includes a lock marking device module, which is used to set the lock marking of the process to a first mark when the process holds a memory lock, and the first mark is used to indicate that the lock state of the process is holding a memory lock; when the process has released the memory lock, the lock marking of the process is set to a second mark, and the second mark is used to indicate that the lock state of the process is releasing the memory lock.

[0232] In one implementable manner, the lock status determination module 402 is specifically used to obtain the lock tags of the M processes; determine that the lock status of the process whose lock tag is a first tag is holding a memory lock; and determine that the lock status of the process whose lock tag is a second tag is releasing a memory lock.

[0233] That is, the device 400 can realize the corresponding Figures 1 to 7 The steps or processes performed by the method embodiment shown in the figure may include a device for performing Figures 1 to 7 The modules of the method executed in the method embodiment shown. It should be understood that the specific process of each module executing the above corresponding steps has been described in detail in the above method embodiment, and for the sake of brevity, it will not be repeated here.

[0234] In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in a processor or an instruction in the form of software. The steps of the method disclosed in conjunction with the embodiment of the present application can be directly embodied as a hardware processor for execution, or a combination of hardware and software modules in a processor for execution. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in a memory, and the processor reads the information in the memory and completes the steps of the above method in conjunction with its hardware. To avoid repetition, it is not described in detail here.

[0235] It should be noted that the processor in the embodiment of the present application can be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method embodiment can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to perform, or the hardware and software modules in the decoding processor can be combined and performed. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in a memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.

[0236] It can be understood that the memory in the embodiments of the present application can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), and direct RAM (DR RAM). It should be noted that the memory of the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.

[0237] According to the method provided in the embodiments of the present application, the embodiments of the present application also provide a computer program product, which includes: a computer program or instructions, when the computer program or instructions are run on a computer, the computer executes the method of any one of the embodiments of the method.

[0238] According to the method provided by the embodiments of the present application, the embodiments of the present application also provide a computer storage medium, which stores a computer program or instructions. When the computer program or instructions are run on a computer, the computer executes the method of any one of the embodiments of the method.

[0239] According to the method provided by an embodiment of the present application, an embodiment of the present application also provides an electronic device, including a memory and a processor; the memory and the processor are coupled; the memory is used to store computer program code, and the computer program code includes computer instructions. When the processor executes the computer instructions, the electronic device executes the method of any one of the embodiments of the method embodiment.

[0240] Those of ordinary skill in the art will appreciate that the various illustrative logical blocks and steps described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or in a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0241] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0242] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0243] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0244] In addition, each functional module in each embodiment of the present application may be integrated into one processing unit, or each module may exist physically separately, or two or more modules may be integrated into one unit.

[0245] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage media include: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROM), random access memories (RAM), magnetic disks or optical disks.

[0246] The devices, computer storage media, computer program products, and electronic devices provided in the above-mentioned embodiments of the present application are all used to execute the methods provided above. Therefore, the beneficial effects that can be achieved can refer to the corresponding beneficial effects of the methods provided above, and will not be repeated here.

[0247] It should be understood that in each embodiment of the present application, the execution order of each step should be determined by its function and internal logic, and the size of the sequence number of each step does not mean the order of execution and does not limit the implementation process of the embodiment.

[0248] Each part of this specification is described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the embodiments of the device, computer storage medium, computer program product, and electronic device, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the description in the method embodiments.

[0249] Although the preferred embodiments of the present application have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.

[0250] The above-described embodiments of the present application do not constitute a limitation on the protection scope of the present application.

Claims

1. A process scheduling method, characterized in that: The method is applied to an electronic device, and the method comprises: When the memory pressure value of the electronic device is greater than the pressure threshold, obtaining the scheduling weight value of each process in the scheduling queue; the scheduling queue includes M processes in an executable state, where M is a positive integer greater than or equal to 1; Determine the lock status of the M processes in the scheduling queue; In the case where the target process is included in the scheduling queue, the virtual runtime vruntime of the target process is set to a first time value; wherein the target process is a process in the scheduling queue whose scheduling weight value is a first value and whose lock state is a process holding a memory lock; the scheduling weight values ​​corresponding to other processes in the foreground application of the electronic device except the drawing process and the rendering process are a first value, and the scheduling weight values ​​corresponding to the drawing process and the rendering process in the foreground application are a second value, and the first value and the second value are different; the first time value is the minimum value of the vruntime of all processes in the scheduling queue; Scheduling each process in the scheduling queue based on the size of the vruntime of each process in the scheduling queue; Wherein, when the memory pressure value of the electronic device is greater than the pressure threshold, obtaining the scheduling weight value of each process in the scheduling queue includes: When the memory pressure value of the electronic device is greater than the pressure threshold and the foreground application of the electronic device includes a drawing process and a rendering process, the scheduling weight value of each process in the scheduling queue is obtained.

2. The method according to claim 1, characterized in that The method further comprises: Monitoring a memory pressure value of the electronic device; When the memory pressure value is greater than the pressure threshold, the scheduling weight value of the target process group is determined to be the first value; the target process group includes other processes in the foreground application except the drawing process and the rendering process; When the memory pressure value is less than or equal to the pressure threshold, the scheduling weight value of the target process group is determined to be the second value; wherein the first value is different from the second value.

3. The method according to claim 2, characterized in that The second value is a default value of the scheduling weight value of the target process group, and an absolute value of a difference between the first value and the second value is less than a preset value.

4. The method according to claim 3, characterized in that The first value is 1023 or 1025, and the default value is 1024.

5. The method according to claim 1, characterized in that Before setting the vruntime of the target process to the first time value, the step further includes: In the case where the target process is included in the scheduling queue, determining the vruntime of the target process; When the vruntime of the target process is not the minimum value of the vruntime of all processes in the scheduling queue, the virtual runtime vruntime of the target process is set to a first time value.

6. The method according to claim 1, characterized in that The first time value is the difference between the second time value and the rotation period, the second time value is the vruntime of the target process before modification, and the rotation period is the time required for all processes in the scheduling queue to run one round.

7. The method according to claim 1, characterized in that The method further comprises: In the case where the process holds a memory lock, setting a lock flag of the process to a first flag, where the first flag is used to indicate that the lock state of the process is holding a memory lock; In the case that the process has released the memory lock, the lock flag of the process is set to a second flag, where the second flag is used to indicate that the lock state of the process is to release the memory lock.

8. The method according to claim 7, characterized in that Determining the lock status of the M processes includes: Obtain the lock marks of the M processes; Determine that the lock state of the process whose lock mark is the first mark is holding a memory lock; Determine that the locking state of the process whose locking mark is the second mark is releasing the memory lock.

9. A process scheduling device, characterized in that: The device comprises: An acquisition module, used for acquiring a scheduling weight value of each process in a scheduling queue when a memory pressure value of the electronic device is greater than a pressure threshold; the scheduling queue includes M processes in an executable state, where M is a positive integer greater than or equal to 1; A lock status determination module, used to determine the lock status of the M processes; A vruntime setting module is used to set the virtual runtime vruntime of the target process to a first time value when the target process is included in the scheduling queue; wherein the target process is a process in the scheduling queue whose scheduling weight value is a first value and whose lock state is a process holding a memory lock; the scheduling weight values ​​corresponding to other processes in the foreground application of the electronic device except the drawing process and the rendering process are a first value, and the scheduling weight values ​​corresponding to the drawing process and the rendering process in the foreground application are a second value, and the first value and the second value are different; the first time value is the minimum value of the vruntime of all processes in the scheduling queue; A scheduling module, used for scheduling each process in the scheduling queue based on the size of the vruntime of each process in the scheduling queue; Wherein, the acquisition module is also used to obtain the scheduling weight value of each process in the scheduling queue when the memory pressure value of the electronic device is greater than the pressure threshold and the foreground application of the electronic device includes a drawing process and a rendering process.

10. An electronic device, characterized in that: It comprises a memory and a processor; the memory and the processor are coupled; the memory is used to store computer program code, the computer program code comprises computer instructions, and when the processor executes the computer instructions, the electronic device executes the method as described in any one of claims 1-8.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program or instruction. When the computer program or instruction is executed on a computer, the computer is enabled to execute the method according to any one of claims 1 to 8.