CN117271092A - Thread scheduling method, device, electronic equipment and storage medium - Google Patents

Thread scheduling method, device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117271092A
CN117271092A CN202311273751.6A CN202311273751A CN117271092A CN 117271092 A CN117271092 A CN 117271092A CN 202311273751 A CN202311273751 A CN 202311273751A CN 117271092 A CN117271092 A CN 117271092A
Authority
CN
China
Prior art keywords
thread
thread group
scheduling
threads
group
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN202311273751.6A
Other languages
Chinese (zh)
Inventor
徐嘉伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Vivo Mobile Communication Co Ltd
Original Assignee
Vivo Mobile Communication Co Ltd
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 Vivo Mobile Communication Co Ltd filed Critical Vivo Mobile Communication Co Ltd
Priority to CN202311273751.6A priority Critical patent/CN117271092A/en
Publication of CN117271092A publication Critical patent/CN117271092A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/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
    • G06F1/00Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
    • G06F1/26Power supply means, e.g. regulation thereof
    • G06F1/32Means for saving power
    • G06F1/3203Power management, i.e. event-based initiation of a power-saving mode
    • G06F1/3234Power saving characterised by the action undertaken
    • G06F1/329Power saving characterised by the action undertaken by task scheduling
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application discloses a thread scheduling method, a thread scheduling device, electronic equipment and a storage medium, and belongs to the technical field of electronics. The method comprises the following steps: acquiring at least one first thread group corresponding to a foreground service of a first process; determining at least one second thread group corresponding to background business of the first process based on the at least one first thread group and threads of the first process; scheduling threads in at least one first thread group or threads in a target thread group in at least one second thread group; wherein the scheduling priority of the target thread group is higher than the scheduling priority of the other thread groups than the target thread group in the at least one second thread group.

Description

