WO2020063040A1 - 处理器核心配置方法、装置、终端及存储介质 - Google Patents

处理器核心配置方法、装置、终端及存储介质 Download PDF

Info

Publication number
WO2020063040A1
WO2020063040A1 PCT/CN2019/095993 CN2019095993W WO2020063040A1 WO 2020063040 A1 WO2020063040 A1 WO 2020063040A1 CN 2019095993 W CN2019095993 W CN 2019095993W WO 2020063040 A1 WO2020063040 A1 WO 2020063040A1
Authority
WO
WIPO (PCT)
Prior art keywords
target
core
task
performance
operating system
Prior art date
Application number
PCT/CN2019/095993
Other languages
English (en)
French (fr)
Inventor
王猛猛
程杰
陈岩
Original Assignee
Oppo广东移动通信有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Oppo广东移动通信有限公司 filed Critical Oppo广东移动通信有限公司
Publication of WO2020063040A1 publication Critical patent/WO2020063040A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/5038Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the execution order of a plurality of tasks, e.g. taking priority or time dependency constraints into consideration
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/505Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the load
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/48Indexing scheme relating to G06F9/48
    • G06F2209/482Application
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5012Processor sets
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5021Priority
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5022Workload threshold
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the embodiments of the present application relate to the technical field of terminals, and in particular, to a method, a device, a terminal, and a storage medium for configuring a processor core.
  • processors with multiple cores use the Big-Little architecture.
  • the processor adopting the Big-Little architecture includes multiple high-performance cores and multiple low-performance cores. Among them, the high-performance core is used to handle complex operations, and the low-performance core is used to handle simple operations.
  • a related processor core configuration method has not been provided in the related art.
  • the embodiments of the present application provide a processor core configuration method, a device, a terminal, and a storage medium.
  • the technical solution is as follows:
  • a processor core configuration method is provided.
  • the method is applied to a terminal.
  • the terminal runs an operating system and at least one application program.
  • the method includes:
  • the target application sends a target request to the operating system by calling a first application programming interface (API) provided by a Software Development Kit (SDK), and the target request carries the target Task ID of the target task of the application;
  • API application programming interface
  • SDK Software Development Kit
  • the operating system binds the target task and the target core, and sets the target core to an isolated state. In the isolated state, only the target task after binding is allowed to run on the target core. .
  • a processor core configuration device where the device includes a target application program module and an operating system module;
  • the target application program module is configured to send a target request to the operating system module by calling a first API provided by the SDK, where the target request carries a task identifier of a target task of the target application program;
  • the operating system module is configured to determine a target core corresponding to the task identifier
  • the operating system module is further configured to bind the target task and the target core, and set the target core to an isolated state, where the target core is allowed to run only after binding. The stated task.
  • a terminal includes a processor and a memory, and the memory stores at least one instruction, and the instruction is loaded and executed by the processor to implement the present invention. Apply for the processor core configuration method according to any one of the first aspect and its optional embodiments.
  • a computer-readable storage medium stores at least one instruction, and the instruction is loaded and executed by a processor to implement the first aspect of the present application and its implementation.
  • the processor core configuration method according to any one of the optional embodiments.
  • a target application calls a first API interface provided by the SDK, and sends a target request to the operating system.
  • the target request carries a task identifier of a target task of the target application for operation.
  • the system binds the target task and the target core, and sets the target core to an isolated state. Only the bound target task is allowed to run on the target core.
  • the operating system can Adaptively configure the corresponding target core, do not allow other tasks to be scheduled to run on the target core, and only allow bound target tasks to be scheduled to run on the target core, thereby ensuring the execution of target tasks and avoiding related technologies.
  • the target task When the target task is running in the processor core, it may be preempted or interrupted by other tasks, causing the target application to still have the problem of stuttering, which achieves the effect of optimizing the quality of the application program.
  • FIG. 1 is a schematic structural diagram of a terminal provided by an exemplary embodiment of the present application.
  • FIG. 2 is an implementation schematic diagram of a communication process between an application program and an operating system in a terminal
  • FIG. 3 is a schematic structural diagram of a terminal according to an exemplary embodiment of the present application.
  • FIG. 4 and FIG. 5 are schematic diagrams of implementation of a communication process between an application program and an operating system in the terminal shown in FIG. 3;
  • FIG. 6 is a schematic structural diagram of a terminal according to another exemplary embodiment of the present application.
  • FIG. 7 is a flowchart of a processor core configuration method according to an exemplary embodiment of the present application.
  • FIG. 8 is a flowchart of a processor core configuration method according to another exemplary embodiment of the present application.
  • FIG. 9 is a flowchart of a processor core configuration method according to another exemplary embodiment of the present application.
  • FIG. 10 is a flowchart of a processor core configuration method according to another exemplary embodiment of the present application.
  • FIG. 11 is a flowchart of a processor core configuration method according to another exemplary embodiment of the present application.
  • FIG. 12 shows a structural block diagram of a processor core configuration apparatus according to an embodiment of the present application.
  • FIG. 1 is a structural block diagram of a terminal 100 according to an exemplary embodiment of the present application.
  • the terminal 100 may be an electronic device capable of running an application program, such as a smart phone, a tablet computer, or an e-book.
  • the terminal 100 in this application may include one or more of the following components: a processor 110, a memory 120, and an input-output device 130.
  • the processor 110 may include one or more processing cores.
  • the processor 110 uses various interfaces and lines to connect various parts in the entire terminal 100, and executes the terminal by running or executing instructions, programs, code sets or instruction sets stored in the memory 120, and calling data stored in the memory 120. 100 various functions and processing data.
  • the processor 110 may use at least one of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), and Programmable Logic Array (PLA).
  • DSP Digital Signal Processing
  • FPGA Field-Programmable Gate Array
  • PDA Programmable Logic Array
  • the processor 110 may integrate one or a combination of a central processing unit (Central Processing Unit, CPU), an image processor (Graphics Processing Unit, GPU), and a modem.
  • CPU Central Processing Unit
  • GPU Graphics Processing Unit
  • modem modem
  • the CPU mainly handles the operating system, user interface, and application programs; the GPU is responsible for rendering and rendering of the displayed content; the modem is used for wireless communication. It can be understood that the modem may not be integrated into the processor 110, and may be implemented by a single communication chip.
  • the memory 120 may include Random Access Memory (RAM), and may also include Read-Only Memory.
  • the memory 120 includes a non-transitory computer-readable storage medium.
  • the memory 120 may be used to store instructions, programs, codes, code sets, or instruction sets.
  • the memory 120 may include a storage program area and a storage data area, where the storage program area may store instructions for implementing an operating system and instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.) And instructions for implementing the following method embodiments, the operating system may be an Android (Android) system (including a system developed based on the Android system), an IOS system (including a system developed based on the IOS system) ) Or other systems.
  • the storage data area may also store data (such as phonebook, audio and video data, and chat history data) created by the terminal 100 during use.
  • the memory 120 can be divided into operating system space and user space.
  • the operating system runs in the operating system space, and native and third-party applications run in the user space.
  • the operating system allocates corresponding system resources for different third-party applications.
  • the requirements of system resources for different application scenarios in the same third-party application are also different.
  • the third-party application requires higher disk read speed.
  • the animation rendering scenario the third Three-party applications have higher requirements for GPU performance. Since the operating system and third-party applications are independent of each other, the operating system often cannot sense the current application scenario of the third-party application in time, resulting in that the operating system cannot adapt the system resources according to the specific application scenario of the third-party application.
  • the running quality of third-party applications is also related to the real-time operating status of the operating system. If the third-party applications cannot obtain the current operating status of the operating system in a timely manner, their operating quality will also be affected. For example, when the terminal temperature is too high, the third-party application still runs in the first performance mode. If the terminal temperature continues to rise, the system will crash and the third-party application will not run.
  • the memory 120 may store the Linux kernel layer 220, the system runtime layer 240, the application framework layer 260, and the application layer 280.
  • the Linux kernel layer 220, the system runtime layer 240, and the application framework layer 260 belong to the operating system space, and the application layer 280 belongs to the user space.
  • the Linux kernel layer 220 provides low-level drivers for various hardware of the terminal 100, such as a display driver, an audio driver, a camera driver, a Bluetooth driver, a Wi-Fi driver, and power management.
  • the system runtime layer 240 provides main feature support for the Android system through some C / C ++ libraries.
  • the SQLite library provides database support
  • the OpenGL / ES library provides 3D graphics support
  • the Webkit library provides browser kernel support.
  • An Android runtime library (Android Runtime) is also provided in the system runtime layer 240, which mainly provides some core libraries, which can allow developers to use the Java language to write Android applications.
  • the application framework layer 260 provides various APIs that may be used when building applications. Developers can also use these APIs to build their own applications, such as activity management, window management, view management, notification management, content providers, Package management, call management, resource management, positioning management.
  • At least one application program is running in the application layer 280.
  • These applications can be native applications that come with the operating system, such as contact programs, SMS programs, clock programs, camera applications, etc .; or they can be developed by third-party developers. Third-party applications, such as game applications, instant messaging programs, photo beautification programs, shopping programs, and so on.
  • FIG. 4 A feasible communication method between the operating system and third-party applications is shown in Figure 4.
  • the third-party application has an embedded SDK for communicating with the operating system.
  • the SDK contains several abstracted APIs, which are provided by operating system developers to third-party application developers, and the third-party application developers embed the SDK into third-party applications. After such third-party applications are installed and running on the operating system, they can call the API provided by the SDK to communicate with the operating system.
  • the system runtime layer 240 may additionally include an interface communication system 242.
  • the interface communication system 242 can be regarded as a subsystem in the operating system, or as an application program embedded in the operating system.
  • the interface communication system 242 is provided with an SDK interface, and a third-party application program calls the API of the SDK and the SDK interface to perform data communication in a binder (Binder) manner.
  • Binder Binder
  • a third-party application may also use the Socket method to establish a long-term connection with the Socket interface of the interface communication system 242. You can communicate over this long connection.
  • the interface communication system 242 may be provided with different policy modules. After receiving data sent by a third-party application, the interface communication system 242 uses the corresponding policy module of the third-party application to analyze the data. To get the corresponding resource adaptation optimization strategy. Based on the resource adaptation and optimization strategy obtained through analysis, the interface communication system 242 notifies the Linux kernel layer 220 to perform system resource adaptation and optimization through the control interface.
  • the control interface can communicate with the Linux kernel layer 220 in a Sysfs manner.
  • different policy modules in the interface communication system 242 may correspond to different third-party applications (that is, setting policy modules for different applications), or different policy modules correspond to different types of third-party applications (that is, targeting Different types of applications set policy modules), or different policy modules correspond to different system resources (that is, set policy modules for different system resources), or different policy modules correspond to different application scenarios (that is, different application applications Scenario setting strategy module), the embodiment of the present application does not limit the specific setting manner of the strategy module.
  • different policy modules can be set in the third-party application.
  • the third-party application can pass different policy modules.
  • the interface communication system 242 can also communicate with the application framework layer 260 in a Binder manner, and is used to receive the foreground application information sent by the application framework layer 260, so that based on the foreground application information, only for third-party applications running in the foreground System resource optimization.
  • the IOS system includes: a core operating system layer 320 (Core OS layer), a core service layer 340 (Core services layer), and a media layer. 360 (Media layer), 380 (Cocoa Touch Layer).
  • the core operating system layer 320 includes an operating system kernel, drivers, and a low-level program framework. These low-level program frameworks provide functions closer to the hardware for use by the program framework located in the core service layer 340.
  • the core service layer 340 provides system services and / or program frameworks required by applications, such as a Foundation framework, an account framework, an advertising framework, a data storage framework, a network connection framework, a geographic location framework, a motion framework, and so on.
  • the media layer 360 provides audio-visual-related interfaces for applications, such as interfaces related to graphics and images, interfaces related to audio technology, interfaces related to video technology, and wireless playback (AirPlay) interfaces for audio and video transmission technologies.
  • the touchable layer 380 provides various commonly-used interface-related frameworks for application development. The touchable layer 380 is responsible for user touch interaction operations on the terminal 100. For example, a local notification service, a remote push service, an advertising framework, a game tool framework, a message user interface interface (UI) framework, a user interface UIKit framework, a map framework, and so on.
  • UI message user interface interface
  • frameworks related to most applications include, but are not limited to, a basic framework in a core service layer 340 and a UIKit framework in a touchable layer 380.
  • the basic framework provides many basic object classes and data types, and provides the most basic system services for all applications, regardless of the UI.
  • the classes provided by the UIKit framework are basic UI class libraries for creating touch-based user interfaces.
  • IOS applications can provide UIs based on the UIKit framework, so it provides the application's infrastructure for building user interfaces and drawing. , Handling and user interaction events, responding to gestures, and more.
  • the input-output device 130 may include a touch display screen for receiving a user's touch operation on or near any suitable object using a finger, a touch pen, or the like, and a user interface displaying various application programs.
  • the touch display is usually provided on the front panel of the terminal 100.
  • the touch display can be designed as a full screen, curved screen or special-shaped screen.
  • the touch display screen can also be designed as a combination of a full screen and a curved screen, and a combination of a special-shaped screen and a curved screen, which is not limited in the embodiment of the present application.
  • the structure of the terminal 100 shown in the above drawings does not constitute a limitation on the terminal 100.
  • the terminal may include more or fewer components than shown, or a combination of some Components, or different component arrangements.
  • the terminal 100 further includes components such as a radio frequency circuit, an input unit, a sensor, an audio circuit, a wireless fidelity (WiFi) module, a power source, and a Bluetooth module, and details are not described herein again.
  • WiFi wireless fidelity
  • the work of the scheduling processor core is performed autonomously by the scheduler based on the current load situation. For example, when it is detected that the load of the low-performance core is too large, the scheduler schedules the high-performance core running task; when it is detected that the load of the high-performance core is small, the scheduler schedules the low-performance core running task.
  • the target application program calls an API interface provided by the SDK to send a target request to the operating system, and the target request carries the task identifier of the target task of the target application program, so that the operating system can respond to the target task and target
  • the core binds and sets the target core to an isolated state, and only the target task after binding is allowed to run on the target core.
  • the method provided in the embodiment of the present application can avoid the problem that the target application may still be stuck when the target task may be preempted or interrupted when it is running in the processor core. It improves the running fluency of the application and achieves the effect of optimizing the running quality of the application.
  • FIG. 7 shows a flowchart of a processor core configuration method according to an exemplary embodiment of the present application.
  • This embodiment is exemplified by applying the method to a terminal 100 running an operating system and at least one application program.
  • the method includes:
  • Step 701 The target application program sends a target request to the operating system by calling the first API provided by the SDK, and the target request carries a task identifier of a target task of the target application program.
  • the SDK may be an SDK provided by an operating system developer embedded in a target application program, or may be an SDK in a dynamic library (DLL) of a so file located at a system runtime library layer of the operating system.
  • DLL dynamic library
  • the following uses only the SDK as an example embedded in the target application as an example.
  • the target application may be a third-party application embedded with an SDK provided by an operating system developer.
  • the target application may be a game application, a video playback application, an instant communication application, and the like.
  • the target application is not specifically limited.
  • the embedded SDK contains several APIs.
  • the target application finishes starting, it calls the first API provided by the SDK to establish a Binder connection with the operating system, and establishes a data communication connection with the operating system through the Binder connection. Through this data communication connection, the target application sends a target request to the operating system.
  • the target application sending the target request to the operating system may include: the target application obtaining the task identifier of the target task, and sending the target request carrying the task identifier to the operating system.
  • the task ID of a target task is used to uniquely identify the target task among multiple tasks.
  • Target tasks are also called target processes or target threads.
  • the target task includes at least one process, or at least one thread.
  • the target task is a task related to the running fluency of the target application.
  • the target task is a task whose criticality level is higher than a preset level threshold among multiple tasks involved in the target application.
  • the criticality level of a task is used to indicate the criticality of the task in the target application.
  • the criticality level of a task is positively related to the system resource performance required for the task. That is, the higher the criticality level of a task, the higher the performance of system resources required by the task.
  • the preset level threshold may be set by the terminal by default, or may be set by a user, which is not limited in this embodiment.
  • the target application sends a target request to the operating system by calling the first API provided by the SDK, including: the target application obtains the task attributes of the candidate task to be executed, and when the task attributes are used to indicate the candidate task and the target application When the running fluency is related, the target application determines the candidate task as the target task; the target application sends a target request carrying the task ID of the target task to the operating system by calling the first API provided by the SDK.
  • the task attribute of the candidate task is used to indicate whether the candidate task is related to the running fluency of the target application.
  • the task attribute of the candidate task includes a criticality level of the candidate task or a task identifier.
  • the criticality level of the candidate task is used to indicate the criticality of the candidate task in the target application.
  • the task identification of the candidate task is used to uniquely identify the candidate task among multiple tasks.
  • Step 702 The operating system determines a target core corresponding to the task identifier.
  • the target core includes at least one processor core.
  • the target core may be a preset processor core, or may be a core that is dynamically configured according to the current application scenario of the target application and / or the load of each core.
  • the number of target cores is positively related to the number of threads in the task.
  • the CPU integrated in the processor includes at least two cores, and the at least two cores include at least one first performance core (high-performance core) and at least one second performance core (low-performance core), where a single The processing capability of the first performance core is higher than that of a single second performance core.
  • the CPU includes 8 cores, of which 4 cores are the first performance core, and the other 4 cores are the second performance core.
  • the working frequency of the first performance core is higher than the working frequency of the second performance core, and the power consumption of the first performance core is higher than the power consumption of the second performance core.
  • the operating frequency of the first performance core is 2.0 GHz
  • the operating frequency of the second performance core is 1.2 GHz.
  • the embodiments of the present application do not limit the working frequencies of the two processor cores.
  • the target core is at least one of the first performance core, or at least one of the second performance core.
  • the target core is a core that is dynamically configured according to the current application scenario of the target application and / or the load of each core
  • the target application determines the first performance
  • the core is the target core; when the processing performance requirement of the target task indicated by the task identifier is lower than the performance threshold, the target application determines the second performance core as the target core to reduce the overall power consumption.
  • Step 703 The operating system binds the target task and the target core, and sets the target core to an isolated state. In the isolated state, only the bound target task is allowed to run on the target core.
  • the operating system binds the target task and the target core, and sets the target core to an isolated state.
  • only the bound target task is allowed to run on the target core, and other tasks other than the bound target task are not allowed to run.
  • a target application calls a first API interface provided by the SDK, and sends a target request to the operating system.
  • the target request carries a target task of the target application.
  • Task identification so that the operating system binds the target task to the target core and sets the target core to an isolated state. Only the bound target task is allowed to run on the target core.
  • the operating system can The task identifier of the target task is adaptively configured with the corresponding target core, and other tasks are not allowed to be scheduled to run on the target core. Only the bound target task is allowed to be scheduled to run on the target core, thereby ensuring the execution of the target task.
  • the problem that the target application in the related art may be preempted or interrupted by other tasks while running in the processor core is prevented from causing the target application to still be stuck, and the effect of optimizing the application program running quality is achieved.
  • the target application adopts a method of isolating the target core. After the target task is bound to the target core, the target core is allowed to run only the target task and not other common tasks. .
  • the following uses a schematic embodiment for description.
  • FIG. 8 shows a flowchart of a processor core configuration method according to another exemplary embodiment of the present application.
  • This embodiment is exemplified by applying the method to a terminal 100 running an operating system and at least one application program.
  • the method includes:
  • Step 801 The target application program sends a scheduling request to the operating system by calling a second API provided by the SDK, and the scheduling request is used to instruct the operating system to feedback the criticality level of the candidate task to be executed.
  • the target application Similar to sending a target request, the target application sends a scheduling request to the operating system by calling a second API (different from the first API) in the SDK.
  • the scheduling request includes an application identifier of the target application and a task identifier of the candidate task, and the application identifier may be a package name of the target application.
  • the criticality level of the candidate task in the target application is used to indicate the criticality of the candidate task in the target application.
  • the criticality level of a candidate task is positively related to the system resource performance required by the candidate task. That is, the higher the criticality level of the candidate task, the higher the performance of the system resource required by the candidate task.
  • Step 802 The operating system feeds back the criticality level to the target application.
  • the operating system acquires a first correspondence relationship corresponding to the application identifier according to the application identifier of the target application program, and acquires a criticality level corresponding to the task identifier of the candidate task according to the first correspondence relationship.
  • the first correspondence relationship is a correspondence relationship between the task identifier and the criticality level.
  • a correspondence relationship between different task identifiers and criticality levels is preset in the operating system, and the correspondence relationship is provided by the operating system developer and can be dynamically updated.
  • the corresponding relationship is shown in Table 1.
  • the criticality levels of tasks that are not related to the target application are Level 0
  • the criticality levels corresponding to Task 1, Task 2, and Task 3 involved in the target application are " Level 1 "
  • the level of criticality corresponding to task 4 involved in the target application is” Level 2 "
  • the level of criticality corresponding to tasks 5 and 6 involved in the target application is” Level 3 "
  • the target application involves The level of criticality corresponding to task 7, task 8, and task 9 is "Level 4".
  • the operating system determines the corresponding criticality level according to the task identifier of the candidate task.
  • the operating system feedbacks the level of criticality through a data communication connection with the target application.
  • the operating system may establish data communication connections with multiple applications at the same time.
  • the operating system obtains the foreground application identification of the foreground application, and detects whether the application identification of the target application is consistent with the foreground application identification.
  • a Binder connection is established between the application framework layer 250 and the interface communication system 242.
  • the operating system obtains foreground application information from the application framework layer 250, and the foreground application information includes the foreground application identifier.
  • the operating system will feedback the criticality level to the target application. If they are not the same, the operating system will not feedback the criticality level to the target application.
  • the operating system sends the criticality level in the form of a data packet, and the format of the data packet is agreed with the target application in advance.
  • the format of the data packet may be a Java script object tag (JavaScript, Object Notation, JSON), a protocol buffer (ProtocolBuffer, Protocol), or a custom format.
  • Step 803 The target application receives the criticality level feedback from the operating system.
  • the target application parses the data packet using a pre-approved data packet format, thereby obtaining the criticality level contained therein.
  • Step 804 If the criticality level is higher than a preset level threshold, the target application determines the candidate task as the target task.
  • the target application detects whether the criticality level is higher than a preset level threshold, and if it is higher, it determines that the processor core needs to be reconfigured, and executes step 805; if it is lower, it determines that the processor performance is stronger, and the target application The program does not send a target request.
  • the preset level threshold may be Level 2.
  • Step 805 The target application program sends a target request carrying the task identifier of the target task to the operating system by calling the first API provided by the SDK.
  • Step 806 The operating system obtains the target core corresponding to the task identifier.
  • the target core is a preset processor core.
  • the operating system Before the operating system obtains the target core corresponding to the task identifier, the operating system also includes: the operating system initializes multiple control groups, and the multiple control groups include a default control group and a reserved control group.
  • the default control group is used to indicate a default processing for processing tasks.
  • Processor core the reservation control group is used to indicate the processor core reserved for processing the target task.
  • each control group (default control group or reserved control group) in the multiple control groups includes a task list and at least one processor core identifier
  • the task list includes at least one running task and at least one processor core.
  • the identifier is used to indicate that all tasks in the control group are allowed to run only on the processor core corresponding to each of the at least one processor core identifier.
  • each task belongs to only one control group. That is, there is no intersection between tasks in any two control groups of multiple control groups.
  • the task is placed in the processor core indicated by the default control group to run by default.
  • obtaining the target core corresponding to the task identifier by the operating system includes: the operating system determining the processor core indicated by the reservation control group as the target core corresponding to the task identifier.
  • Step 807 The operating system binds the target task and the target core, and sets the target core to an isolated state. In the isolated state, only the bound target task is allowed to run on the target core.
  • the operating system determines the processor core indicated by the reserved control group as the target core corresponding to the task ID, if the target application is switched from the foreground to the background, the target application schedules the default control group through a system call.
  • the indicated processor core runs the target task.
  • the processor core indicated by the default control group can be called to run the target task, so that the reserved control group can Go to the target task of the application running in the foreground.
  • the target application sends a scheduling request to the operating system by calling the second API provided by the SDK, and the scheduling request is used to instruct the operating system to feedback the criticality level of the candidate task of the target application; the operating system feedbacks to the target application.
  • Criticality level if the criticality level is higher than the preset level threshold, the target application determines the candidate task as the target task; so that subsequent operating systems can bind the target task whose criticality level is higher than the preset level threshold to the target core This in turn ensures the execution of more critical target tasks.
  • the reserved control groups are set in multiple control groups in advance through the operating system.
  • the target task can be placed on the processor core indicated by the reserved control group. In the target core, the target task will not be preempted or interrupted by other tasks.
  • Step 901 The target application obtains a task identifier of a candidate task.
  • the task identifier of the candidate task is also referred to as the process identifier of the candidate process.
  • the process identifier is usually represented by a process identifier (PID).
  • the task ID of the candidate task is also referred to as the thread ID of the candidate thread, and the thread ID is usually represented by a thread ID.
  • the target application After the target application obtains the task identifier of the candidate task, it determines whether the task identifier belongs to the preset task identifier list. If the task identifier belongs to the preset task identifier list, the target application executes the following step 902; if the task identifier does not belong to the preset Task ID list, the target application disconnects from the operating system.
  • step of determining whether the task identifier belongs to the preset task identifier list may also be performed when the target application program establishes a data communication connection with the operating system, which is not limited in this embodiment.
  • step 902 if the task identifier of the candidate task belongs to the preset task identifier list, the target application program determines the candidate task as the target task.
  • a preset application identifier list is included in the target application, and the preset task identifier list includes multiple task identifiers related to the running fluency of the target application.
  • the list is set by the target application developer and stored encrypted in the terminal.
  • the target core is a core that is dynamically configured according to a current application scenario of the target application and / or a load of each core.
  • the processor in the terminal includes a first performance core and a second performance core, and the performance of the first performance core is higher than the performance of the second performance core.
  • the target application determines the target core corresponding to the target task according to the maximum processing performance requirements of the target task.
  • the target application determines that the target core corresponding to the target task is the second performance core; when the target task is a task with a high demand for the processor computing power When the target application determines that the target core corresponding to the target task is the first performance core.
  • the target task has different requirements for processor computing power in different application scenarios. For example, taking a game application as an example, in the game main interface scenario, the target task requires a lower computing power of the processor, while in the game battle scenario, the target task requires a higher computing power of the processor. If the target task of the target application always runs on the first performance core, it will waste the computing resources of the processor and increase the overall power consumption of the terminal.
  • the target application when the target application is running in the foreground, the target application dynamically determines the target core corresponding to the target task according to the current application scenario.
  • the above step 806 may include the following steps.
  • Step 1001 The operating system obtains a current application scenario of the target application.
  • the application scenarios refer to scenarios corresponding to different running stages in the target application.
  • the application scenarios include game data loading scenarios, game data update scenarios, game main interface scenarios, and game battle scenarios.
  • the operating system obtains the current application scenario of the target application, where the application scenario is represented by a scenario number.
  • Step 1002 If the current application scenario belongs to the first application scenario, the operating system determines the first performance core as the target core corresponding to the task identifier.
  • the application scenario is divided into a first application scenario and a second application scenario based on the requirements of the processor computing performance of the application scenario, where the performance of the processor on the first application scenario The demand is higher than the performance requirement of the processor in the second application scenario.
  • the corresponding first application scenario includes a game mall interface scenario, a game cut scene animation scenario, and a game battle scenario; its corresponding second application scenario includes a game resource update scenario, a game main interface scenario, and a game account Landing scene.
  • the target application detects whether the current application scenario belongs to the first application scenario. If it does, the target application determines the first performance core as the target core; if it does not, the target application determines that the current application scenario belongs to the second application. Scenes.
  • the core numbers corresponding to the 8 processor cores are 0-7.
  • the core information fed back by the operating system indicates that the processor core with core numbers 0-3 is the first performance core, and the processor core with core numbers 4-7 is the second performance core.
  • the target application determines the first performance core with core numbers 0 and 1 as the target core.
  • Step 1003 If the current application scenario belongs to the second application scenario, the operating system determines the second performance core as the target core corresponding to the task identifier.
  • the target application determines the second performance core as the target core corresponding to the task identifier.
  • the target application determines the second performance core with the core number 4 as the target core.
  • the target application program determines the target core corresponding to the task identifier according to the current application scenario and the load situation of the processor core at the same time.
  • the above step 806 may include the following steps.
  • Step 1101 The operating system obtains the current application scenario of the target application and the load of each core.
  • the operating system obtains load information by accessing the kernel layer.
  • the load information includes the load of each core, and the load can be expressed by the core usage.
  • step 1102 if the current application scenario belongs to the first application scenario and the load of the first performance core is less than the load threshold, the operating system determines the first performance core as the target core.
  • the target application determines the target core from the cores whose load is below the load threshold. For example, the load threshold is 20% of core usage.
  • the current application scenario is the first application scenario
  • the load of the first performance core (the core numbers are 0 to 3 in order) is 30%, 22%, 0%, and 0% in order.
  • the target application is about to have the core number as The first performance core of 2 and 3 is determined as the target core.
  • Step 1103 If the current application scenario belongs to the second application scenario and the load of the second performance core is less than the load threshold, the operating system determines the second performance core as the target core.
  • the target application determines the target core from the second performance core whose load is lower than the load threshold.
  • the target application selects a lightly loaded core as the target core according to the load situation of the core, thereby reducing the impact on other tasks when the core is bound.
  • FIG. 12 is a schematic structural diagram of a processor core configuration device according to an embodiment of the present application.
  • the processor core configuration device may be implemented as a whole or a part of the terminal in FIG. 1 through a dedicated hardware circuit or a combination of software and hardware.
  • the processor core configuration device includes a target application program module 1210 and an operating system module 1220.
  • the target application module 1210 is configured to send a target request to the operating system module 1220 by calling the first API provided by the SDK, and the target request carries a task identifier of a target task of the target application;
  • An operating system module 1220 configured to determine a target core corresponding to a task identifier
  • the operating system module 1220 is further configured to bind the target task and the target core, and set the target core to an isolated state. In the isolated state, only the bound target task is allowed to run on the target core.
  • the target application module 1210 is further configured to obtain task attributes of the candidate task to be executed, and the task attributes are used to indicate whether the candidate task is related to the running fluency of the target application module 1210; when the task attributes are used to indicate the candidate When the task is related to the running fluency of the target application module 1210, the candidate task is determined as the target task;
  • the target application program module 1210 is further configured to send a target request carrying a task identifier of the target task to the operating system module 1220 by calling the first API provided by the SDK.
  • the target application module 1210 is further configured to send a scheduling request to the operating system module 1220 by calling a second API provided by the SDK, and the scheduling request is used to instruct the operating system module 1220 to feedback the criticality level of the candidate task to be executed. ;
  • the target application program module 1210 is further configured to receive a criticality level feedback from the operating system module 1220;
  • the target application program module 1210 is further configured to determine the candidate task as the target task if the criticality level is higher than a preset level threshold.
  • the task attributes of the candidate task include the task identifier of the candidate task
  • the target application module 1210 is further configured to determine the candidate task as the target task if the task identifier of the candidate task belongs to a preset task identifier list;
  • the preset task identifier list includes multiple task identifiers related to the running fluency of the target application module 1210.
  • the operating system module 1220 is also used to initialize multiple control groups.
  • the multiple control groups include a default control group and a reserved control group.
  • the default control group is used to indicate a default processor core for processing tasks.
  • the reserved control group is used to indicate a reserved processor core for processing a target task;
  • the operating system module 1220 is further configured to determine the processor core indicated by the reservation control group as a target core corresponding to the task identifier.
  • the target application program module 1210 is further configured to schedule a processor core indicated by the default control group to run the target task through a system call when switching from the foreground operation to the background operation.
  • the processor in the terminal includes a first performance core and a second performance core, and the performance of the first performance core is higher than the performance of the second performance core;
  • the operating system module 1220 is configured to determine a target core among the first performance core and the second performance core according to a maximum processing performance requirement of the target task.
  • the processor in the terminal includes a first performance core and a second performance core, and the performance of the first performance core is higher than that of the second performance core;
  • the operating system module 1220 is further configured to obtain a current application scenario of the target application program module 1210.
  • the operating system module 1220 is further configured to: if the current application scenario belongs to the first application scenario, determine the first performance core as the target core corresponding to the task identifier; if the current application scenario belongs to the second application scenario, determine the second performance core Identify the target core corresponding to the task;
  • the performance requirement of the processor in the first application scenario is higher than the performance requirement of the processor in the second application scenario.
  • the processor in the terminal includes a first performance core and a second performance core, and the performance of the first performance core is higher than that of the second performance core;
  • the operating system module 1220 is further configured to obtain the current application scenario and the load of each core of the target application module 1210. If the current application scenario belongs to the first application scenario and the load of the first performance core is less than the load threshold, the first performance core Determine the target core; if the current application scenario belongs to the second application scenario and the load of the second performance core is less than the load threshold, determine the second performance core as the target core;
  • the performance requirement of the processor in the first application scenario is higher than the performance requirement of the processor in the second application scenario.
  • the target application program module 1210 is also used to implement any other functions related to the steps performed by the target application program that are implicit or disclosed in the above method embodiments; the operating system module 1220 is also used to implement any other methods in the above method embodiments. Implied or exposed functions related to steps performed by the operating system.
  • the devices provided in the above embodiments only use the division of the above functional modules as an example to implement their functions. In practical applications, the above functions may be allocated by different functional modules as needed. The internal structure of the device is divided into different functional modules to complete all or part of the functions described above.
  • the devices and method embodiments provided by the foregoing embodiments belong to the same concept. For specific implementation processes, refer to the method embodiments, and details are not described herein again.
  • the present application also provides a computer-readable medium having program instructions stored thereon.
  • program instructions When the program instructions are executed by a processor, the processor core configuration method provided by the foregoing method embodiments is implemented.
  • the present application also provides a computer program product containing instructions, which when executed on a computer, causes the computer to execute the processor core configuration method described in the foregoing embodiments.
  • the steps in the method for configuring a processor core according to the above embodiment may be completed by hardware, or may be performed by a program instructing related hardware.
  • the program may be stored in a computer.
  • the aforementioned storage medium may be a read-only memory, a magnetic disk, or an optical disk.

Landscapes

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

Abstract

本申请公开了一种处理器核心配置方法、装置、终端及存储介质,属于终端技术领域。所述方法包括:目标应用程序通过调用SDK提供的第一API,向操作系统发送目标请求,目标请求携带有目标应用程序的目标任务的任务标识;操作系统确定任务标识对应的目标核心;操作系统对目标任务和目标核心进行绑定,并将目标核心设置为隔离状态,隔离状态下目标核心上只允许运行绑定后的目标任务。本申请实施例通过操作系统根据目标任务的任务标识自适应配置相应的目标核心,不允许其他任务调度到该目标核心上运行,仅允许绑定后的目标任务调度到该目标核心上运行,从而使得目标任务的执行得到保障,达到了优化应用程序运行质量的效果。

Description

处理器核心配置方法、装置、终端及存储介质
本申请要求于2018年09月26日提交的申请号为201811122422.0、发明名称为“处理器核心配置方法、装置、终端及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请实施例涉及终端技术领域,特别涉及一种处理器核心配置方法、装置、终端及存储介质。
背景技术
随着处理器制造技术的不断提高,越来越多的厂商为终端配置多核心的处理器,以此来提高终端整体的处理能力。
出于性能和功耗等方面的考虑,包含多个核心的处理器采用Big-Little架构。采用Big-Little架构的处理器中包含多个高性能核心和多个低性能核心,其中,高性能核心用于处理复杂运算,而低性能核心则用于处理简单运算。然而,相关技术中尚未提供一种合理的处理器核心配置方法。
发明内容
本申请实施例提供了一种处理器核心配置方法、装置、终端及存储介质。所述技术方案如下:
根据本申请实施例的第一方面,提供了一种处理器核心配置方法,所述方法应用于终端,所述终端运行有操作系统和至少一个应用程序,所述方法包括:
目标应用程序通过调用软件开发工具包(Software Development Kit,SDK)提供的第一应用程序编程接口(Application Programming Interface,API),向所述操作系统发送目标请求,所述目标请求携带有所述目标应用程序的目标任务的任务标识;
所述操作系统确定所述任务标识对应的目标核心;
所述操作系统对所述目标任务和所述目标核心进行绑定,并将所述目标核心设置为隔离状态,所述隔离状态下所述目标核心上只允许运行绑定后的所述目标任务。
根据本申请实施例的第二方面,提供了一种处理器核心配置装置,所述装置包括目标应用程序模块和操作系统模块;
所述目标应用程序模块,用于通过调用SDK提供的第一API,向所述操作系统模块发送目标请求,所述目标请求携带有所述目标应用程序的目标任务的任务标识;
所述操作系统模块,用于确定所述任务标识对应的目标核心;
所述操作系统模块,还用于对所述目标任务和所述目标核心进行绑定,并将所述目标核心设置为隔离状态,所述隔离状态下所述目标核心上只允许运行绑定后的所述目标任务。
根据本申请实施例的第三方面,提供了一种终端,所述终端包括处理器和存储器,所述存储器中存储有至少一条指令,所述指令由所述处理器加载并执行以实现如本申请第一方面及其可选实施例任一所述的处理器核心配置方法。
根据本申请实施例的第四方面,提供了一种计算机可读存储介质,所述存储介质中存储有至少一条指令,所述指令由处理器加载并执行以实现如本申请第一方面及其可选实施例任一所述的处理器核心配置方法。
本申请实施例提供的技术方案带来的有益效果至少包括:
本申请实施例提供的处理器核心配置方法中,通过目标应用程序调用SDK提供的第一API接口,向操作系统发送目标请求,该目标请求携带有目标应用程序的目标任务的任务标识,以便操作系统对目标任务和目标核心进行绑定,并将目标核心设置为隔离状态,在该目标核心上只允许运行绑定后的目标任务;本申请实施例中,操作系统能够根据目标任务的任务标识自适应配置相应的目标核心,不允许其他任务调度到该目标核心上运行,仅允许绑定后的目标任务调度到该目标核心上运行,从而使得目标任务的执行得到保障,避免了相关技术中目标任务在处理器核心中运行时可能被其它任务抢占或者打断导致目标应用程序仍会出现卡顿的问题,达到了优化应用程序运行质量的效果。
附图说明
图1是本申请一个示例性实施例提供的终端的结构示意图;
图2是终端中应用程序与操作系统通信过程的实施示意图;
图3是本申请一个示例性实施例提供的终端的结构示意图;
图4和图5是图3所示终端中应用程序与操作系统通信过程的实施示意图;
图6是本申请另一个示例性实施例提供的终端的结构示意图;
图7示出了本申请一个示例性实施例示出的处理器核心配置方法的流程图;
图8示出了本申请另一个示例性实施例示出的处理器核心配置方法的流程图;
图9示出了本申请另一个示例性实施例示出的处理器核心配置方法的流程图;
图10示出了本申请另一个示例性实施例示出的处理器核心配置方法的流程图;
图11示出了本申请另一个示例性实施例示出的处理器核心配置方法的流程图;
图12示出了本申请一个实施例提供的处理器核心配置装置的结构框图。
具体实施方式
为使本申请的目的、技术方案和优点更加清楚,下面将结合附图对本申请实施方式作进一步地详细描述。
下面的描述涉及附图时,除非另有表示,不同附图中的相同数字表示相同或相似的要素。以下示例性实施例中所描述的实施方式并不代表与本申请相一致的所有实施方式。相反,它们仅是与如所附权利要求书中所详述的、本申请的一些方面相一致的装置和方法的例子。
在本申请的描述中,需要理解的是,术语“第一”、“第二”等仅用于描述目的,而不能理解为指示或暗示相对重要性。在本申请的描述中,需要说明的是,除非另有明确的规定和限定,术语“相连”、“连接”应做广义理解,例如,可以是固定连接,也可以是可拆卸连接,或一体地连接;可以是机械连接,也可以是电连接;可以是直接相连,也可以通过中间媒介间接相连。对于本领域的普通技术人员而言,可以具体情况理解上述术语在本申请中的具体含义。此外,在本申请的描述中,除非另有说明,“多个”是指两个或两个以上。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。字符“/”一般表示前后关联对象是一种“或”的关系。
请参考图1,其示出了本申请一个示例性实施例提供的终端100的结构方框图。该终端100可以是智能手机、平板电脑、电子书等能够运行应用程序的电子设备。本申请中的终端100可以包括一个或多个如下部件:处理器110、存储器120和输入输出设备130。
处理器110可以包括一个或者多个处理核心。处理器110利用各种接口和线路连接整个终端100内的各个部分,通过运行或执行存储在存储器120内的指令、程序、代码集或指令集,以及调用存储在存储器120内的数据,执行终端100的各种功能和处理数据。可选地,处理器110可以采用数字信号处理(Digital Signal Processing,DSP)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)、可编程逻辑阵列(Programmable Logic Array,PLA)中 的至少一种硬件形式来实现。处理器110可集成中央处理器(Central Processing Unit,CPU)、图像处理器(Graphics Processing Unit,GPU)和调制解调器等中的一种或几种的组合。其中,CPU主要处理操作系统、用户界面和应用程序等;GPU用于负责显示内容的渲染和绘制;调制解调器用于处理无线通信。可以理解的是,上述调制解调器也可以不集成到处理器110中,单独通过一块通信芯片进行实现。
存储器120可以包括随机存储器(Random Access Memory,RAM),也可以包括只读存储器(Read-Only Memory)。可选地,该存储器120包括非瞬时性计算机可读介质(non-transitory computer-readable storage medium)。存储器120可用于存储指令、程序、代码、代码集或指令集。存储器120可包括存储程序区和存储数据区,其中,存储程序区可存储用于实现操作系统的指令、用于实现至少一个功能的指令(比如触控功能、声音播放功能、图像播放功能等)、用于实现下述各个方法实施例的指令等,该操作系统可以是安卓(Android)系统(包括基于Android系统深度开发的系统)、苹果公司开发的IOS系统(包括基于IOS系统深度开发的系统)或其它系统。存储数据区还可以存储终端100在使用中所创建的数据(比如电话本、音视频数据、聊天记录数据)等。
存储器120可分为操作系统空间和用户空间,操作系统即运行于操作系统空间,原生及第三方应用程序即运行于用户空间。为了保证不同第三方应用程序均能够达到较好的运行效果,操作系统针对不同第三方应用程序为其分配相应的系统资源。然而,同一第三方应用程序中不同应用场景对系统资源的需求也存在差异,比如,在本地资源加载场景下,第三方应用程序对磁盘读取速度的要求较高;在动画渲染场景下,第三方应用程序则对GPU性能的要求较高。而操作系统与第三方应用程序之间相互独立,操作系统往往不能及时感知第三方应用程序当前的应用场景,导致操作系统无法根据第三方应用程序的具体应用场景进行针对性的系统资源适配。
并且,第三方应用程序的运行质量还与操作系统实时的运行状态相关,若第三方应用程序不能及时获取操作系统当前的运行状态,其运行质量也将受到影响。比如,当终端温度过高时,第三方应用程序仍旧以第一性能模式运行,终端温度持续升高将导致系统崩溃,第三方应用程序也将无法运行。
如图2所示,为了提高第三方应用程序的运行质量,需要打通第三方应用程序与操作系统之间的数据通信,使得操作系统能够随时获取第三方应用程序当前的场景信息,进而基于当前场景进行针对性的系统资源适配;同时,第三方应用程序能够实时获取操作系统的运行状态,进而基于该运行状态针对性的进行程序优化。
以操作系统为Android系统为例,存储器120中存储的程序和数据如图3所示,存储器120中可存储有Linux内核层220、系统运行库层240、应用框架层260和应用层280,其中,Linux内核层220、系统运行库层240和应用框架层260属于操作系统空间,应用层280属于用户空间。Linux内核层220为终端100的各种硬件提供了底层的驱动,如显示驱动、音频驱动、摄像头驱动、蓝牙驱动、Wi-Fi驱动、电源管理等。系统运行库层240通过一些C/C++库来为Android系统提供了主要的特性支持。如SQLite库提供了数据库的支持,OpenGL/ES库提供了3D绘图的支持,Webkit库提供了浏览器内核的支持等。在系统运行库层240中还提供有安卓运行时库(Android Runtime),它主要提供了一些核心库,能够允许开发者使用Java语言来编写Android应用。应用框架层260提供了构建应用程序时可能用到的各种API,开发者也可以通过使用这些API来构建自己的应用程序,比如活动管理、窗口管理、视图管理、通知管理、内容提供者、包管理、通话管理、资源管理、定位管理。应用层280中运行有至少一个应用程序,这些应用程序可以是操作系统自带的原生应用程序,比如联系人程序、短信程序、时钟程序、相机应用等;也可以是第三方开发者所开发的第三方应用程序,比如游戏类应用程序、即时通信程序、相片美化程序、购物程序等。
操作系统与第三方应用程序之间一种可行的通信方式如图4所示,第三方应用程序中内嵌有用于与操作系统进行通信的SDK。
其中,SDK包含若干经过抽象的API,并由操作系统开发者提供给第三方应用程序开发者,并由第三方应用程序开发者将该SDK内嵌到第三方应用程序中。此类第三方应用程序安装并运行在操作系统后,即可调用SDK提供的API与操作系统进行通信。
如图4所示,系统运行库层240可以额外包括接口通信系统242。该接口通信系统242可以视为操作系统中的一个子系统,或视为操作系统内嵌的一个应用程序。接口通信系统242中设置有SDK接口,第三方应用程序即调用SDK的API与该SDK接口之间通过粘合(Binder)的方式进行数据通信。这样,第三方应用程序的应用场景相关的数据就可以通过SDK传输给操作系统,且/或,操作系统运行状态相关的数据也可以通过SDK传输给第三方应用程序。
在另一种可行的通信方式中,如图5所示,第三方应用程序还可以采用套接字(Socket)方式与接口通信系统242的Socket接口建立长连接,第三方应用程序和操作系统之间即可通过该长连接进行通信。
如图4和5所示,接口通信系统242中可设置有不同的策略模块,接收到第三方应用程序发送的数据后,接口通信系统242即采用第三方应用程序对应的策略模块对数据进行分析,得到相应的资源适配优化策略。基于分析得到的资源适配优化策略,接口通信系统242通过控制接口通知Linux内核层220进行系统资源适配优化。其中,该控制接口可以采用Sysfs的方式与Linux内核层220进行通信。
可选的,接口通信系统242中不同的策略模块可以对应不同的第三方应用程序(即针对不同的应用程序设置策略模块),或者,不同的策略模块对应不同类型的第三方应用程序(即针对不同类型的应用程序设置策略模块),或者,不同的策略模块对应不同的系统资源(即针对不同系统资源设置策略模块),或者,不同的策略模块对应不同的应用场景(即针对不同的以应用场景设置策略模块),本申请实施例并不对策略模块的具体设置方式进行限定。
可选的,如图4或5所示,第三方应用程序中可设置有不同的策略模块,接收到操作系统发送的与运行状态相关的数据后,第三方应用程序即可通过不同的策略模块制定出不同的程序优化策略,进而根据程序优化策略对程序进行优化。
其中,接口通信系统242还可以通过Binder的方式与应用框架层260进行通信,用于接收应用框架层260发送的前景应用信息,从而基于前景应用信息,仅针对当前前台运行的第三方应用程序进行系统资源优化。
以操作系统为IOS系统为例,存储器120中存储的程序和数据如图6所示,IOS系统包括:核心操作系统层320(Core OS layer)、核心服务层340(Core Services layer)、媒体层360(Media layer)、可触摸层380(Cocoa Touch Layer)。核心操作系统层320包括了操作系统内核、驱动程序以及底层程序框架,这些底层程序框架提供更接近硬件的功能,以供位于核心服务层340的程序框架所使用。核心服务层340提供给应用程序所需要的系统服务和/或程序框架,比如基础(Foundation)框架、账户框架、广告框架、数据存储框架、网络连接框架、地理位置框架、运动框架等等。媒体层360为应用程序提供有关视听方面的接口,如图形图像相关的接口、音频技术相关的接口、视频技术相关的接口、音视频传输技术的无线播放(AirPlay)接口等。可触摸层380为应用程序开发提供了各种常用的界面相关的框架,可触摸层380负责用户在终端100上的触摸交互操作。比如本地通知服务、远程推送服务、广告框架、游戏工具框架、消息用户界面接口(User Interface,UI)框架、用户界面UIKit框架、地图框架等等。
在图6所示出的框架中,与大部分应用程序有关的框架包括但不限于:核心服务层340中的基础框架和可触摸层380中的UIKit框架。基础框架提供许多基本的对象类和数据类型, 为所有应用程序提供最基本的系统服务,和UI无关。而UIKit框架提供的类是基础的UI类库,用于创建基于触摸的用户界面,iOS应用程序可以基于UIKit框架来提供UI,所以它提供了应用程序的基础架构,用于构建用户界面,绘图、处理和用户交互事件,响应手势等等。
其中,在IOS系统中实现第三方应用程序与操作系统数据通信的方式以及原理可参考Android系统,本申请在此不再赘述。
输入输出设备130可以包括触摸显示屏,该触摸显示屏用于接收用户使用手指、触摸笔等任何适合的物体在其上或附近的触摸操作,以及显示各个应用程序的用户界面。触摸显示屏通常设置在终端100的前面板。触摸显示屏可被设计成为全面屏、曲面屏或异型屏。触摸显示屏还可被设计成为全面屏与曲面屏的结合,异型屏与曲面屏的结合,本申请实施例对此不加以限定。
除此之外,本领域技术人员可以理解,上述附图所示出的终端100的结构并不构成对终端100的限定,终端可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。比如,终端100中还包括射频电路、输入单元、传感器、音频电路、无线保真(Wireless Fidelity,WiFi)模块、电源、蓝牙模块等部件,在此不再赘述。
相关技术中,调度处理器核心的工作由调度器基于当前负载情况自主完成。比如,当检测到低性能核心的负载过大时,调度器即调度高性能核心运行任务;当检测到高性能核心的负载较小时,调度器即调度低性能核心运行任务。
然而,基于负载调度处理器核心仍然可能会引起应用程序卡顿的情况。在一种可能的场景下,目标应用程序处于前台运行,处理器核心中运行有影响该目标应用程序卡顿的目标任务和其他的普通任务,目标任务在处理器核心中运行时可能被会被普通任务抢占或者打断,导致目标应用程序仍会出现卡顿的情况,影响应用程序的运行质量。
为了避免上述问题,本申请实施例中,目标应用程序调用SDK提供的API接口向操作系统发送目标请求,该目标请求携带有目标应用程序的目标任务的任务标识,以便操作系统对目标任务和目标核心进行绑定,并将目标核心设置为隔离状态,在该目标核心上只允许运行绑定后的目标任务。相较于基于负载进行处理器核心调度,采用本申请实施例提供的方法能够避免目标任务在处理器核心中运行时可能被其它任务抢占或者打断导致目标应用程序仍会出现卡顿的问题,提高了应用程序的运行流畅度,达到了优化应用程序运行质量的效果。
请参考图7,其示出了本申请一个示例性实施例示出的处理器核心配置方法的流程图。本实施例以该方法应用于运行有操作系统和至少一个应用程序的终端100来举例说明。该方法包括:
步骤701,目标应用程序通过调用SDK提供的第一API,向操作系统发送目标请求,目标请求携带有目标应用程序的目标任务的任务标识。
SDK可以是内嵌在目标应用程序中由操作系统开发商提供的SDK,也可以是位于操作系统的系统运行库层的so文件的动态库(Dynamic Link Library,DLL)中的SDK。为了方便说明,下面仅以SDK为内嵌在目标应用程序中的SDK为例进行说明。
目标应用程序可以为内嵌有操作系统开发商提供的SDK的第三方应用程序,该目标应用程序可以为游戏类应用程序、视频播放类应用程序、即时通信应用程序等等,本申请实施例并不对目标应用程序进行具体限定。
内嵌的SDK中包含若干API,当目标应用程序完成启动后,即通过调用SDK提供的第一API,与操作系统之间建立Binder连接,从而通过该Binder连接与操作系统建立数据通信连接,进而通过该数据通信连接,目标应用程序向操作系统发送目标请求。
目标应用程序向操作系统发送目标请求可以包括:目标应用程序获取目标任务的任务标识,向操作系统发送携带有该任务标识的目标请求。目标任务的任务标识用于在多个任务中 唯一标识该目标任务。
目标任务也称目标进程或者目标线程。目标任务包括至少一个进程,或者至少一个线程。
可选的,目标任务为与目标应用程序的运行流畅度相关的任务。
可选的,目标任务为目标应用程序涉及的多个任务中关键程度等级高于预设等级阈值的任务。其中,任务的关键程度等级用于指示该任务在目标应用程序中的关键程度。任务的关键程度等级与该任务所需的系统资源性能呈正相关关系。即任务的关键程度等级越高,该任务所需的系统资源性能越高。
预设等级阈值可以是终端默认设置的,也可以是用户自定义设置的,本实施例对此不加以限定。
可选的,目标应用程序通过调用SDK提供的第一API,向操作系统发送目标请求,包括:目标应用程序获取待执行的候选任务的任务属性,当任务属性用于指示候选任务与目标应用程序的运行流畅度相关时,目标应用程序将候选任务确定为目标任务;目标应用程序通过调用SDK提供的第一API,向操作系统发送携带有目标任务的任务标识的目标请求。
候选任务的任务属性用于指示候选任务是否与目标应用程序的运行流畅度相关。
可选的,候选任务的任务属性包括候选任务的关键程度等级或者任务标识。其中,候选任务的关键程度等级用于指示该候选任务在目标应用程序中的关键程度。候选任务的任务标识用于在多个任务中唯一标识该候选任务。
需要说明的是,目标应用程序根据候选任务的任务属性确定是否为目标任务的过程可参考下面实施例中的相关细节,在此先不介绍。
步骤702,操作系统确定任务标识对应的目标核心。
目标核心包括至少一个处理器核心。目标核心可以是预先设置好的处理器核心,也可以是根据目标应用程序的当前应用场景和/或各个核心的负载动态配置的核心。
可选的,目标核心的数量与任务中线程的数量呈正相关关系。
可选的,处理器中集成的CPU至少包含两个核心,且至少两个核心中包括至少一个第一性能核心(高性能核心)和至少一个第二性能核心(低性能核心),其中,单个第一性能核心的处理能力高于单个第二性能核心的处理能力。比如,该CPU中包含8个核心,其中4个核心为第一性能核心,另外4个核心为第二性能核心。
可选的,第一性能核心的工作频率高于第二性能核心的工作频率,且第一性能核心的功耗高于第二性能核心的功耗。比如,第一性能核心的工作频率为2.0GHz,第二性能核心的工作频率为1.2GHz。本申请实施例并不对两种处理器核心的工作频率进行限定。
可选的,该目标核心为第一性能核心中的至少一个,或,第二性能核心中的至少一个。
当目标核心是根据目标应用程序的当前应用场景和/或各个核心的负载动态配置的核心时,当任务标识指示的目标任务对处理性能的需求高于性能阈值时,目标应用程序确定第一性能核心为目标核心;当任务标识指示的目标任务对处理性能的需求低于性能阈值时,目标应用程序确定第二性能核心为目标核心,以降低整体功耗。相关细节可参考下面实施例中的相关描述,在此先不介绍。
步骤703,操作系统对目标任务和目标核心进行绑定,并将目标核心设置为隔离状态,隔离状态下目标核心上只允许运行绑定后的目标任务。
操作系统对目标任务和目标核心进行绑定,并将目标核心设置为隔离状态。
可选的,隔离状态下目标核心上只允许运行绑定后的目标任务,不允许运行除了绑定后的目标任务以外的其它任务。
综上所述,本申请实施例提供的处理器核心配置方法中,通过目标应用程序调用SDK提供的第一API接口,向操作系统发送目标请求,该目标请求携带有目标应用程序的目标任务的任务标识,以便操作系统对目标任务和目标核心进行绑定,并将目标核心设置为隔离状态,在该目标核心上只允许运行绑定后的目标任务;本申请实施例中,操作系统能够根据目标任 务的任务标识自适应配置相应的目标核心,不允许其他任务调度到该目标核心上运行,仅允许绑定后的目标任务调度到该目标核心上运行,从而使得目标任务的执行得到保障,避免了相关技术中目标任务在处理器核心中运行时可能被其它任务抢占或者打断导致目标应用程序仍会出现卡顿的问题,达到了优化应用程序运行质量的效果。
在一种可能的实施方式中,目标应用程序采用将目标核心进行隔离的方式,在将目标任务与目标核心进行绑定之后,实现在目标核心上仅允许运行目标任务而不允许运行其它普通任务。下面采用示意性的实施例进行说明。
请参考图8,其示出了本申请另一个示例性实施例示出的处理器核心配置方法的流程图。本实施例以该方法应用于运行有操作系统和至少一个应用程序的终端100来举例说明。该方法包括:
步骤801,目标应用程序通过调用SDK提供的第二API,向操作系统发送调度请求,调度请求用于指示操作系统反馈待执行的候选任务的关键程度等级。
与发送目标请求相似的,目标应用程序通过调用SDK中的第二API(不同于第一API),向操作系统发送调度请求。可选的,该调度请求中包含目标应用程序的应用标识和候选任务的任务标识,该应用标识可以为目标应用程序的包名。
目标应用程序中候选任务的关键程度等级用于指示该候选任务在目标应用程序中的关键程度。候选任务的关键程度等级与该候选任务所需的系统资源性能呈正相关关系。即候选任务的关键程度等级越高,该候选任务所需的系统资源性能越高。
步骤802,操作系统向目标应用程序反馈关键程度等级。
在一种可能的实施方式中,操作系统根据目标应用程序的应用标识,获取与应用标识对应的第一对应关系,根据第一对应关系获取候选任务的任务标识对应的关键程度等级。其中,第一对应关系为任务标识与关键程度等级之间的对应关系。
可选的,操作系统中预先设置有不同任务标识与关键程度等级之间的对应关系,该对应关系由操作系统开发商提供,且可以动态更新。
示意性的,该对应关系如表一所示。可选的,当目标应用程序处于前台运行时,与目标应用程序无关的任务的关键程度等级均为Level 0,该目标应用程序涉及的任务1、任务2、任务3对应的关键程度等级为“Level 1”;该目标应用程序涉及的任务4对应的关键程度等级为“Level 2”;该目标应用程序涉及的任务5、任务6对应的关键程度等级为“Level 3”;该目标应用程序涉及的任务7、任务8、任务9对应的关键程度等级为“Level 4”。
表一
任务标识 关键程度等级
任务1、任务2、任务3 Level 1
任务4 Level 2
任务5、任务6 Level 3
任务7、任务8、任务9 Level 4
相应的,操作系统即根据候选任务的任务标识,确定其对应的关键程度等级。操作系统通过与目标应用程序之间的数据通信连接,反馈关键程度等级。
由于终端中可能安装并运行有多个SDK的应用程序,且操作系统可能同时与多个应用程序建立数据通信连接。为了保证前台应用程序的运行质量,在一种可能的实施方式中,操作系统获取前台应用的前台应用标识,并检测目标应用程序的应用标识与前台应用标识是否一致。示意性,如图4所示,应用框架层250与接口通信系统242之间建立有Binder连接,操作系统即从应用框架层250处获取前景应用信息,该前景应用信息中即包含前台应用标识。
若两者一致,操作系统则向目标应用程序反馈关键程度等级,若两者不一致,操作系统则不会向目标应用程序反馈关键程度等级。
可选的,操作系统采用数据包的形式发送关键程度等级,且数据包的格式预先与目标应用程序进行约定。其中,数据包的格式可以为Java脚本对象标记(JavaScript Object Notation,JSON)、协议缓冲区(ProtocolBuffer,Protobuf)或自定义格式等。
步骤803,目标应用程序接收操作系统反馈的关键程度等级。
相应的,目标应用程序接收到操作系统发送的数据包后,采用预先约定的数据包格式对该数据包进行解析,从而得到其中包含的关键程度等级。
步骤804,若关键程度等级高于预设等级阈值,目标应用程序则将候选任务确定为目标任务。
进一步的,目标应用程序检测关键程度等级是否高于预设等级阈值,若高于,则确定需要重新配置处理器核心,并执行步骤805;若低于,则确定处理器性能较强,目标应用程序不发送目标请求。结合表一所示,该预设等级阈值可以为Level 2。
步骤805,目标应用程序通过调用SDK提供的第一API,向操作系统发送携带有目标任务的任务标识的目标请求。
本步骤的实施方式与上述步骤701相似,本实施例在此不再赘述。
步骤806,操作系统获取任务标识对应的目标核心。
在一种可能的实施方式中,目标核心为预先设置好的处理器核心。操作系统获取任务标识对应的目标核心之前,还包括:操作系统初始化多个控制组,多个控制组包括默认控制组和预留控制组,默认控制组用于指示默认的用于处理任务的处理器核心,预留控制组用于指示预留的用于处理目标任务的处理器核心。
可选的,多个控制组中的每个控制组(默认控制组或预留控制组)包括任务列表和至少一个处理器核心标识,任务列表包括至少一个正在运行的任务,至少一个处理器核心标识用于指示该控制组内的所有任务仅允许在至少一个处理器核心标识各自对应的处理器核心上运行。
其中,每个任务仅属于一个控制组。即多个控制组中的任意两个控制组中的任务不存在交集。
可选的,当操作系统需要处理任务时默认将任务放置在默认控制组所指示的处理器核心中运行。
进一步的,操作系统获取任务标识对应的目标核心,包括:操作系统将预留控制组所指示的处理器核心确定为任务标识对应的目标核心。
步骤807,操作系统对目标任务和目标核心进行绑定,并将目标核心设置为隔离状态,隔离状态下目标核心上只允许运行绑定后的目标任务。
隔离状态下目标核心上只允许运行绑定后的目标任务,不允许运行除了绑定后的目标任务以外的其它任务。
当操作系统将预留控制组所指示的处理器核心确定为任务标识对应的目标核心时,若目标应用程序由前台运行切换至后台运行时,目标应用程序通过系统调用的方式调度默认控制组所指示的处理器核心运行目标任务。当应用程序由前台运行切换至后台运行时,用户对该应用程序的运行流畅度的关注程度较小,因此可以调用默认控制组所指示的处理器核心运行目标任务,以使得预留控制组可以去处理在前台运行的应用程序的目标任务。本实施例中,目标应用程序通过调用SDK提供的第二API,向操作系统发送调度请求,调度请求用于指示操作系统反馈目标应用程序的候选任务的关键程度等级;操作系统向目标应用程序反馈关键程度等级;若关键程度等级高于预设等级阈值,目标应用程序则将候选任务确定为目标任务;使得后续操作系统能够将关键程度等级高于预设等级阈值的目标任务与目标核心进行绑定,进而保证了较关键的目标任务的执行。
本实施例中,通过操作系统预先在多个控制组中设置预留控制组,当操作系统需要针对目标任务进行性能优化时,能够将目标任务放置到预留控制组所指示的处理器核心即目标核 心中,进而使得目标任务不会被其它任务抢占或者打断。
在一种可能的实施方式中,上述步骤801至804可以被替换实现成为如下几个步骤,如图9所示:
步骤901,目标应用程序获取候选任务的任务标识。
当任务为进程时,候选任务的任务标识也称候选进程的进程标识,进程标识通常用进程标识符(process identifier,PID)表示。
当任务为线程时,候选任务的任务标识也称候选线程的线程标识,线程标识通常用线程ID表示。
目标应用程序获取到候选任务的任务标识后,判断任务标识是否属于预设任务标识列表,若任务标识属于预设任务标识列表,目标应用程序则执行下述步骤902;若任务标识不属于预设任务标识列表,则目标应用程序断开与操作系统之间的连接。
需要说明的是,判断任务标识是否属于预设任务标识列表的步骤也可以在目标应用程序与操作系统建立数据通信连接时执行,本实施例并不对此进行限定。
步骤902,若候选任务的任务标识属于预设任务标识列表,目标应用程序则将候选任务确定为目标任务。
可选的,目标应用程序中预设应用标识列表,该预设任务标识列表中包含与目标应用程序的运行流畅度相关的多个任务标识。可选的,该列表由目标应用程序开发商设置,且加密存储在终端内。
在一种可能的实施方式中,目标核心是根据目标应用程序的当前应用场景和/或各个核心的负载动态配置的核心。
可选的,终端中的处理器包含第一性能核心和第二性能核心,第一性能核心的性能高于第二性能核心的性能。
当目标应用程序处于前台运行时,为了保证目标应用程序的目标任务在前台运行时能达到良好的运行质量,目标应用程序根据目标任务的最大处理性能需求确定目标任务对应的目标核心。
示意性的,当目标任务是对处理器运算能力需求较低的任务时,目标应用程序确定目标任务对应的目标核心为第二性能核心;当目标任务是对处理器运算能力需求较高的任务时,目标应用程序确定目标任务对应的目标核心为第一性能核心。
然而,在实际应用过程中发现,目标任务在不同应用场景下对处理器运算能力的需求不同。比如,以游戏类应用程序为例,在游戏主界面场景下,目标任务对处理器运算能力的需求较低,而在游戏对战场景下,目标任务对处理器运算能力的需求则较高。若目标应用程序的目标任务始终运行在第一性能核心上,将会在成处理器运算资源的浪费,并增加终端的整体功耗。
因此,在另一种可能的实施方式中,当目标应用程序处于前台运行时,目标应用程序根据当前应用场景,动态确定目标任务对应的目标核心。如图10所示,上述步骤806可以包括如下步骤。
步骤1001,操作系统获取目标应用程序的当前应用场景。
其中,应用场景指目标应用程序中不同运行阶段对应的场景,比如,对于游戏类应用程序,该应用场景包括游戏数据加载场景、游戏数据更新场景、游戏主界面场景和游戏对战场景等等。
可选的,当应用场景发生变化时,操作系统获取目标应用程序的当前应用场景,其中,应用场景采用场景编号进行表示。
步骤1002,若当前应用场景属于第一应用场景,操作系统则将第一性能核心确定为任务标识对应的目标核心。
可选的,开发人员在开发目标应用程序时,基于应用场景对处理器运算性能的需求,将应用场景划分为第一应用场景和第二应用场景,其中,第一应用场景对处理器的性能需求高于第二应用场景对处理器的性能需求。
以游戏类应用程序为例,其对应的第一应用场景包括游戏商城界面场景、游戏过场动画场景和游戏对战场景;其对应的第二应用场景包括游戏资源更新场景、游戏主界面场景和游戏账号登陆场景。
进一步的,目标应用程序检测当前应用场景是否属于第一应用场景,若属于,目标应用程序则将第一性能核心确定为目标核心;若不属于,目标应用程序则确定当前应用场景属于第二应用场景。
以处理器为8核处理器为例,8个处理器核心对应的核心编号为0-7。操作系统反馈的核心信息指示核心编号为0-3的处理器核心为第一性能核心,核心编号为4-7的处理器核心为第二性能核心。当前应用场景属于第一应用场景时,目标应用程序将核心编号为0和1的第一性能核心确定为目标核心。
步骤1003,若当前应用场景属于第二应用场景,操作系统则将第二性能核心确定为任务标识对应的目标核心。
当当前应用场景属于第二应用场景时,为了降低功耗目标应用程序则将第二性能核心确定为任务标识对应的目标核心。
结合步骤1002中的示例,当前应用场景属于第二应用场景时,目标应用程序将核心编号为4的第二性能核心确定为目标核心。
在另一种可能的实施方式中,目标应用程序同时根据当前应用场景和处理器核心的负载情况,确定任务标识对应的目标核心。如图11所示,上述步骤806可以包括如下几个步骤。
步骤1101,操作系统获取目标应用程序的当前应用场景和各个核心的负载。
操作系统通过访问内核层获取负载信息,负载信息包括各个核心的负载,该负载可以用核心使用率表示。
目标应用程序获取目标应用程序的当前应用场景的过程可参考步骤1001中的相关细节在此不再赘述。
步骤1102,若当前应用场景属于第一应用场景且第一性能核心的负载小于负载阈值,操作系统则将第一性能核心确定为目标核心。
当核心的负载较高时,表明其上运行有其他任务,由于目标核心在确定后需要设置为隔离状态,即需要将运行在其上的其它任务进行移动,因此为了避免对其他任务造成较大影响,目标应用程序从负载低于负载阈值的核心中确定目标核心。比如,该负载阈值为核心使用率20%。
示意性的,当前应用场景为第一应用场景,且第一性能核心(核心编号依次为0至3)的负载依次为30%、22%、0%、0%,目标应用程序即将核心编号为2和3的第一性能核心确定为目标核心。
步骤1103,若当前应用场景属于第二应用场景且第二性能核心的负载小于负载阈值,操作系统则将第二性能核心确定为目标核心。
与上述步骤1102相似的,若当前应用场景属于第二应用场景,目标应用程序从负载低于负载阈值的第二性能核心中确定目标核心。
本实施例中,目标应用程序根据核心的负载情况,选择负载较轻的核心作为目标核心,从而降低绑定核心时对其他任务造成的影响。
下述为本申请装置实施例,可以用于执行本申请方法实施例。对于本申请装置实施例中未披露的细节,请参照本申请方法实施例。
请参考图12,其示出了本申请一个实施例提供的处理器核心配置装置的结构示意图。该处理器核心配置装置可以通过专用硬件电路,或者,软硬件的结合实现成为图1中的终端的全部或一部分,该处理器核心配置装置包括:目标应用程序模块1210和操作系统模块1220。
目标应用程序模块1210,用于通过调用SDK提供的第一API,向操作系统模块1220发送目标请求,目标请求携带有目标应用程序的目标任务的任务标识;
操作系统模块1220,用于确定任务标识对应的目标核心;
操作系统模块1220,还用于对目标任务和目标核心进行绑定,并将目标核心设置为隔离状态,隔离状态下目标核心上只允许运行绑定后的目标任务。
可选的,目标应用程序模块1210,还用于获取待执行的候选任务的任务属性,任务属性用于指示候选任务是否与目标应用程序模块1210的运行流畅度相关;当任务属性用于指示候选任务与目标应用程序模块1210的运行流畅度相关时,将候选任务确定为目标任务;
目标应用程序模块1210,还用于通过调用SDK提供的第一API,向操作系统模块1220发送携带有目标任务的任务标识的目标请求。
可选的,目标应用程序模块1210,还用于通过调用SDK提供的第二API,向操作系统模块1220发送调度请求,调度请求用于指示操作系统模块1220反馈待执行的候选任务的关键程度等级;
目标应用程序模块1210,还用于接收操作系统模块1220反馈的关键程度等级;
目标应用程序模块1210,还用于若关键程度等级高于预设等级阈值,则将候选任务确定为目标任务。
可选的,候选任务的任务属性包括候选任务的任务标识;
目标应用程序模块1210,还用于若候选任务的任务标识属于预设任务标识列表,则将候选任务确定为目标任务;
其中,预设任务标识列表中包含与目标应用程序模块1210的运行流畅度相关的多个任务标识。
可选的,操作系统模块1220,还用于初始化多个控制组,多个控制组包括默认控制组和预留控制组,默认控制组用于指示默认的用于处理任务的处理器核心,预留控制组用于指示预留的用于处理目标任务的处理器核心;
操作系统模块1220,还用于将预留控制组所指示的处理器核心确定为任务标识对应的目标核心。
可选的,目标应用程序模块1210,还用于当由前台运行切换至后台运行时,通过系统调用的方式调度默认控制组所指示的处理器核心运行目标任务。
可选地,终端中的处理器包含第一性能核心和第二性能核心,第一性能核心的性能高于第二性能核心的性能;
操作系统模块1220,用于根据目标任务的最大处理性能需求在第一性能核心和第二性能核心中确定出目标核心。可选的,终端中的处理器包含第一性能核心和第二性能核心,第一性能核心的性能高于第二性能核心的性能;
操作系统模块1220,还用于获取目标应用程序模块1210的当前应用场景;
操作系统模块1220,还用于若当前应用场景属于第一应用场景,则将第一性能核心确定为任务标识对应的目标核心;若当前应用场景属于第二应用场景,则将第二性能核心确定为任务标识对应的目标核心;
其中,第一应用场景对处理器的性能需求高于第二应用场景对处理器的性能需求。
可选的,终端中的处理器包含第一性能核心和第二性能核心,第一性能核心的性能高于第二性能核心的性能;
操作系统模块1220,还用于获取目标应用程序模块1210的当前应用场景和各个核心的负载;若当前应用场景属于第一应用场景且第一性能核心的负载小于负载阈值,则将第一性 能核心确定为目标核心;若当前应用场景属于第二应用场景且第二性能核心的负载小于负载阈值,则将第二性能核心确定为目标核心;
其中,第一应用场景对处理器的性能需求高于第二应用场景对处理器的性能需求。
相关细节可结合参考图7至图11所示的方法实施例。其中,目标应用程序模块1210还用于实现上述方法实施例中其他任意隐含或公开的由目标应用程序所执行的步骤相关的功能;操作系统模块1220还用于实现上述方法实施例中其他任意隐含或公开的由操作系统所执行的步骤相关的功能。
需要说明的是,上述实施例提供的装置,在实现其功能时,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将设备的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的装置与方法实施例属于同一构思,其具体实现过程详见方法实施例,这里不再赘述。
本申请还提供一种计算机可读介质,其上存储有程序指令,程序指令被处理器执行时实现上述各个方法实施例提供的处理器核心配置方法。
本申请还提供了一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行上述各个实施例所述的处理器核心配置方法。
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。
本领域普通技术人员可以理解实现上述实施例的处理器核心配置方法中全部或部分步骤可以通过硬件来完成,也可以通过程序来指令相关的硬件完成,所述的程序可以存储于一种计算机可读存储介质中,上述提到的存储介质可以是只读存储器,磁盘或光盘等。以上所述仅为本申请的较佳实施例,并不用以限制本申请,凡在本申请的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。