Thread scheduling method, device, electronic equipment and storage medium
Technical Field
The application belongs to the technical field of electronics, and particularly relates to a thread scheduling method, a thread scheduling device, electronic equipment and a storage medium.
Background
Currently, with the increase of functions of applications in electronic devices, system resources of the electronic devices occupied by the applications, such as central processing units (Central Processing Unit, CPUs), are also increasing, which results in greater power consumption of the electronic devices.
In the related art, an electronic device may acquire an operation state of an application program that has been started, for example, a foreground operation or a background operation; and the application program in the background running is determined from the method, and the running of the application program in the background running is stopped by clearing the process corresponding to the application program in the background running, so that the power consumption of the electronic equipment is reduced.
However, in the application running in the foreground, some unnecessary background services, such as the listening service, consume power continuously in addition to the necessary foreground services, such as the display service, so that power consumption of the electronic device is still large.
Disclosure of Invention
An embodiment of the application aims to provide a thread scheduling method, a thread scheduling device, electronic equipment and a storage medium, which can reduce power consumption of the electronic equipment.
In a first aspect, an embodiment of the present application provides a thread scheduling method, where the thread scheduling method includes: acquiring at least one first thread group corresponding to a foreground service of a first process; determining at least one second thread group corresponding to background business of the first process based on the at least one first thread group and threads of the first process; scheduling threads in at least one first thread group or threads in a target thread group in at least one second thread group; wherein the scheduling priority of the target thread group is higher than the scheduling priority of the other thread groups than the target thread group in the at least one second thread group.
In a second aspect, an embodiment of the present application provides a thread scheduling apparatus, including: the device comprises an acquisition module, a determination module and a scheduling module. The acquisition module acquires at least one first thread group corresponding to a foreground service of the first process. The determining module is used for determining at least one second thread group corresponding to the background service of the first process based on the at least one first thread group and the threads of the first process acquired by the acquiring module. A scheduling module for scheduling threads in at least one first thread group or threads in a target thread group in at least one second thread group; wherein the scheduling priority of the target thread group is higher than the scheduling priority of the other thread groups than the target thread group in the at least one second thread group.
In a third aspect, embodiments of the present application provide an electronic device comprising a processor and a memory storing a program or instructions executable on the processor, which when executed by the processor, implement the steps of the method as described in the first aspect.
In a fourth aspect, embodiments of the present application provide a readable storage medium having stored thereon a program or instructions which when executed by a processor implement the steps of the method according to the first aspect.
In a fifth aspect, embodiments of the present application provide a chip, where the chip includes a processor and a communication interface, where the communication interface is coupled to the processor, and where the processor is configured to execute a program or instructions to implement a method according to the first aspect.
In a sixth aspect, embodiments of the present application provide a computer program product stored in a storage medium, the program product being executable by at least one processor to implement the method according to the first aspect.
In the embodiment of the present application, since the electronic device may distinguish the thread group corresponding to the foreground service and the thread group corresponding to the background service from the threads of the first process, when the electronic device performs thread scheduling, separate scheduling may be performed for the threads in the thread group corresponding to the foreground service or the thread group corresponding to the background service, that is, when the electronic device operates the first process, the electronic device may only operate the threads in the foreground service or the threads in the background service, that is, when the electronic device performs the operation corresponding to the first process, it is not necessary to completely operate all threads in the first process, and, based on the scheduling priority, the electronic device may schedule part of the services in the background service, without operating the complete background service, so power consumption of the electronic device is reduced.
Drawings
FIG. 1 is a schematic diagram of a relationship between processes and threads provided by embodiments of the present application;
FIG. 2 is one of the flowcharts of a thread scheduling method provided in an embodiment of the present application;
FIG. 3 is a second flowchart of a thread scheduling method according to an embodiment of the present application;
FIG. 4 is a third flowchart of a thread scheduling method according to an embodiment of the present application;
FIG. 5 is a diagram of an example of a thread scheduling method provided in an embodiment of the present application;
FIG. 6 is a diagram illustrating a second example of a thread scheduling method according to an embodiment of the present application;
FIG. 7 is a fourth flowchart of a thread scheduling method according to an embodiment of the present application;
FIG. 8 is a fifth flowchart of a thread scheduling method according to an embodiment of the present application;
FIG. 9 is a third diagram of an example of a thread scheduling method according to an embodiment of the present application;
FIG. 10 is a schematic diagram of a thread scheduler according to an embodiment of the present disclosure;
fig. 11 is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present application;
fig. 12 is a second schematic diagram of a hardware structure of an electronic device according to an embodiment of the present application.
Detailed Description
Technical solutions in the embodiments of the present application will be clearly described below with reference to the drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present application are within the scope of the protection of the present application.
The terms first, second and the like in the description and in the claims, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the terms so used are interchangeable under appropriate circumstances such that the embodiments of the application are capable of operation in sequences other than those illustrated or otherwise described herein, and that the objects identified by "first," "second," etc. are generally of a type and do not limit the number of objects, for example, the first object may be one or more. Furthermore, in the description and claims, "and/or" means at least one of the connected objects, and the character "/", generally means that the associated object is an "or" relationship.
The terms "at least one," "at least one," and the like in the description and in the claims of the present application mean that they encompass any one, any two, or a combination of two or more of the objects. For example, at least one of a, b, c (item) may represent: "a", "b", "c", "a and b", "a and c", "b and c" and "a, b and c", wherein a, b, c may be single or plural. Similarly, the term "at least two" means two or more, and the meaning of the expression is similar to the term "at least one".
The following explains the terms of art provided in the embodiments of the present application.
The process comprises the following steps: a process is an instance of execution in a computer, which is the basic unit of application execution. Each process has its own independent memory space, code, data, system resources, etc. The operation system completes the operations such as data exchange, task allocation and the like among different processes through scheduling and communication among the processes; the program in the computer is also one-time operation activity on a certain data set, is a basic unit for the system to allocate and schedule resources, and is the basis of the structure of the operating system. In early process-oriented computer architecture, a process is the basic execution entity of a program; in contemporary thread-oriented computer architectures, the process is a container for the threads. A program is a description of instructions, data, and their organization, and a process is an entity of the program; when a plurality of programs are executed, system resources need to be shared, so that the programs are in a mutually restricted relation in the execution process, and the execution of the programs is characterized by intermittence. These features occur during the execution of the program, and are dynamic, whereas the conventional program itself is a set of instructions, which is a static concept, and cannot describe the execution of the program in the memory, i.e. we cannot see when it is executed, when it is stopped, and when it is related to other executing programs from the literal aspect of the program, so this static concept of the program cannot reflect the feature of the concurrent execution of the program. To deeply describe the nature of the program's dynamic execution Process, a "Process" concept was introduced.
Process group: each process group has a lead process. A process group is a collection of one or more processes, typically associated with a set of jobs, that can accept various signals from the same electronic device.
Thread: a thread is an execution unit in a process, which is a branch of a process that shares memory and system resources with the process to which it belongs. A process may include multiple threads, each of which is responsible for executing a portion of the tasks within the process, and may more efficiently utilize processor resources and memory, which is the smallest unit that an operating system can perform operational scheduling. It is included in the process and is the actual unit of operation in the process. One thread refers to a single sequential control flow in a process, multiple threads may be concurrent in a process, and each thread performs different tasks in parallel. Lightweight processes (lightweight processes) are also called in Unix System V and SunOS, but lightweight processes refer more to kernel threads (kernel threads) and user threads (user threads) are called threads.
Thread group: a process group is a collection of one or more threads.
Foreground service: foreground services refer to services that a computer processes as perceived by a user, and include: user input, output graphics, audio, vibration. He is commonly completed by multiple threads in multiple processes. There may be 0 to N threads for a process to handle foreground traffic, N being a positive integer.
Background business: background services refer to services that are not perceived by a computer processing user, such as: background data capture, position tracking, file monitoring and the like. There may be 0 to N threads for one process to handle background traffic.
Illustratively, as shown in FIG. 1, the relationships between the processes, threads, foreground traffic, and background traffic described above are explained.
Taking a process as an example, fig. 1 includes a process 1, where the process 1 includes threads 1 to 6, and the threads 1 and 2 are threads corresponding to a foreground service. The threads 3 to 6 are threads corresponding to background services, and the threads corresponding to the foreground services and the threads corresponding to the background services are mutually independent; a process is a basic unit of resource allocation. All resources related to the process are recorded in the process control block PCB. To indicate that the process owns or is using these resources. In addition, the process is also the scheduling unit of the preemptive handler, which has a complete virtual address space. When a process is scheduled, different processes have different virtual address spaces, and different threads within the same process share the same address space. Corresponding to a process, a thread is independent of resource allocation, belongs to a certain process, and shares the process's resources with other threads in the process. Threads consist only of the relevant stack (system stack or user stack) registers and thread control tables (Thread Control Block, TCB). Registers may be used to store local variables within a thread, but not related variables for other threads. Typically, a process may contain several threads that can utilize the resources owned by the process. In an operating system that introduces threads, it is common to use processes as the basic unit for allocating resources, and threads as the basic unit for running and scheduling independently. Because the thread is smaller than the process and basically does not own the system resource, the cost for dispatching the thread is much smaller, and the concurrent execution degree among a plurality of programs in the system can be effectively improved, so that the utilization rate and throughput of the system resource are obviously improved. Thus, the general-purpose operating system introduced in recent years introduces threads to further increase the concurrency of the system and is considered as an important index of the modern operating system.
The thread scheduling method, the thread scheduling device, the electronic equipment and the storage medium provided by the embodiment of the application are described in detail below through specific embodiments and application scenes thereof with reference to the accompanying drawings.
At present, electronic devices have become an indispensable tool in life of people, and with the development of electronic devices, applications in electronic devices are increasing, and these application programs provide convenient and fast services for users, such as watching television, navigating, watching electronic books, and the like. With the continued expansion of application functionality and the increasing demand of users, many applications have begun to become large and complex, thereby requiring the use of more computing power and consuming more battery power in electronic devices. Some complex applications not only provide basic services, such as instant messaging applications, etc., but may also provide many background services, such as background data crawling, advertisement pushing, location tracking, etc., in addition to normal chat functions, which typically require significant computing power and battery consumption.
The existing background power saving technology aims at limiting the background use resources under the background condition of an application program. For example, the electronic device may stop running the background running application by clearing a process corresponding to the background running application, so as to reduce power consumption of the electronic device. However, when an application is running in the foreground, in addition to the necessary functions, the foreground running application consumes power, and some background services that are not currently needed also consume power continuously, for example, background data grabbing. Resulting in greater power consumption of the electronic device.
In the thread scheduling method, the device, the electronic equipment and the storage medium provided by the embodiment of the application, since the electronic equipment can distinguish the thread group corresponding to the foreground service and the thread group corresponding to the background service from the threads of the first process, when the electronic equipment performs thread scheduling, separate scheduling can be performed on the threads in the thread group corresponding to the foreground service or the thread group corresponding to the background service, that is, when the electronic equipment operates the first process, the electronic equipment can only operate the threads in the foreground service or the threads in the background service, that is, when the electronic equipment performs the operation corresponding to the first process, the electronic equipment does not need to completely operate all the threads in the first process, and based on the scheduling priority, the electronic equipment can schedule part of services in the background service and does not need to operate the complete background service, so the power consumption of the electronic equipment is reduced.
The execution body of the thread scheduling method provided by the embodiment of the application may be a thread scheduling device, and the thread scheduling device may be an electronic device or a functional module in the electronic device. The technical solution provided in the embodiments of the present application will be described below by taking an electronic device as an example.
The embodiment of the application provides a thread scheduling method, and fig. 2 shows a flowchart of the thread scheduling method provided by the embodiment of the application. As shown in fig. 2, the thread scheduling method provided in the embodiment of the present application may include the following steps 201 to 203.
Step 201, the electronic device obtains at least one first thread group corresponding to a foreground service of a first process.
In this embodiment of the present application, the electronic device may obtain, in a process of running a first process of a first application, at least one first thread group corresponding to a foreground service of the first process.
Alternatively, in the embodiment of the present application, the first application may be any application in the electronic device. Such as a game-like application, an instant messaging-like application, or a video-like application.
Alternatively, in the embodiment of the present application, the first process may be any type of process. Such as displaying a picture process or playing a video process.
Optionally, in an embodiment of the present application, the foreground service may include at least one of the following: display traffic, page skip traffic, page data refresh traffic, etc. Specifically, the method can be determined according to actual use requirements, and the embodiment of the application is not limited.
In this embodiment of the present application, the foreground service may include at least one first service, where each first thread group in the at least one first thread group corresponds to one first service.
For example, assuming that the foreground service is a picture display service, the first thread group is a plurality of threads that need to be scheduled by the electronic device to display the picture.
In the embodiment of the present application, in a process of running a first process of a first application, an electronic device may obtain at least one first thread group corresponding to a foreground service of the first process through a thread wake-up procedure corresponding to the foreground service.
In an embodiment of the present application, after the electronic device obtains the at least one first thread group, the electronic device may store the at least one first thread group.
Illustratively, the electronic device may store the at least one first thread group in a Memory area in the electronic device, such as a Read-Only Memory (ROM); alternatively, the electronic device may store the at least one first thread group in the cloud server.
It should be noted that, since the electronic device stores the at least one first thread group, if the electronic device triggers the first process again, the electronic device may directly obtain the at least one first thread group through the stored at least one first thread group.
Step 202, the electronic device determines at least one second thread group corresponding to the background service of the first process based on the at least one first thread group and the threads of the first process.
In this embodiment of the present application, the thread of the first process includes: the at least one first thread group and the at least one second thread group.
It will be appreciated that the threads of the first process described above are all threads required by the electronic device to run the first process.
In this embodiment of the present application, in a process of running a first process of a first application, an electronic device may record all threads corresponding to the first process.
For example, the electronic device records that all threads corresponding to the first process are: and marking all threads corresponding to the first process, so that the electronic equipment can identify threads corresponding to different processes.
Illustratively, the above-mentioned indicia may include at least one of: numerical indicia, alphabetic indicia, special symbol indicia, and the like. Specifically, the method can be determined according to actual use conditions, and the embodiment of the application is not limited.
With reference to fig. 1, it may be understood that, after the electronic device acquires all threads of the first process, the electronic device only needs to determine at least one first thread group corresponding to a foreground service in the first process, and the rest is at least one second thread group corresponding to a background service.
Optionally, in the embodiment of the present application, after determining at least one second thread group corresponding to the background service of the first process, the electronic device may store the at least one second thread group.
Illustratively, the electronic device may store the at least one second thread group in a Memory area in the electronic device, such as a Read-Only Memory (ROM); alternatively, the electronic device may store the at least one second thread group in the cloud server.
It should be noted that, since the electronic device stores the at least one second thread group, if the electronic device triggers the first process again, the electronic device may directly obtain the at least one second thread group through the stored at least one second thread group.
Step 203, the electronic device schedules threads in at least one first thread group or schedules threads in a target thread group in at least one second thread group.
In this embodiment of the present application, the scheduling priority of the target thread group is higher than the scheduling priority of the other thread groups except the target thread group in the at least one second thread group.
It is understood that, when the electronic device performs thread scheduling, the electronic device may schedule threads in at least one first thread group separately; alternatively, the electronic device may schedule threads in the at least one second thread group separately. That is, for either the foreground service or the background service, the electronic device may operate only one of the services.
Further, when the electronic device performs thread scheduling of the background service, the electronic device may schedule a part of the background threads in the background service according to the scheduling priority, and further, the electronic device may only execute a part of the background service in the background service.
In the thread scheduling method provided in the embodiment of the present application, since the electronic device may distinguish the thread group corresponding to the foreground service and the thread group corresponding to the background service from the threads of the first process, when the electronic device performs thread scheduling, separate scheduling may be performed for the threads in the thread group corresponding to the foreground service or the thread group corresponding to the background service, that is, when the electronic device operates the first process, the electronic device may only operate the threads in the foreground service or the threads in the background service, that is, when the electronic device performs the operation corresponding to the first process, it is not necessary to completely operate all threads in the first process, and, based on the scheduling priority, the electronic device may schedule part of the services in the background service, without operating the complete background service, so power consumption of the electronic device is reduced.
Alternatively, in the embodiment of the present application, as shown in fig. 3 in conjunction with fig. 2, the above step 201 may be specifically implemented by the following steps 201a and 201 b.
Step 201a, the electronic device obtains thread information of at least two first threads corresponding to a foreground service of the first process.
In this embodiment of the present application, the thread information of the first thread includes at least one of the following: the thread name of the first thread, the service corresponding to the thread and the thread data.
For example, the thread data is data carried by a thread, for example, the foreground service is page data in a refresh page, and the electronic device may perform page refresh based on the page data carried by the thread.
Optionally, in an embodiment of the present application, the at least two first threads include a third thread and a fourth thread described below.
In this embodiment of the present application, the electronic device may obtain, according to a foreground service flow of the first process, at least two first threads corresponding to the foreground service, so as to obtain information of the at least two first threads.
For example, after determining at least two first threads corresponding to the foreground service, the electronic device may obtain, from a configuration file stored in the electronic device, thread information of each first thread based on a thread identifier of each first thread of the at least two first threads.
Step 201b, the electronic device constructs at least one first thread group based on the thread information.
In this embodiment of the present application, after obtaining the thread information of each first thread in at least two first threads, the electronic device may perform link construction processing on each first thread based on the thread information of each first thread, so as to obtain at least one first thread group.
Illustratively, the link is constructed such that the electronic device constructs at least one tree structure based on the thread information to obtain at least one first thread group. Wherein each of the at least one first thread group corresponds to a tree structure.
The tree structure may be a binary tree, for example.
In the embodiment of the application, the electronic device can construct at least one first thread group according to the thread information of the first thread, so that the accuracy of the electronic device in determining the thread corresponding to the foreground service is ensured.
Alternatively, in the embodiment of the present application, as shown in fig. 4 in conjunction with fig. 2, the above step 201 may be specifically implemented by the following step 201 c.
Step 201c, under the condition that a first input for triggering a first process is received, the electronic device acquires at least one third thread group of a first foreground service corresponding to the first input, and acquires at least one fourth thread group of a second foreground service corresponding to an execution result of a target operation.
In this embodiment of the present application, the at least one first thread group includes at least one third thread group and at least one fourth thread group, and the target operation is an operation corresponding to the first input.
Alternatively, the first input may be any one of the following: click input, long press input, preset track input or slide input of the first application by the user, and the like. Specifically, the method can be determined according to actual use conditions, and the embodiment of the application is not limited.
In this embodiment of the present application, in a process of running a first process, an electronic device may obtain, according to a thread wake-up procedure corresponding to the first process, at least one third thread group of a first foreground service corresponding to a first input.
Illustratively, the thread wake-up procedure corresponding to the first process is: the electronic device may begin with a thread corresponding to the first input until the thread corresponding to the electronic device receiving the first input ends.
The method includes the steps that a source thread is used as a source, a foreground thread adjacent to the source thread is awakened, the foreground threads awakened by the source thread are awakened to the foreground threads adjacent to the source thread, and the awakened threads are marked until the electronic equipment receives the thread corresponding to the first input and ends, so that at least one third thread corresponding to a first foreground service is obtained.
In this embodiment of the present application, after obtaining at least one third thread, the electronic device may construct an input wakeup link based on the at least one third thread, so as to obtain at least one third thread group corresponding to a foreground service of an input process.
Illustratively, as shown in FIG. 5, a user operates a touch screen, the touch screen device triggers a hardware interrupt, at which point input driver thread will first wake up and be used to parse the device's signal, where the input wake up link begins to be constructed, at which point input driver thread is marked as the foreground root node. Input driver thread wakes up the Input Reader thread, encapsulates the parsed data, and facilitates the transfer of the data of the subsequent Input event to the application. At this point Input driver thread sets the Input Reader to its own child node and is marked as an Input wakeup link thread. The Input Reader thread wakes up the Input Dispatcher thread and is used for selecting a foreground interface to dispatch the event. At this point the Input Reader sets the Input Dispatcher as its own child node and is marked as an Input wakeup link thread. The Input event is dispatched to a plurality of receiving objects, typically foreground applications, which are awakened by the Input Dispatcher thread. At this time, the Input Dispatcher sets the thread of the receiving object as its own child node and is marked as the Input wakeup link thread. Upon receiving an object handling event, a User Interface (UI) thread or other worker thread may be awakened to handle the transaction. The awakened thread is taken as a child node of the electronic device and marked as an input awakening link, so that the electronic device can obtain at least one third thread group corresponding to the foreground service of the input process.
Optionally, in the embodiment of the present application, after the electronic device performs the target operation corresponding to the first input, at least one fourth thread group of the second foreground service corresponding to the execution result is obtained based on the execution result of the target operation.
Optionally, in an implementation of the present application, the foregoing execution result may include at least one of the following: image output, audio output, and jarring output.
In this embodiment of the present application, after the electronic device performs the target operation corresponding to the first input, the electronic device may determine, according to a thread wake-up procedure corresponding to an execution result of the target operation, at least one fourth thread corresponding to a foreground service of the execution result.
Illustratively, taking the first process as an image output, the operation corresponding to the electronic device is to display the image. The thread wake-up flow corresponding to the execution result is as follows: the source of the output is a thread for displaying images of the electronic equipment, the thread is taken as the source, a foreground thread adjacent to the thread is awakened until the thread of a driving module of a screen of the electronic equipment is awakened, and at least one fourth thread corresponding to the foreground service is obtained.
Illustratively, as shown in FIG. 6, taking the first Thread as an example of image output, when one Thread wakes up the other Thread, e.g., thread1 wakes up Thread12, thread1 is added to the list of waken child nodes of Thread 12. Thread2 wakes up Thread 13, then Thread2 is added to the list of waken child nodes of Thread 13. Thread12 and Thread 13 wake up App 1-Thread 1, and Thread12 and Thread 13 are added to App 1-Thread 1's list of awakened child nodes. App 1-thread 1 and App 2-thread2 wake up Graphic service thread, app 1-thread 1 and App 2-thread2 are added to the list of awakened child nodes of Graphic service thread. And similarly Graphic service thread is added to the list of awakened child nodes of Lcm hal thread. Lcm hal thread is added to the list of awakened child nodes of Lcm driver thread. The Lcm driver thread child node is used to wake up the display device, at which point Lcm driver thread is marked as the output link root node. Starting back from Lcm driver thread, all the awakened child node lists are traversed and all child node threads are marked as foreground business threads.
In the embodiment of the application, the electronic device can save the wake-up link of the foreground service corresponding to the input process and the output process of the first input through the input process and the output process of the first input, so that the accuracy of the electronic device in determining at least one first thread group corresponding to the first process is improved.
Alternatively, in the embodiment of the present application, as shown in fig. 7 in conjunction with fig. 2, the above step 202 may be specifically implemented by the following steps 202a and 202 b.
Step 202a, the electronic device determines a second thread corresponding to the background service of the first process from the threads of the first process.
In this embodiment of the present application, after obtaining an input wakeup link corresponding to an input process and an output wakeup link corresponding to an output, the electronic device determines that all threads of a first process do not belong to threads of the input wakeup link and the output wakeup link as threads of a background service of the first process.
Step 202b, the electronic device groups the second threads corresponding to the background service of the first process according to the wake-up capability of the second threads, so as to obtain at least one second thread group.
Optionally, in an embodiment of the present application, the thread of the background service of the first process includes an orphan thread and a non-orphan thread.
The orphan thread is a thread that does not wake up any other thread, and the non-orphan thread is a thread that can wake up other threads.
In this embodiment of the present application, the electronic device may group the threads of the background service to obtain at least one second thread group based on whether the threads of the background service are orphan threads.
In the embodiment of the application, the electronic equipment can determine the thread corresponding to the background service from all threads based on the thread processing flow of the foreground service, so that the accuracy of the electronic equipment in determining the thread of the background service is improved.
Alternatively, in the embodiment of the present application, the above step 202b may be specifically implemented by the following steps 202b1 and 202b 2.
Step 202b1, the electronic device determines a thread having a wake-up function from among the second threads as a thread in a third thread group.
In this embodiment of the present application, the electronic device may determine, as the thread in the third thread group, the thread having the wake-up function in the at least one second thread group.
In this embodiment of the present application, the thread with the wake-up function is the non-orphan thread.
In this embodiment, for one thread in one of the at least one second thread group, the electronic device may determine whether the thread is an orphan thread according to whether the one thread has an adjacent thread.
Illustratively, in a second thread group, if there is at least one connection relationship between other threads and the one thread, determining that the one thread is a non-orphan thread; in a second thread group, if there is no connection relationship between other threads and the thread, determining that the thread is an orphan thread.
It can be appreciated that the electronic device may determine, by the above method, a wake-up function corresponding to each of the second threads.
Step 202b2, the electronic device determines a thread having no wake-up function from among the second threads as a thread in the fourth thread group.
In this embodiment of the present application, the at least one second thread group includes a third thread group or a fourth thread group, and a scheduling priority of the third thread group is higher than a scheduling priority of the fourth thread group.
It should be noted that, the specific implementation process may be detailed in the above embodiments, and in order to avoid repetition, the description is omitted here.
In this embodiment of the present application, the scheduling priority is preset by a user. For example, the scheduling priority of the non-orphan thread group is higher than the scheduling priority of the orphan thread group.
In the embodiment of the application, the electronic device can perform grouping processing on each thread in at least one second thread group based on the wake-up function of the thread in the second thread, and allocate the scheduling priority, so that the electronic device can schedule part of the services in the background service based on the scheduling priority, the complete background service is not required to be operated, and the power consumption of the electronic device is reduced.
Alternatively, in the embodiment of the present application, as shown in fig. 8, the "scheduling the thread in the target thread group in the at least one second thread group" in the step 203 may be specifically implemented by the following step 203a or step 203 b.
Step 203a, when the resource occupancy rate of the CPU in the electronic device is greater than or equal to the first threshold, scheduling the threads in the target thread group, and freezing the other thread groups except the target thread group in at least one second thread group.
Note that, the freezing means that the other thread groups except the target thread group in the at least one second thread group are not scheduled any more.
For example, in the case where the resource occupancy rate of the CPU is greater than or equal to 30%, the electronic device may freeze the background process according to the above-described scheduling priority, where the priority is lower, the higher the priority is frozen until the resource occupancy rate of the CPU is less than 30% or the other thread groups except the target thread group in the at least one second thread group are all frozen.
In step 203b, when the resource occupancy rate of the CPU in the electronic device is smaller than the first threshold, the electronic device aligns the scheduling time of each thread in the target thread group, and schedules the threads in the target thread group according to the aligned scheduling time.
In this embodiment of the present application, the electronic device may align, according to a preset window time, a scheduling time of each thread in the target thread group when a resource occupancy rate of a CPU in the electronic device is less than a first threshold, and schedule the threads in the target thread group according to the aligned scheduling time.
Optionally, in the embodiment of the present application, the electronic device may align, according to a preset window time, a scheduling time of each thread in the at least one second thread group when a resource occupancy rate of a CPU in the electronic device is less than a first threshold, and schedule each thread in the at least one second thread group according to the aligned scheduling time.
In the embodiment of the application, the electronic device can perform different processes on the threads in the at least one second thread group corresponding to the background service under the condition that the CPU is in different resource occupancy rates, so that the flexibility of the electronic device in processing the threads in the at least one second thread group is improved.
Alternatively, in the embodiment of the present application, the "the electronic device aligns the scheduling time of each thread in the target thread group" in the step 203b may be specifically implemented by the following steps 203b1 and 203b 2; and "according to the aligned scheduling time, the thread of the scheduling target thread group" in the above step 203b may be specifically implemented by the following step 203b 3.
Step 203b1, the electronic device obtains a window time corresponding to the scheduling time of each thread in the target thread group.
In this embodiment of the present application, the window time corresponding to the scheduling time of each thread in the target thread group is a preset window time.
Illustratively, window times, i.e., the earliest and latest times of scheduling, the electronic device may adjust threads that would otherwise need to be scheduled on time to be scheduled in a certain period. For example, the window time may be 30% of the scheduling period.
Illustratively, taking one thread of the target thread group as an example, assume that the actual scheduling time of the one thread is 6:00, the window time corresponding to the actual scheduling time of the one thread may be 6:00 to 6:05 minutes.
Step 203b2, the electronic device determines, as the first scheduling time, a scheduling time of each thread to correspond to a rear endpoint of the window time intersection.
It will be appreciated that the window time corresponding to the scheduling time of each thread in the target thread group is a time period. For each thread, the time period corresponding to the window time includes a start time point and an end time point, so the electronic device may determine, as the first scheduling time, the scheduling time of each thread corresponds to the end time of the window time intersection.
Illustratively, as shown in FIG. 9, assume that the actual scheduling time for thread 1 is 6:00, thread 1 corresponds to a window time of 6:00 to 6:05; the actual scheduling time for thread 2 is 5:59, the window time corresponding to thread 2 is 5:59 to 6:03; the actual scheduling time for thread 3 is 6:02, the window time corresponding to thread 3 is 6:02 to 6:10, as such, the electronic device may compare 6:03 is determined as the scheduling time of the CPU, i.e., the first scheduling time described above.
In the embodiment of the application, after determining the window time, the electronic device may perform batch scheduling according to the window time.
Illustratively, each thread of the background service has a window time, and when aligned, an intersection of the window times of the threads needing to be scheduled is taken down, and the end point of the intersection is used as the starting point time of CPU scheduling.
In this embodiment of the present application, after each thread in the target thread group is scheduled, the electronic device may start setting the scheduling time of the next time through the method described above. In this way, the electronic device can automatically form a scheduling period with the least common multiple of each thread scheduling period multiplied by (1+first scheduling time) as the CPU.
Step 203b3, when the system time of the electronic device reaches the first scheduling time, the electronic device schedules the threads in the target thread group.
It should be noted that, the electronic device may perform the same processing on each thread in the at least one second thread group through the step 203b1 and the step 203b2, so as to determine the second scheduling time of the at least one second thread group, and schedule the thread in the at least one second thread group if the system time of the electronic device reaches the second scheduling time.
In the embodiment of the application, the electronic device can set the same scheduling time for each thread in the target thread group, so that batch scheduling can be realized, the scheduling times are reduced, the wake-up times of the CPU are reduced, and the power consumption of the CPU of the electronic device is further reduced.
It should be noted that, in the thread scheduling method provided in the embodiment of the present application, the execution body may be a thread scheduling device, or an electronic device, or may also be a functional module or entity in the electronic device. In the embodiment of the present application, a thread scheduling device provided in the embodiment of the present application is described by taking a method for executing a thread scheduling by a thread scheduling device as an example.
Fig. 10 shows a schematic diagram of one possible architecture of a thread scheduling apparatus involved in an embodiment of the present application. As shown in fig. 10, the thread scheduling apparatus 70 may include: an acquisition module 71, a determination module 72 and a scheduling module 73.
The acquiring module 71 is configured to acquire at least one first thread group corresponding to a foreground service of a first process. A determining module 72, configured to determine, based on the at least one first thread group and threads of the first process, at least one second thread group corresponding to background services of the first process. A scheduling module 73 for scheduling threads in at least one first thread group or in at least one second thread group; wherein the scheduling priority of the target thread group is higher than the scheduling priority of the other thread groups than the target thread group in the at least one second thread group.
In a possible implementation manner, the obtaining module 71 is specifically configured to obtain, in a case where a first input for triggering the first process is received, at least one third thread group of a first foreground service corresponding to the first input, and at least one fourth thread group of a second foreground service corresponding to an execution result of the target operation; wherein the at least one first thread group includes the at least one third thread group and the at least one fourth thread group, the target operation being an operation corresponding to the first input.
In one possible implementation manner, the obtaining module 71 is specifically configured to obtain thread information of at least two first threads corresponding to a foreground service of a first process; constructing at least one first thread group based on the thread information; wherein the thread information of the first thread includes at least one of: the thread name of the first thread, the service corresponding to the thread and the thread data.
In one possible implementation manner, the scheduling module 73 is specifically configured to schedule the threads in the target thread group and freeze the other thread groups in the at least one second thread group except the target thread group when the resource occupancy rate of the central processing unit CPU of the electronic device is greater than or equal to the first threshold; or aligning the scheduling time of each thread in the target thread group under the condition that the resource occupancy rate of the CPU is smaller than the first threshold value, and scheduling the threads in the target thread group according to the aligned scheduling time.
In one possible implementation manner, the scheduling module 73 is specifically configured to obtain a window time corresponding to a scheduling time of each thread in the target thread group; determining a rear end point of a window time intersection corresponding to the scheduling time of each thread as a first scheduling time; and scheduling the threads in the target thread group under the condition that the system time of the electronic device reaches the first scheduling time.
In one possible implementation manner, the determining module 72 is specifically configured to determine, from threads of the first process, a second thread corresponding to a background service of the first process; and grouping the second threads corresponding to the background service of the first process according to the wake-up capability of the second threads to obtain at least one second thread group.
7. The method of claim 1, wherein the determining module is specifically configured to determine a thread having a wake-up function in the second thread as a thread in the third thread group; determining the thread which does not have the wake-up function in the second thread as the thread in the fourth thread group; wherein the at least one second thread group comprises a third thread group or a fourth thread group, and the scheduling priority of the third thread group is higher than the scheduling priority of the fourth thread group.
The embodiment of the application provides a thread scheduling device, because the thread scheduling device can distinguish a thread group corresponding to a foreground service and a thread group corresponding to a background service from threads of a first process, when the thread scheduling device performs thread scheduling, separate scheduling can be performed on the threads in the thread group corresponding to the foreground service or the thread group corresponding to the background service, that is, when the thread scheduling device operates the first process, the thread scheduling device can only operate the threads in the foreground service or the threads in the background service, that is, when the thread scheduling device performs operations corresponding to the first process, the thread scheduling device does not need to completely operate all threads in the first process, and moreover, the thread scheduling device can schedule part of services in the background service based on the scheduling priority, and does not need to operate the complete background service, so that the power consumption of the thread scheduling device is reduced.
The thread scheduling device in the embodiment of the application may be an electronic device, or may be a component in the electronic device, for example, an integrated circuit or a chip. The electronic device may be a terminal, or may be other devices than a terminal. By way of example, the mobile electronic device may be a mobile phone, tablet, notebook, palmtop, vehicle-mounted electronic device, mobile internet appliance (Mobile Internet Device, MID), augmented reality (augmented reality, AR)/Virtual Reality (VR) device, robot, wearable device, ultra-mobile personal computer, UMPC, netbook or personal digital assistant (personal digital assistant, PDA), etc., but may also be a server, network attached storage (Network Attached Storage, NAS), personal computer (personal computer, PC), television (TV), teller machine or self-service machine, etc., and the embodiments of the present application are not limited in particular.
The thread scheduling device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiments of the present application.
The thread scheduling device provided in the embodiment of the present application can implement each process implemented by the above method embodiment, and in order to avoid repetition, details are not repeated here.
Optionally, as shown in fig. 11, the embodiment of the present application further provides an electronic device 90, including a processor 91 and a memory 92, where a program or an instruction capable of running on the processor 91 is stored in the memory 92, and the program or the instruction implements each step of the above-mentioned thread scheduling method embodiment when executed by the processor 91, and the steps can achieve the same technical effect, so that repetition is avoided, and no further description is given here.
The electronic device in the embodiment of the application includes the mobile electronic device and the non-mobile electronic device described above.
Fig. 12 is a schematic hardware structure of an electronic device implementing an embodiment of the present application.
The electronic device 100 includes, but is not limited to: radio frequency unit 101, network module 102, audio output unit 103, input unit 104, sensor 105, display unit 106, user input unit 107, interface unit 108, memory 109, and processor 110.
Those skilled in the art will appreciate that the electronic device 100 may further include a power source (e.g., a battery) for powering the various components, and that the power source may be logically coupled to the processor 110 via a power management system to perform functions such as managing charging, discharging, and power consumption via the power management system. The electronic device structure shown in fig. 12 does not constitute a limitation of the electronic device, and the electronic device may include more or less components than illustrated, or may combine certain components, or may be arranged in different components, which are not described in detail herein.
The processor 110 is configured to obtain at least one first thread group corresponding to a foreground service of a first process; determining at least one second thread group corresponding to background business of the first process based on the at least one first thread group and threads of the first process; scheduling threads in at least one first thread group or threads in a target thread group in at least one second thread group; wherein the scheduling priority of the target thread group is higher than the scheduling priority of the other thread groups than the target thread group in the at least one second thread group.
The embodiment of the application provides an electronic device, because the electronic device can distinguish a thread group corresponding to a foreground service and a thread group corresponding to a background service from threads of a first process, when the electronic device performs thread scheduling, separate scheduling can be performed on the threads in the thread group corresponding to the foreground service or the thread group corresponding to the background service, that is, when the electronic device operates the first process, the electronic device can only operate the threads in the foreground service or the threads in the background service, that is, when the electronic device performs operations corresponding to the first process, the electronic device does not need to completely operate all threads in the first process, and based on the scheduling priority, the electronic device can schedule part of services in the background service without operating the complete background service, so that power consumption of the electronic device is reduced.
Optionally, in the embodiment of the present application, the processor 110 is specifically configured to, when receiving a first input for triggering a first process, obtain at least one third thread group of a first foreground service corresponding to the first input, and obtain at least one fourth thread group of a second foreground service corresponding to an execution result of a target operation; wherein the at least one first thread group includes at least one third thread group and at least one fourth thread group, and the target operation is an operation corresponding to the first input.
Optionally, in the embodiment of the present application, the processor 110 is specifically configured to obtain thread information of at least two first threads corresponding to a foreground service of a first process; constructing at least one first thread group based on the thread information; wherein the thread information of the first thread includes at least one of: the thread name of the first thread, the service corresponding to the thread and the thread data.
Optionally, in the embodiment of the present application, the processor 110 is specifically configured to schedule a thread in the target thread group and freeze other thread groups in at least one second thread group except the target thread group when a resource occupancy rate of a central processing unit CPU of the electronic device is greater than or equal to a first threshold; or aligning the scheduling time of each thread in the target thread group under the condition that the resource occupancy rate of the CPU is smaller than the first threshold value, and scheduling the threads in the target thread group according to the aligned scheduling time.
Optionally, in the embodiment of the present application, the processor 110 is specifically configured to obtain a window time corresponding to a scheduling time of each thread in the target thread group; determining a rear end point of a window time intersection corresponding to the scheduling time of each thread as a first scheduling time; and scheduling the threads in the target thread group under the condition that the system time of the electronic device reaches the first scheduling time.
Optionally, in the embodiment of the present application, the processor 110 is specifically configured to determine, from threads of a first process, a second thread corresponding to a background service of the first process; and grouping the second threads corresponding to the background service of the first process according to the wake-up capability of the second threads to obtain at least one second thread group.
Optionally, in the embodiment of the present application, the processor 110 is specifically configured to determine a thread having a wake-up function in the second thread as a thread in the third thread group; determining the thread which does not have the wake-up function in the second thread as the thread in the fourth thread group; wherein the at least one second thread group comprises a third thread group or a fourth thread group, and the scheduling priority of the third thread group is higher than the scheduling priority of the fourth thread group.
The electronic device provided in the embodiment of the present application can implement each process implemented by the above method embodiment, and can achieve the same technical effects, so that repetition is avoided, and details are not repeated here.
The beneficial effects of the various implementation manners in this embodiment may be specifically referred to the beneficial effects of the corresponding implementation manners in the foregoing method embodiment, and in order to avoid repetition, the description is omitted here.
It should be appreciated that in embodiments of the present application, the input unit 104 may include a graphics processor (Graphics Processing Unit, GPU) 1041 and a microphone 1042, the graphics processor 1041 processing image data of still pictures or video obtained by an image capturing device (e.g., a camera) in a video capturing mode or an image capturing mode. The display unit 106 may include a display panel 1061, and the display panel 1061 may be configured in the form of a liquid crystal display, an organic light emitting diode, or the like. The user input unit 107 includes at least one of a touch panel 1071 and other input devices 1072. The touch panel 1071 is also referred to as a touch screen. The touch panel 1071 may include two parts of a touch detection device and a touch controller. Other input devices 1072 may include, but are not limited to, a physical keyboard, function keys (e.g., volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, and so forth, which are not described in detail herein.
Memory 109 may be used to store software programs as well as various data. The memory 109 may mainly include a first memory area storing programs or instructions and a second memory area storing data, wherein the first memory area may store an operating system, application programs or instructions (such as a sound playing function, an image playing function, etc.) required for at least one function, and the like. Further, the memory 109 may include volatile memory or nonvolatile memory, or the memory 109 may include both volatile and nonvolatile memory. The nonvolatile Memory may be a Read-Only Memory (ROM), a Programmable ROM (PROM), an Erasable PROM (EPROM), an Electrically Erasable EPROM (EEPROM), or a flash Memory. The volatile memory may be random access memory (Random Access Memory, RAM), static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (ddr SDRAM), enhanced SDRAM (Enhanced SDRAM), synchronous DRAM (SLDRAM), and Direct RAM (DRRAM). Memory 109 in embodiments of the present application includes, but is not limited to, these and any other suitable types of memory.
Processor 110 may include one or more processing units; optionally, the processor 110 integrates an application processor that primarily processes operations involving an operating system, user interface, application programs, etc., and a modem processor that primarily processes wireless communication signals, such as a baseband processor. It will be appreciated that the modem processor described above may not be integrated into the processor 110.
The embodiment of the present application further provides a readable storage medium, where a program or an instruction is stored, and when the program or the instruction is executed by a processor, the program or the instruction implement each process of the embodiment of the method, and the same technical effects can be achieved, so that repetition is avoided, and no further description is given here.
Wherein the processor is a processor in the electronic device described in the above embodiment. The readable storage medium includes computer readable storage medium such as computer readable memory ROM, random access memory RAM, magnetic or optical disk, etc.
The embodiment of the application further provides a chip, the chip includes a processor and a communication interface, the communication interface is coupled with the processor, and the processor is used for running a program or an instruction, implementing each process of the above method embodiment, and achieving the same technical effect, so as to avoid repetition, and not repeated here.
It should be understood that the chips referred to in the embodiments of the present application may also be referred to as system-on-chip chips, chip systems, or system-on-chip chips, etc.
The embodiments of the present application provide a computer program product stored in a storage medium, where the program product is executed by at least one processor to implement the respective processes of the embodiments of the thread scheduling method described above, and achieve the same technical effects, and are not repeated herein.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element. Furthermore, it should be noted that the scope of the methods and apparatus in the embodiments of the present application is not limited to performing the functions in the order shown or discussed, but may also include performing the functions in a substantially simultaneous manner or in an opposite order depending on the functions involved, e.g., the described methods may be performed in an order different from that described, and various steps may also be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solutions of the present application may be embodied essentially or in a part contributing to the prior art in the form of a computer software product stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk), comprising several instructions for causing a terminal (which may be a mobile phone, a computer, a server, or a network device, etc.) to perform the methods described in the embodiments of the present application.
The embodiments of the present application have been described above with reference to the accompanying drawings, but the present application is not limited to the above-described embodiments, which are merely illustrative and not restrictive, and many forms may be made by those of ordinary skill in the art without departing from the spirit of the present application and the scope of the claims, which are also within the protection of the present application.

Claims (12)

1. A method of thread scheduling, the method comprising:
acquiring at least one first thread group corresponding to a foreground service of a first process;
determining at least one second thread group corresponding to background business of the first process based on the at least one first thread group and threads of the first process;
scheduling threads in the at least one first thread group or threads in a target thread group in the at least one second thread group;
wherein the scheduling priority of the target thread group is higher than the scheduling priority of the other thread groups than the target thread group in the at least one second thread group.
2. The method of claim 1, wherein the obtaining at least one first thread group corresponding to foreground traffic of the first process comprises:
under the condition that a first input for triggering the first process is received, acquiring at least one third thread group of a first foreground service corresponding to the first input, and acquiring at least one fourth thread group of a second foreground service corresponding to an execution result of a target operation;
wherein the at least one first thread group includes the at least one third thread group and the at least one fourth thread group, the target operation being an operation corresponding to the first input.
3. The method according to claim 1 or 2, wherein the obtaining at least one first thread group corresponding to foreground traffic of the first process comprises:
acquiring thread information of at least two first threads corresponding to foreground services of the first process;
constructing the at least one first thread group based on the thread information;
wherein the thread information of the first thread includes at least one of: and the thread name of the first thread, the service corresponding to the thread and the thread data.
4. The method of claim 1, wherein the scheduling the threads in the target thread group in the at least one second thread group comprises:
scheduling threads in the target thread group and freezing other thread groups except the target thread group in the at least one second thread group under the condition that the resource occupancy rate of a Central Processing Unit (CPU) of the electronic equipment is greater than or equal to a first threshold value; or alternatively, the first and second heat exchangers may be,
and aligning the scheduling time of each thread in the target thread group under the condition that the resource occupancy rate of the CPU is smaller than the first threshold value, and scheduling the threads in the target thread group according to the aligned scheduling time.
5. The method of claim 4, wherein said aligning the scheduling time of each thread in the target thread group comprises:
acquiring window time corresponding to scheduling time of each thread in the target thread group;
determining a rear end point of a window time intersection corresponding to the scheduling time of each thread as a first scheduling time;
and dispatching the threads of the target thread group according to the aligned dispatching time, wherein the dispatching comprises the following steps:
scheduling threads in the target thread group if the system time of the electronic device reaches the first scheduling time.
6. The method of claim 1, wherein the determining, based on the at least one first thread group and the threads of the first process, at least one second thread group corresponding to background traffic of the first process comprises:
determining a second thread corresponding to a background service of the first process from threads of the first process;
and grouping the second threads corresponding to the background service of the first process according to the wake-up capability of the second threads to obtain the at least one second thread group.
7. The method of claim 6, wherein grouping the second threads corresponding to the background traffic of the first process according to the wake-up capability of the second thread to obtain the at least one second thread group comprises:
Determining the thread with the wake-up function in the second thread as the thread in a third thread group;
determining the thread which does not have a wake-up function in the second thread as the thread in a fourth thread group;
wherein the at least one second thread group comprises the third thread group or the fourth thread group, and the scheduling priority of the third thread group is higher than the scheduling priority of the fourth thread group.
8. A thread scheduling apparatus, the apparatus comprising: the device comprises an acquisition module, a determination module and a scheduling module;
the acquisition module is used for acquiring at least one first thread group corresponding to a foreground service of the first process;
the determining module is used for determining at least one second thread group corresponding to the background service of the first process based on the at least one first thread group and the threads of the first process acquired by the acquiring module;
the scheduling module is used for scheduling threads in the at least one first thread group or threads in a target thread group in the at least one second thread group;
wherein the scheduling priority of the target thread group is higher than the scheduling priority of the other thread groups than the target thread group in the at least one second thread group.
9. The apparatus according to claim 8, wherein the obtaining module is specifically configured to obtain, in a case where a first input for triggering the first process is received, at least one third thread group of a first foreground service corresponding to the first input, and at least one fourth thread group of a second foreground service corresponding to an execution result of a target operation;
wherein the at least one first thread group includes the at least one third thread group and the at least one fourth thread group, the target operation being an operation corresponding to the first input.
10. The apparatus according to claim 8, wherein the scheduling module is specifically configured to schedule the threads of the target thread group and freeze the other thread groups of the at least one second thread group than the target thread group if the resource occupancy of the central processing unit CPU of the electronic device is greater than or equal to a first threshold; or alternatively, the first and second heat exchangers may be,
and aligning the scheduling time of each thread in the target thread group under the condition that the resource occupancy rate of the CPU is smaller than the first threshold value, and scheduling the threads of the target thread group according to the aligned scheduling time.
11. An electronic device comprising a processor, a memory and a program or instruction stored on the memory and executable on the processor, which when executed by the processor, implements the steps of the thread scheduling method of any one of claims 1 to 7.
12. A readable storage medium, characterized in that it stores thereon a program or instructions which, when executed by a processor, implement the steps of the thread scheduling method of any one of claims 1 to 7.
CN202311273751.6A 2023-09-27 2023-09-27 Thread scheduling method, device, electronic equipment and storage medium Pending CN117271092A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311273751.6A CN117271092A (en) 2023-09-27 2023-09-27 Thread scheduling method, device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311273751.6A CN117271092A (en) 2023-09-27 2023-09-27 Thread scheduling method, device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117271092A true CN117271092A (en) 2023-12-22