Claims (20)

  1. 一种处理器核心配置方法,其特征在于,所述方法应用于终端,所述终端运行有操作系统和至少一个应用程序,所述方法包括:
    目标应用程序通过调用软件开发工具包SDK提供的第一应用程序编程接口API,向所述操作系统发送目标请求,所述目标请求携带有所述目标应用程序的目标任务的任务标识;
    所述操作系统确定所述任务标识对应的目标核心;
    所述操作系统对所述目标任务和所述目标核心进行绑定,并将所述目标核心设置为隔离状态,所述隔离状态下所述目标核心上只允许运行绑定后的所述目标任务。
  2. 根据权利要求1所述的方法,其特征在于,所述目标应用程序通过调用SDK提供的第一API,向所述操作系统发送目标请求,包括:
    所述目标应用程序获取待执行的候选任务的任务属性,所述任务属性用于指示所述候选任务是否与所述目标应用程序的运行流畅度相关;
    当所述任务属性用于指示所述候选任务与所述目标应用程序的运行流畅度相关时,所述目标应用程序将所述候选任务确定为所述目标任务;
    所述目标应用程序通过调用所述SDK提供的所述第一API,向所述操作系统发送携带有所述目标任务的任务标识的目标请求。
  3. 根据权利要求2所述的方法,其特征在于,所述目标应用程序获取待执行的候选任务的任务属性,包括:
    所述目标应用程序通过调用所述SDK提供的第二API,向所述操作系统发送调度请求,所述调度请求用于指示所述操作系统反馈待执行的所述候选任务的关键程度等级;
    所述目标应用程序接收所述操作系统反馈的所述关键程度等级;
    所述目标应用程序将所述候选任务确定为所述目标任务,包括:
    若所述关键程度等级高于预设等级阈值,所述目标应用程序则将所述候选任务确定为所述目标任务。
  4. 根据权利要求2所述的方法,其特征在于,所述候选任务的任务属性包括所述候选任务的任务标识;所述目标应用程序将所述候选任务确定为所述目标任务,包括:
    若所述候选任务的任务标识属于预设任务标识列表,所述目标应用程序则将所述候选任务确定为所述目标任务;
    其中,所述预设任务标识列表中包含与所述目标应用程序的运行流畅度相关的多个任务标识。
  5. 根据权利要求1至4任一所述的方法,其特征在于,所述操作系统获取所述任务标识对应的目标核心之前,还包括:
    所述操作系统初始化多个控制组,所述多个控制组包括默认控制组和预留控制组,所述默认控制组用于指示默认的用于处理任务的处理器核心,所述预留控制组用于指示预留的用于处理所述目标任务的处理器核心;
    所述操作系统获取所述任务标识对应的目标核心,包括:
    所述操作系统将所述预留控制组所指示的处理器核心确定为所述任务标识对应的目标核心。
  6. 根据权利要求5所述的方法,其特征在于,所述操作系统对所述目标任务和所述目标核心进行绑定,并将所述目标核心设置为隔离状态之后,所述方法还包括:
    当所述目标应用程序由前台运行切换至后台运行时,所述目标应用程序通过系统调用的方式调度所述默认控制组所指示的处理器核心运行所述目标任务。
  7. 根据权利要求1至4任一项所述的方法,其特征在于,所述终端中的处理器包含第一性能核心和第二性能核心,所述第一性能核心的性能高于所述第二性能核心的性能;
    所述操作系统确定所述任务标识对应的目标核心,包括:
    所述操作系统根据所述目标任务的最大处理性能需求在所述第一性能核心和所述第二性能核心中确定出所述目标核心。
  8. 根据权利要求1至4任一所述的方法,其特征在于,所述终端中的处理器包含第一性能核心和第二性能核心,所述第一性能核心的性能高于所述第二性能核心的性能;
    所述操作系统确定所述任务标识对应的目标核心,包括:
    所述操作系统获取所述目标应用程序的当前应用场景;
    若所述当前应用场景属于第一应用场景,所述操作系统则将所述第一性能核心确定为所述任务标识对应的所述目标核心;
    若所述当前应用场景属于第二应用场景,所述操作系统则将所述第二性能核心确定为所述任务标识对应的所述目标核心;
    其中,所述第一应用场景对处理器的性能需求高于所述第二应用场景对处理器的性能需求。
  9. 根据权利要求1至4任一所述的方法,其特征在于,所述终端中的处理器包含第一性能核心和第二性能核心,所述第一性能核心的性能高于所述第二性能核心的性能;
    所述操作系统确定所述任务标识对应的目标核心,包括:
    所述操作系统获取所述目标应用程序的当前应用场景和各个核心的负载;
    若所述当前应用场景属于第一应用场景且所述第一性能核心的负载小于负载阈值,所述操作系统则将所述第一性能核心确定为所述目标核心;
    若所述当前应用场景属于第二应用场景且所述第二性能核心的负载小于负载阈值,所述操作系统则将所述第二性能核心确定为所述目标核心;
    其中,所述第一应用场景对处理器的性能需求高于所述第二应用场景对处理器的性能需求。
  10. 一种处理器核心配置装置,其特征在于,所述装置包括目标应用程序模块和操作系统模块;
    所述目标应用程序模块,用于通过调用软件开发工具包SDK提供的第一应用程序编程接口API,向所述操作系统模块发送目标请求,所述目标请求携带有所述目标应用程序的目标任务的任务标识;
    所述操作系统模块,用于确定所述任务标识对应的目标核心;
    所述操作系统模块,还用于对所述目标任务和所述目标核心进行绑定,并将所述目标核心设置为隔离状态,所述隔离状态下所述目标核心上只允许运行绑定后的所述目标任务。
  11. 根据权利要求10所述的装置,其特征在于,所述目标应用程序模块,用于:
    获取待执行的候选任务的任务属性,所述任务属性用于指示所述候选任务是否与所述目标应用程序的运行流畅度相关;
    当所述任务属性用于指示所述候选任务与所述目标应用程序的运行流畅度相关时,将所述候选任务确定为所述目标任务;
    通过调用所述SDK提供的所述第一API,向所述操作系统发送携带有所述目标任务的任 务标识的目标请求。
  12. 根据权利要求11所述的装置,其特征在于,所述目标应用程序模块,用于:
    通过调用所述SDK提供的第二API,向所述操作系统发送调度请求,所述调度请求用于指示所述操作系统反馈待执行的所述候选任务的关键程度等级;
    接收所述操作系统反馈的所述关键程度等级;
    若所述关键程度等级高于预设等级阈值,则将所述候选任务确定为所述目标任务。
  13. 根据权利要求11所述的装置,其特征在于,所述候选任务的任务属性包括所述候选任务的任务标识;所述目标应用程序模块,用于:
    若所述候选任务的任务标识属于预设任务标识列表,则将所述候选任务确定为所述目标任务;
    其中,所述预设任务标识列表中包含与所述目标应用程序的运行流畅度相关的多个任务标识。
  14. 根据权利要求10至13任一项所述的装置,其特征在于,所述操作系统模块,用于:
    初始化多个控制组,所述多个控制组包括默认控制组和预留控制组,所述默认控制组用于指示默认的用于处理任务的处理器核心,所述预留控制组用于指示预留的用于处理所述目标任务的处理器核心;
    将所述预留控制组所指示的处理器核心确定为所述任务标识对应的目标核心。
  15. 根据权利要求14所述的装置,其特征在于,所述目标应用程序模块,用于当所述目标应用程序由前台运行切换至后台运行时,通过系统调用的方式调度所述默认控制组所指示的处理器核心运行所述目标任务。
  16. 根据权利要求10至13任一项所述的装置,其特征在于,所述终端中的处理器包含第一性能核心和第二性能核心,所述第一性能核心的性能高于所述第二性能核心的性能;
    所述操作系统模块,用于根据所述目标任务的最大处理性能需求在所述第一性能核心和所述第二性能核心中确定出所述目标核心。
  17. 根据权利要求10至13任一所述的装置,其特征在于,所述终端中的处理器包含第一性能核心和第二性能核心,所述第一性能核心的性能高于所述第二性能核心的性能;
    所述操作系统模块,用于:
    获取所述目标应用程序的当前应用场景;
    若所述当前应用场景属于第一应用场景,则将所述第一性能核心确定为所述任务标识对应的所述目标核心;
    若所述当前应用场景属于第二应用场景,则将所述第二性能核心确定为所述任务标识对应的所述目标核心;
    其中,所述第一应用场景对处理器的性能需求高于所述第二应用场景对处理器的性能需求。
  18. 根据权利要求10至13任一所述的装置,其特征在于,所述终端中的处理器包含第一性能核心和第二性能核心,所述第一性能核心的性能高于所述第二性能核心的性能;
    所述操作系统模块,用于:
    获取所述目标应用程序的当前应用场景和各个核心的负载;
    若所述当前应用场景属于第一应用场景且所述第一性能核心的负载小于负载阈值,则将 所述第一性能核心确定为所述目标核心;
    若所述当前应用场景属于第二应用场景且所述第二性能核心的负载小于负载阈值,则将所述第二性能核心确定为所述目标核心;
    其中,所述第一应用场景对处理器的性能需求高于所述第二应用场景对处理器的性能需求。
  19. 一种终端,其特征在于,所述终端包括处理器、与所述处理器相连的存储器,以及存储在所述存储器上的程序指令,所述处理器执行所述程序指令时实现如权利要求1至9任一所述的处理器核心配置方法。
  20. 一种计算机可读存储介质,其特征在于,其上存储有程序指令,所述程序指令被处理器执行时实现如权利要求1至9任一所述的处理器核心配置方法。
PCT/CN2019/095993 2018-09-26 2019-07-15 处理器核心配置方法、装置、终端及存储介质 WO2020063040A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201811122422.0 2018-09-26
CN201811122422.0A CN110955499B (zh) 2018-09-26 2018-09-26 处理器核心配置方法、装置、终端及存储介质

Publications (1)

Publication Number Publication Date
WO2020063040A1 true WO2020063040A1 (zh) 2020-04-02

Family

ID=69949537

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/095993 WO2020063040A1 (zh) 2018-09-26 2019-07-15 处理器核心配置方法、装置、终端及存储介质

Country Status (2)

Country Link
CN (1) CN110955499B (zh)
WO (1) WO2020063040A1 (zh)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112230964A (zh) * 2020-10-29 2021-01-15 Oppo广东移动通信有限公司 应用程序开发、应用程序运行方法、装置、设备及介质
CN112817428A (zh) * 2021-01-25 2021-05-18 广州虎牙科技有限公司 任务运行方法、装置、移动终端和存储介质
CN113760374B (zh) * 2021-08-30 2023-04-21 海信电子科技(深圳)有限公司 一种处理器的绑定方法、装置及电子设备
CN113842642B (zh) * 2021-09-29 2024-05-28 联想(北京)有限公司 一种为游戏应用分配资源的方法及电子设备
CN114510282B (zh) * 2021-12-15 2024-02-13 北京达佳互联信息技术有限公司 一种自动化应用的运行方法、装置、设备以及存储介质
CN115220932A (zh) * 2022-07-13 2022-10-21 小米汽车科技有限公司 通信进程执行方法、装置、车辆、可读存储介质及芯片

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102662740A (zh) * 2012-03-29 2012-09-12 迈普通信技术股份有限公司 非对称多核系统及其实现方法
CN103617071A (zh) * 2013-12-02 2014-03-05 北京华胜天成科技股份有限公司 一种资源独占及排它的提升虚拟机计算能力的方法及装置
CN106897132A (zh) * 2017-02-27 2017-06-27 郑州云海信息技术有限公司 一种服务器任务调度的方法以及装置

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9304570B2 (en) * 2011-12-15 2016-04-05 Intel Corporation Method, apparatus, and system for energy efficiency and energy conservation including power and performance workload-based balancing between multiple processing elements
US9329912B2 (en) * 2012-07-13 2016-05-03 Freescale Semiconductor, Inc. Core-affine processing on symmetric multiprocessing systems
CN108241527B (zh) * 2016-12-26 2021-10-08 成都理想境界科技有限公司 一种任务调度方法及电子设备
CN106879056A (zh) * 2017-02-23 2017-06-20 上海与德信息技术有限公司 一种终端的省电方法及装置
CN107517306B (zh) * 2017-07-31 2020-07-10 Oppo广东移动通信有限公司 资源配置方法及相关产品
CN107577185B (zh) * 2017-09-14 2019-10-25 浙江国自机器人技术有限公司 一种任务执行方法及基于多核处理器的控制器
CN108628652B (zh) * 2018-03-13 2023-02-28 Oppo广东移动通信有限公司 用户界面渲染方法、装置及终端

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102662740A (zh) * 2012-03-29 2012-09-12 迈普通信技术股份有限公司 非对称多核系统及其实现方法
CN103617071A (zh) * 2013-12-02 2014-03-05 北京华胜天成科技股份有限公司 一种资源独占及排它的提升虚拟机计算能力的方法及装置
CN106897132A (zh) * 2017-02-27 2017-06-27 郑州云海信息技术有限公司 一种服务器任务调度的方法以及装置

Also Published As

Publication number Publication date
CN110955499A (zh) 2020-04-03
CN110955499B (zh) 2022-11-18

Similar Documents

Publication Publication Date Title
WO2020063040A1 (zh) 处理器核心配置方法、装置、终端及存储介质
US11409547B2 (en) Method for rendering user interface and terminal
JP7100154B6 (ja) プロセッサコアのスケジューリング方法、装置、端末及び記憶媒体
WO2019228344A1 (zh) 资源配置方法、装置、终端及存储介质
WO2019228340A1 (zh) 程序优化方法、装置、终端及存储介质
CN110300328B (zh) 一种视频播放控制方法、装置及可读存储介质
WO2020063008A1 (zh) 资源配置方法、装置、终端及存储介质
CN109324903B (zh) 用于嵌入式系统的显示资源调度方法及装置
US20200258195A1 (en) Image Processing Method and Device
CN109522131A (zh) 资源配置方法、装置及设备
CN115640149A (zh) Rdma事件管理方法、设备及存储介质
CN115373869A (zh) 基于aar的进程处理方法、装置及电子设备
CN110278331B (zh) 系统属性的反馈方法、装置、终端及存储介质
CN109976876B (zh) 加速器管理方法和装置
WO2021102748A1 (zh) 应用下载方法、装置、移动终端及存储介质
US20220107841A1 (en) Electronic device and method for controlling electronic device

Legal Events

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

Ref document number: 19865888

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19865888

Country of ref document: EP

Kind code of ref document: A1