Family

ID=89200529

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311273751.6A Pending CN117271092A (en) 2023-09-27 2023-09-27 Thread scheduling method, device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117271092A (en)

Similar Documents

Publication Publication Date Title
CN109740732B (en) Neural network processor, convolutional neural network data multiplexing method and related equipment
CN109324833B (en) Method and device for running application program
US20110131430A1 (en) Managing accelerators of a computing environment
CN103218329A (en) Digital signal processing data transfer
CN113535364A (en) Task scheduling method and device
CN105308566A (en) On-demand scalable timer wheel
CN111459629A (en) Azkaban-based project operation method and device and terminal equipment
CN111831432B (en) IO request scheduling method and device, storage medium and electronic equipment
CN113238843A (en) Task execution method, device, equipment and storage medium
US10061676B2 (en) Remotely located timing method and device for a processing unit in an information processing system
CN113282359A (en) Application reminding method and device and electronic equipment
CN102779076B (en) The method and apparatus of interprocess communication in a kind of browser
CN117271092A (en) Thread scheduling method, device, electronic equipment and storage medium
WO2023284877A1 (en) Detection method and apparatus, and electronic device
CN111178846A (en) Workflow file generation method, device, equipment and storage medium
CN100454261C (en) Method and device for displaying real time information with the helf of mouse cursor
CN115809126A (en) Job scheduling method and device in mixed deployment scene and electronic equipment
JP2000081986A (en) Method for managing job in client-server type operation processing system and recording medium storing program for the method
CN114611046A (en) Data loading method, device, equipment and medium
CN111090627B (en) Log storage method and device based on pooling, computer equipment and storage medium
CN109799715B (en) Data receiving method, device and terminal equipment
CN113037871A (en) Conference call recovery method, device, system, electronic equipment and readable storage medium
CN112083849B (en) Information display method, device, equipment and medium
CN111767153B (en) Resource access method and device and electronic equipment
CN112084022B (en) Project capacity planning method and device, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination