CN114035926A - Application thread scheduling method, device, storage medium and electronic device - Google Patents
Application thread scheduling method, device, storage medium and electronic device Download PDFInfo
- Publication number
- CN114035926A CN114035926A CN202111402516.5A CN202111402516A CN114035926A CN 114035926 A CN114035926 A CN 114035926A CN 202111402516 A CN202111402516 A CN 202111402516A CN 114035926 A CN114035926 A CN 114035926A
- Authority
- CN
- China
- Prior art keywords
- thread
- scheduling
- application
- class
- deadline
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
- G06F9/4881—Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
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
The application discloses an application thread scheduling method, an application thread scheduling device, a storage medium and electronic equipment, and relates to the technical field of computers, wherein the method comprises the following steps: creating an application process of a started target application, wherein the application process comprises an auxiliary thread and a main thread; setting the type of the auxiliary thread as a fair scheduling class, and setting the type of the main thread as a deadline scheduling class; creating an application drawing thread, and setting the type of the application drawing thread as a deadline scheduling class; and scheduling the auxiliary thread, the main thread and the application drawing thread according to the thread scheduling priority corresponding to the deadline scheduling class and the fair scheduling class so as to run the target application. The application effectively avoids the phenomenon of blocking during application operation, and improves the application smoothness.
Description
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for scheduling application threads, a storage medium, and an electronic device.
Background
In an Android system, application drawing threads are generally classified into threads of a fair scheduling Class (CFS), and in the Android system, hundreds of threads of the fair scheduling class exist, and when the system is busy, even if the application drawing threads have the highest priority among the threads of the fair scheduling class, allocated time slices are used up and are preempted by other threads, so that the application operation is blocked.
Disclosure of Invention
The embodiment of the application provides a scheme, so that the phenomenon of blockage during application running can be effectively avoided, and the use smoothness of the application is improved.
In order to solve the above technical problem, an embodiment of the present application provides the following technical solutions:
according to one embodiment of the application, an application thread scheduling method comprises the following steps: creating an application process of a started target application, wherein the application process comprises an auxiliary thread and a main thread; setting the type of the auxiliary thread as a fair scheduling class, and setting the type of the main thread as a deadline scheduling class; creating an application drawing thread, and setting the type of the application drawing thread as a deadline scheduling class; and scheduling the auxiliary thread, the main thread and the application drawing thread according to the thread scheduling priority corresponding to the deadline scheduling class and the fair scheduling class so as to run the target application.
In some embodiments of the present application, the application drawing thread and the main thread of the deadline scheduling class are allocated to run in a first central processing unit; the method further comprises the following steps: monitoring a target thread of a wakened real-time scheduling class in an operating system; and allocating the target thread to a second central processing unit for running, wherein the first central processing unit is different from the second central processing unit.
In some embodiments of the present application, said assigning said target thread to run in a second central processing unit comprises: traversing all central processing units in a processor corresponding to an operating system to determine central processing units except the first central processing unit as central processing units to be distributed; and determining the central processing unit with the smallest cumulative load from the central processing units to be distributed as the second central processing unit.
In some embodiments of the present application, the scheduling the auxiliary thread, the main thread, and the application drawing thread according to the thread scheduling priority corresponding to the deadline scheduling class and the fair scheduling class includes: determining a scheduling parameter of each thread according to the tasks in charge of the auxiliary thread, the main thread and the application drawing thread; and scheduling the types of the auxiliary thread, the main thread and the application drawing thread according to the thread scheduling priority and the scheduling parameter, wherein the thread scheduling priority corresponding to the deadline scheduling class is higher than the fair scheduling class.
In some embodiments of the present application, the scheduling the types of the secondary thread, the primary thread, and the application drawing thread according to the thread scheduling priority and the scheduling parameter includes: based on a deadline scheduler, scheduling the main thread according to the thread scheduling priority corresponding to the deadline scheduling class and the scheduling parameter corresponding to the task for which the main thread is responsible; based on the deadline scheduler, scheduling the application drawing thread according to the thread scheduling priority corresponding to the deadline scheduling class and the scheduling parameter corresponding to the task for which the application drawing thread is responsible; and scheduling the auxiliary thread according to the thread scheduling priority corresponding to the fair scheduling class and the scheduling parameter corresponding to the task for which the auxiliary thread is responsible based on fair scheduling.
In some embodiments of the present application, the method further comprises: and scheduling the target thread according to the thread scheduling priority corresponding to the real-time scheduling class, wherein the thread scheduling priorities corresponding to the deadline scheduling class, the real-time scheduling class and the fair scheduling class are sequentially reduced.
In some embodiments of the present application, said scheduling the target thread according to the thread scheduling priority corresponding to the real-time scheduling class includes: and scheduling the target thread based on a real-time scheduler according to the thread scheduling priority corresponding to the real-time scheduling class and the scheduling parameter corresponding to the task for which the target thread is responsible.
According to an embodiment of the present application, an application thread scheduling apparatus includes: the system comprises a first establishing module, a second establishing module and a third establishing module, wherein the first establishing module is used for establishing an application process of a started target application, and the application process comprises an auxiliary thread and a main thread; the setting module is used for setting the type of the auxiliary thread as a fair scheduling class and setting the type of the main thread as a deadline scheduling class; the second creating module is used for creating an application drawing thread and setting the type of the application drawing thread as a deadline scheduling class; and the scheduling module is used for scheduling the auxiliary thread, the main thread and the application drawing thread according to the thread scheduling priority corresponding to the deadline scheduling class and the fair scheduling class so as to run the target application.
According to another embodiment of the present application, a storage medium has stored thereon a computer program which, when executed by a processor of a computer, causes the computer to perform the method of an embodiment of the present application.
According to another embodiment of the present application, an electronic device may include: a memory storing a computer program; and the processor reads the computer program stored in the memory to execute the method in the embodiment of the application.
In the embodiment of the application, an application process of a started target application is created, wherein the application process comprises an auxiliary thread and a main thread; setting the type of the auxiliary thread as a fair scheduling class, and setting the type of the main thread as a deadline scheduling class; creating an application drawing thread, and setting the type of the application drawing thread as a deadline scheduling class; and scheduling the auxiliary thread, the main thread and the application drawing thread according to the thread scheduling priority corresponding to the deadline scheduling class and the fair scheduling class so as to run the target application.
In this way, the type of the application drawing thread of the target application is set as the deadline scheduling class, the type of the main thread is set as the deadline scheduling class, and the other auxiliary threads are set as the fair scheduling class, so that the phenomenon of blocking during the operation of the application is effectively avoided based on the scheduling priorities of the threads of the types in the android system, and the use smoothness of the application is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 shows a schematic diagram of a system to which embodiments of the present application may be applied.
FIG. 2 shows a flow diagram of an application thread scheduling method according to one embodiment of the present application.
FIG. 3 shows a block diagram of an application thread scheduling apparatus according to an embodiment of the present application.
FIG. 4 shows a block diagram of an electronic device according to an embodiment of the application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
In the description that follows, specific embodiments of the present application will be described with reference to steps and symbols executed by one or more computers, unless otherwise indicated. Accordingly, these steps and operations will be referred to, several times, as being performed by a computer, the computer performing operations involving a processing unit of the computer in electronic signals representing data in a structured form. This operation transforms the data or maintains it at locations in the computer's memory system, which may be reconfigured or otherwise altered in a manner well known to those skilled in the art. The data maintains a data structure that is a physical location of the memory that has particular characteristics defined by the data format. However, the principles of the present application are described in the foregoing text and are not meant to be limiting, as those of ordinary skill in the art will appreciate that various steps and operations described below may be implemented in hardware.
FIG. 1 shows a schematic diagram of a system 100 to which embodiments of the present application may be applied. As shown in fig. 1, system 100 may include a terminal 101 and a terminal 102. The terminals 101 and 102 may be any computer devices, such as computers, mobile phones, smart watches, and home appliances. In one example, the terminal 101 is a remote controller, and the terminal 102 is a smart television.
In one implementation of this example, the terminal 102 may: creating an application process of a target application, wherein the application process comprises an auxiliary thread and a main thread; setting the type of the auxiliary thread as a fair scheduling class, and setting the type of the main thread as a deadline scheduling class; creating an application drawing thread, and setting the type of the application drawing thread as a deadline scheduling class; and scheduling the auxiliary thread, the main thread and the application drawing thread according to the thread scheduling priority corresponding to the deadline scheduling class and the fair scheduling class so as to start the target application. The target application may be started by the terminal 101 controlling the terminal 102, or the terminal 102 may be started by other controls.
FIG. 2 schematically shows a flow diagram of an application thread scheduling method according to an embodiment of the present application. The execution subject of the application thread scheduling method may be any device, such as the terminal 102 shown in fig. 1.
As shown in fig. 2, the application thread scheduling method may include steps S210 to S240.
Step S210, creating an application process of a started target application, wherein the application process comprises an auxiliary thread and a main thread;
step S220, setting the type of the auxiliary thread as a fair scheduling class and setting the type of the main thread as a deadline scheduling class;
step S230, creating an application drawing thread, and setting the type of the application drawing thread as a deadline scheduling class;
step S240, according to the thread scheduling priorities corresponding to the deadline scheduling class and the fair scheduling class, scheduling the auxiliary thread, the main thread, and the application drawing thread to run the target application.
For the target application, when a starting command of the target application is received, an application process of the target application is created in the system. The target application may be an application to be started, such as a television playing application or a music application.
An application process, i.e., a program process corresponding to a target application, i.e., an instruction set that is active in a system corresponding to the target application, generally has one application process. At least one thread may be included in an application process. One thread which must be included in the application process is a main thread, the application process starts from the execution of the main thread, and other additional threads in the created application process are auxiliary threads.
After the application process is created, the type of the auxiliary thread in the application process is set as a fair scheduling class, and the type of the main thread is set as a deadline scheduling class. The fair scheduling Class (CFS) is a type of scheduling in which each thread is scheduled in time slices in the order of a high scheduling priority to a low scheduling priority. The Deadline class (DL) is a type that is scheduled according to the Deadline of the thread, and the Deadline class scheduler always selects the Deadline class thread with the Deadline closest to the current time point and schedules the thread to execute.
Then, an application drawing thread is created, and the type of the application drawing thread is set as a deadline scheduling class. The application drawing thread is a thread for drawing an application, and improper scheduling of the application drawing thread causes the application drawing to be stuck, thereby causing the problem of stuck application display.
And finally, scheduling the auxiliary thread, the main thread and the application drawing thread according to the deadline scheduling class and the thread scheduling priority corresponding to the fair scheduling class, wherein the target application can be operated very smoothly without being blocked based on a thread scheduling mechanism in an android.
In this way, based on steps S210 to S240, by setting the type of the application drawing thread of the target application as the deadline scheduling class, the type of the main thread as the deadline scheduling class, and the other auxiliary threads as the fair scheduling class, based on the scheduling priorities of the several types of threads in the android system, the phenomenon of stutter during the operation of the application is effectively avoided, and the smoothness of the application is improved.
The following describes a specific process of each step performed when the application thread scheduling is performed.
In step S210, an application process of the started target application is created, where the application process includes an auxiliary thread and a main thread.
In the embodiment of the present example, for the target application, when receiving the start command, the application process of the target application is created in the system. The target application may be an application to be started, such as a television playing application or a music application.
An application process, i.e., a program process corresponding to a target application, i.e., an instruction set that is active in a system corresponding to the target application, generally has one application process. At least one thread can be included in an application process, and the thread is a basic unit of processor time resource allocation of a system or a unit which is independently executed in the process.
One thread, the main thread, that must be included in the application process, one process starts with the execution of the main thread, and the other additional threads, the auxiliary threads.
In step S220, the type of the secondary thread is set as a fair scheduling class, and the type of the primary thread is set as a deadline scheduling class.
In the embodiment of this example, after the application process is created, the type of the secondary thread in the application process is set as a fair scheduling class, and the type of the primary thread is set as a deadline scheduling class.
The fair scheduling Class (CFS) is a type of scheduling according to allocated slots in an order from high to low according to the scheduling priority of each thread, for example, a thread a with the highest priority runs in the allocated slot after being scheduled, stops running after the slot arrives (a thread task is not necessarily completed), and is rearranged at the end of a queue of all fair scheduling class threads, and is called again according to the priority when the scheduling arrives at the end of the queue.
The Deadline class (DL) is a type that is scheduled according to the Deadline of the thread, and the Deadline class scheduler always selects the Deadline class thread with the Deadline closest to the current time point and schedules the thread to execute.
In step S230, an application drawing thread is created, and the type of the application drawing thread is set as the deadline scheduling class.
In the embodiment of the present example, the application drawing thread is a thread for drawing an application, such as a User Interface (UI) drawing thread, a rendering thread (render thread), an animation thread (animation thread), and the like, and the improper scheduling of the application drawing thread will cause the application drawing to be stuck, thereby causing the problem of the application display being stuck.
In step S240, the auxiliary thread, the main thread, and the application drawing thread are scheduled according to the thread scheduling priorities corresponding to the deadline scheduling class and the fair scheduling class, so as to run the target application.
In the embodiment of the example, the scheduling priority of the thread of the deadline scheduling class in the android system is higher than that of the thread of the fair scheduling class, and based on a thread scheduling mechanism in the android system, by dynamically adjusting the type of the thread, especially adjusting the type of the application drawing thread to be the type with the highest scheduling priority, the running of the target application can be very smooth and not stuck.
In one embodiment, the application drawing thread and the main thread of the deadline scheduling class are allocated to run in a first central processing unit; after step S240, the method further includes: monitoring a target thread of a wakened real-time scheduling class in an operating system; and allocating the target thread to a second central processing unit for running, wherein the first central processing unit is different from the second central processing unit.
The real-time scheduling (RT) class is a thread scheduled in real time according to a requirement, the scheduling priority of the real-time scheduling class thread in the android system is higher than that of the fair scheduling class thread, and the scheduling priority of the deadline scheduling class thread is higher than that of the real-time scheduling class thread.
The method comprises the steps that a target thread of a real-time scheduling class is placed in a second central processing unit to run, the application drawing thread and the main thread of a deadline scheduling class are distributed to a first central processing unit to run, the central processing unit is a CPU core, and the two classes of threads run in different CPU cores based on a CPU multi-core mechanism, so that the real-time scheduling class thread and the deadline scheduling class thread are prevented from seizing CPU resources, and the application running smoothness is further improved.
In one embodiment, said assigning said target thread to run in a second central processing unit comprises: traversing all central processing units in a processor corresponding to an operating system to determine central processing units except the first central processing unit as central processing units to be distributed; and determining the central processing unit with the smallest cumulative load from the central processing units to be distributed as the second central processing unit.
Traversing all central processing units in a processor (CPU), and determining that the central processing unit with the minimum accumulated central processing unit in the central processing units (namely the central processing units except the first central processing unit) which do not run the threads of the deadline class runs the real-time scheduling class linearity, thereby further improving the running reliability of the application.
In one embodiment, in step S240, the scheduling the secondary thread, the primary thread, and the application drawing thread according to the thread scheduling priorities corresponding to the deadline scheduling class and the fair scheduling class includes:
determining a scheduling parameter of each thread according to the tasks in charge of the auxiliary thread, the main thread and the application drawing thread; and scheduling the types of the auxiliary thread, the main thread and the application drawing thread according to the thread scheduling priority and the scheduling parameter, wherein the thread scheduling priority corresponding to the deadline scheduling class is higher than the fair scheduling class.
The scheduling priority of the thread of the deadline scheduling class in the android system is higher than that of the thread of the fair scheduling class, and a main thread and an application drawing thread with high priority are preferentially called when the thread is scheduled. Each thread sets scheduling parameters according to a corresponding task, for example, a thread of fair scheduling class may set a time slice parameter corresponding to the task, and a thread of deadline class may set a period (period), a running time (runtime), a deadline (deadline), and other parameters. Furthermore, the scheduler in the android system can effectively schedule each thread according to the scheduling priority and the scheduling parameter corresponding to each thread.
In one embodiment, the scheduling the types of the secondary thread, the primary thread, and the application rendering thread according to the thread scheduling priority and the scheduling parameter includes:
based on a deadline scheduler, scheduling the main thread according to the thread scheduling priority corresponding to the deadline scheduling class and the scheduling parameter corresponding to the task for which the main thread is responsible; based on the deadline scheduler, scheduling the application drawing thread according to the thread scheduling priority corresponding to the deadline scheduling class and the scheduling parameter corresponding to the task for which the application drawing thread is responsible; and scheduling the auxiliary thread according to the thread scheduling priority corresponding to the fair scheduling class and the scheduling parameter corresponding to the task for which the auxiliary thread is responsible based on a fair scheduler.
A deadline scheduler (dead scheduler), i.e. a scheduler for scheduling threads of a deadline scheduling class, for which a user may set three scheduling parameters: period (period), run time (runtime), and deadline (deadline). The cycle is related to the working mode of the real-time task corresponding to the thread, for example: for a video processing task, its main task is to process 60 frames of video data per second, i.e. each frame of video needs to be processed every 16ms, so the period of the task is 16 ms. For real-time tasks, there is always a fixed "work" to be done in a cycle, for example, in video tasks, the so-called work is to process a frame of video data, and the running time is the CPU execution time required to complete the "work", that is, the time value required for the CPU to participate in operations in a cycle. We cannot be very optimistic when setting runtime parameters, which must consider worst-case execution time (WCET) when setting. For example, in video processing, the situation of each frame may be different (on one hand, the correlation between frames is different, and on the other hand, the correlation between image pixels is different even for one frame of data), some of which may take longer and some of which may be shorter. If the longest processed frame of video requires 5 milliseconds to process, then its run time setting is five milliseconds.
Based on the deadline scheduler, scheduling the main thread according to the thread scheduling priority corresponding to the deadline scheduling class and scheduling parameters (three scheduling parameters: period, running time and deadline) corresponding to tasks for which the main thread is responsible); and scheduling the application drawing thread according to the thread scheduling priority corresponding to the deadline scheduling class and scheduling parameters (three scheduling parameters: period, running time and deadline) corresponding to the task for which the application drawing thread is responsible) based on a deadline scheduler.
The fair scheduler (complete fair scheduler) is a scheduler for scheduling the threads in the fair scheduling class, where the scheduling parameters of the threads in the fair scheduling class mainly include a time slice parameter, and for the threads in the fair scheduling Class (CFS), the fair scheduler performs scheduling according to the order of the scheduling priority of each thread from high to low according to the allocated time slices, for example, a thread a with the highest priority runs in the allocated time slice after being scheduled, stops running after the time slice arrives (a thread task is not necessarily completed), and rearranges the threads in all the fair scheduling classes at the end of the queue, and calls again according to the priority after the scheduling arrives at the end of the queue.
In one embodiment, the method further comprises: and scheduling the target thread according to the thread scheduling priority corresponding to the real-time scheduling class, wherein the thread scheduling priorities corresponding to the deadline scheduling class, the real-time scheduling class and the fair scheduling class are sequentially reduced.
The thread scheduling priorities corresponding to the deadline scheduling class, the real-time scheduling class and the fair scheduling class are sequentially reduced, namely the scheduling priority of the real-time scheduling class thread in the android system is higher than that of the fair scheduling class thread, the scheduling priority of the deadline scheduling class thread is higher than that of the real-time scheduling class thread, on the basis, the scheduling priority of each thread comprises the real-time priority of the corresponding thread to the task, the scheduling of the target thread of the real-time scheduling class is carried out in the android system based on the sequence and the real-time priority, and the thread scheduling rationality is further improved.
In an embodiment, the scheduling the target thread according to the thread scheduling priority corresponding to the real-time scheduling class includes: and scheduling the target thread based on a real-time scheduler according to the thread scheduling priority corresponding to the real-time scheduling class and the scheduling parameter corresponding to the task for which the target thread is responsible.
The real-time scheduler (POSIX real time scheduler) is an RT scheduler, which has two scheduling strategies: FIFO (first-in-first-out) and RR (round-robin). The RT scheduler, whether FIFO or RR, schedules according to the real-time priority of the task (RT _ priority member in Linux process descriptor). The thread corresponding to the task with the highest real-time priority will obtain the CPU resource first. In real-time theory, such a scheduler is classified as a fixed-priority scheduler (i.e., each rt task is fixedly assigned a priority). When the real-time priorities are different, the FIFO and RR are not different, and we can only see the difference between FIFO and RR when the two tasks have the same priority.
For a FIFO scheduler, the task that first enters the run-time (runtime) state will first acquire CPU resources and hold them until the process goes to sleep. Whereas for the RR scheduler tasks with the same priority will share processor resources in a round-robin fashion. When an RR task starts running, if the task is not blocked, the RR task runs until the time slice allocated to the task expires; when the time slice runs out, the scheduler will place the task at the end of the task chain table (note that only tasks of the same priority will be placed in one chain table, with different priorities in different chain tables), and select the next task from the task chain table to execute.
In order to better implement the application thread scheduling method provided in the embodiments of the present application, an application thread scheduling apparatus based on the application thread scheduling method is also provided in the embodiments of the present application. The terms are the same as those in the application thread scheduling method, and specific implementation details can refer to the description in the method embodiment. FIG. 3 shows a block diagram of an application thread scheduling apparatus according to an embodiment of the present application.
As shown in fig. 3, the application thread scheduling apparatus 300 may include a first creation module 310, a setting module 320, a second creation module 330, and a scheduling module 340.
The first creating module 310 may be configured to create an application process of a started target application, where the application process includes an auxiliary thread and a main thread; the setting module 320 may be configured to set the type of the secondary thread to a fair scheduling class and set the type of the primary thread to a deadline scheduling class; the second creating module 330 may be configured to create an application drawing thread and set a type of the application drawing thread as a deadline scheduling class; the scheduling module 340 may be configured to schedule the auxiliary thread, the main thread, and the application drawing thread according to the thread scheduling priorities corresponding to the deadline scheduling class and the fair scheduling class, so as to run the target application.
In some embodiments of the present application, the application drawing thread and the main thread of the deadline scheduling class are allocated to run in a first central processing unit; the apparatus further comprises a monitoring module configured to: monitoring a target thread of a wakened real-time scheduling class in an operating system; and allocating the target thread to a second central processing unit for running, wherein the first central processing unit is different from the second central processing unit.
In some embodiments of the present application, the monitoring module comprises an allocation unit for: traversing all central processing units in a processor corresponding to an operating system to determine central processing units except the first central processing unit as central processing units to be distributed; and determining the central processing unit with the smallest cumulative load from the central processing units to be distributed as the second central processing unit.
In some embodiments of the present application, the scheduling module 340 includes: the determining unit is used for determining the scheduling parameters of each thread according to the tasks in charge of the auxiliary thread, the main thread and the application drawing thread; and the scheduling unit is used for scheduling the types of the auxiliary thread, the main thread and the application drawing thread according to the thread scheduling priority and the scheduling parameter, wherein the thread scheduling priority corresponding to the deadline scheduling class is higher than the fair scheduling class.
In some embodiments of the present application, the scheduling unit is configured to: based on a deadline scheduler, scheduling the main thread according to the thread scheduling priority corresponding to the deadline scheduling class and the scheduling parameter corresponding to the task for which the main thread is responsible; based on the deadline scheduler, scheduling the application drawing thread according to the thread scheduling priority corresponding to the deadline scheduling class and the scheduling parameter corresponding to the task for which the application drawing thread is responsible; and scheduling the auxiliary thread according to the thread scheduling priority corresponding to the fair scheduling class and the scheduling parameter corresponding to the task for which the auxiliary thread is responsible based on fair scheduling.
In some embodiments of the present application, the apparatus further comprises a target scheduling unit configured to: and scheduling the target thread according to the thread scheduling priority corresponding to the real-time scheduling class, wherein the thread scheduling priorities corresponding to the deadline scheduling class, the real-time scheduling class and the fair scheduling class are sequentially reduced.
In some embodiments of the present application, the target scheduling unit is configured to: and scheduling the target thread based on a real-time scheduler according to the thread scheduling priority corresponding to the real-time scheduling class and the scheduling parameter corresponding to the task for which the target thread is responsible.
In this way, based on the application thread scheduling device 300, by setting the type of the application drawing thread of the target application as the deadline scheduling class, the type of the main thread as the deadline scheduling class, and the other auxiliary threads as the fair scheduling class, based on the scheduling priorities of the threads of these types in the android system, the phenomenon of jamming during the operation of the application is effectively avoided, and the use smoothness of the application is improved.
It should be noted that although in the above detailed description several modules or units of the device for action execution are mentioned, such a division is not mandatory. Indeed, the features and functionality of two or more modules or units described above may be embodied in one module or unit, according to embodiments of the application. Conversely, the features and functions of one module or unit described above may be further divided into embodiments by a plurality of modules or units.
In addition, an embodiment of the present application further provides an electronic device, where the electronic device may be a terminal or a server, as shown in fig. 4, which shows a schematic structural diagram of the electronic device according to the embodiment of the present application, and specifically:
the electronic device may include components such as a processor 401 of one or more processing cores, memory 402 of one or more computer-readable storage media, a power supply 403, and an input unit 404. Those skilled in the art will appreciate that the electronic device configuration shown in fig. 4 does not constitute a limitation of the electronic device and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components. Wherein:
the processor 401 is a control center of the electronic device, connects various parts of the entire computer device using various interfaces and lines, and performs various functions of the computer device and processes data by operating or executing software programs and/or modules stored in the memory 402 and calling data stored in the memory 402, thereby integrally monitoring the electronic device. Optionally, processor 401 may include one or more processing cores; preferably, the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly handles operating systems, user pages, application programs, and the like, and the modem processor mainly handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 401.
The memory 402 may be used to store software programs and modules, and the processor 401 executes various functional applications and data processing by operating the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data created according to use of the computer device, and the like. Further, the memory 402 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 access to the memory 402.
The electronic device further comprises a power supply 403 for supplying power to the various components, and preferably, the power supply 403 is logically connected to the processor 401 through a power management system, so that functions of managing charging, discharging, and power consumption are realized through the power management system. The power supply 403 may also include any component of one or more dc or ac power sources, recharging systems, power failure detection circuitry, power converters or inverters, power status indicators, and the like.
The electronic device may further include an input unit 404, and the input unit 404 may be used to receive input numeric or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
Although not shown, the electronic device may further include a display unit and the like, which are not described in detail herein. Specifically, in this embodiment, the processor 401 in the electronic device loads the executable file corresponding to the process of one or more computer programs into the memory 402 according to the following instructions, and the processor 401 runs the computer program stored in the memory 402, so as to implement various functions, for example, the processor 401 may execute the following steps:
creating an application process of a started target application, wherein the application process comprises an auxiliary thread and a main thread; setting the type of the auxiliary thread as a fair scheduling class, and setting the type of the main thread as a deadline scheduling class; creating an application drawing thread, and setting the type of the application drawing thread as a deadline scheduling class; and scheduling the auxiliary thread, the main thread and the application drawing thread according to the thread scheduling priority corresponding to the deadline scheduling class and the fair scheduling class so as to run the target application.
In some embodiments of the present application, the application drawing thread and the main thread of the deadline scheduling class are allocated to run in a first central processing unit; the processor 401 may perform: monitoring a target thread of a wakened real-time scheduling class in an operating system; and allocating the target thread to a second central processing unit for running, wherein the first central processing unit is different from the second central processing unit.
In some embodiments of the present application, when the target thread is allocated to the second central processing unit, the processor 401 may perform: traversing all central processing units in a processor corresponding to an operating system to determine central processing units except the first central processing unit as central processing units to be distributed; and determining the central processing unit with the smallest cumulative load from the central processing units to be distributed as the second central processing unit.
In some embodiments of the present application, when the secondary thread, the primary thread, and the application drawing thread are scheduled according to the thread scheduling priorities corresponding to the deadline scheduling class and the fair scheduling class, the processor 401 may perform: determining a scheduling parameter of each thread according to the tasks in charge of the auxiliary thread, the main thread and the application drawing thread; and scheduling the types of the auxiliary thread, the main thread and the application drawing thread according to the thread scheduling priority and the scheduling parameter, wherein the thread scheduling priority corresponding to the deadline scheduling class is higher than the fair scheduling class.
In some embodiments of the present application, when the types of the secondary thread, the primary thread, and the application drawing thread are scheduled according to the thread scheduling priority and the scheduling parameter, the processor 401 may perform: based on a deadline scheduler, scheduling the main thread according to the thread scheduling priority corresponding to the deadline scheduling class and the scheduling parameter corresponding to the task for which the main thread is responsible; based on the deadline scheduler, scheduling the application drawing thread according to the thread scheduling priority corresponding to the deadline scheduling class and the scheduling parameter corresponding to the task for which the application drawing thread is responsible; and scheduling the auxiliary thread according to the thread scheduling priority corresponding to the fair scheduling class and the scheduling parameter corresponding to the task for which the auxiliary thread is responsible based on fair scheduling.
In some embodiments of the present application, the processor 401 may perform: and scheduling the target thread according to the thread scheduling priority corresponding to the real-time scheduling class, wherein the thread scheduling priorities corresponding to the deadline scheduling class, the real-time scheduling class and the fair scheduling class are sequentially reduced.
In some embodiments of the present application, when the target thread is scheduled according to the thread scheduling priority corresponding to the real-time scheduling class, the processor 401 may perform: and scheduling the target thread based on a real-time scheduler according to the thread scheduling priority corresponding to the real-time scheduling class and the scheduling parameter corresponding to the task for which the target thread is responsible.
It will be understood by those skilled in the art that all or part of the steps of the methods of the above embodiments may be performed by a computer program, which may be stored in a computer-readable storage medium and loaded and executed by a processor, or by related hardware controlled by the computer program.
To this end, the present application further provides a storage medium, in which a computer program is stored, where the computer program can be loaded by a processor to execute the steps in any one of the methods provided in the present application.
Wherein the storage medium may include: read Only Memory (ROM), Random Access Memory (RAM), magnetic or optical disks, and the like.
Since the computer program stored in the storage medium can execute the steps in any method provided in the embodiments of the present application, the beneficial effects that can be achieved by the methods provided in the embodiments of the present application can be achieved, for details, see the foregoing embodiments, and are not described herein again.
Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the embodiments disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains.
It will be understood that the present application is not limited to the embodiments that have been described above and shown in the drawings, but that various modifications and changes can be made without departing from the scope thereof.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111402516.5A CN114035926A (en) | 2021-11-19 | 2021-11-19 | Application thread scheduling method, device, storage medium and electronic device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111402516.5A CN114035926A (en) | 2021-11-19 | 2021-11-19 | Application thread scheduling method, device, storage medium and electronic device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114035926A true CN114035926A (en) | 2022-02-11 |
Family
ID=80145324
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111402516.5A Pending CN114035926A (en) | 2021-11-19 | 2021-11-19 | Application thread scheduling method, device, storage medium and electronic device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114035926A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2023197866A1 (en) * | 2022-04-14 | 2023-10-19 | 北京字节跳动网络技术有限公司 | Application starting optimization method and apparatus, computer device, and storage medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106293917A (en) * | 2016-08-09 | 2017-01-04 | 浪潮(北京)电子信息产业有限公司 | The optimization method of a kind of I O scheduling cfq algorithm and system |
CN109426556A (en) * | 2017-08-31 | 2019-03-05 | 大唐移动通信设备有限公司 | A kind of process scheduling method and device |
WO2021013055A1 (en) * | 2019-07-20 | 2021-01-28 | 华为技术有限公司 | Data processing method and apparatus, and electronic device |
CN112789593A (en) * | 2018-12-24 | 2021-05-11 | 华为技术有限公司 | Multithreading-based instruction processing method and device |
-
2021
- 2021-11-19 CN CN202111402516.5A patent/CN114035926A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106293917A (en) * | 2016-08-09 | 2017-01-04 | 浪潮(北京)电子信息产业有限公司 | The optimization method of a kind of I O scheduling cfq algorithm and system |
CN109426556A (en) * | 2017-08-31 | 2019-03-05 | 大唐移动通信设备有限公司 | A kind of process scheduling method and device |
CN112789593A (en) * | 2018-12-24 | 2021-05-11 | 华为技术有限公司 | Multithreading-based instruction processing method and device |
WO2021013055A1 (en) * | 2019-07-20 | 2021-01-28 | 华为技术有限公司 | Data processing method and apparatus, and electronic device |
Non-Patent Citations (1)
Title |
---|
ZYNORL: "实时调度器之 DL(deadline)调度器 与 RT(rt_priority)调度器 详解", pages 1 - 8, Retrieved from the Internet <URL:《https://blog.csdn.net/qq_44222849/article/details/105783561》> * |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2023197866A1 (en) * | 2022-04-14 | 2023-10-19 | 北京字节跳动网络技术有限公司 | Application starting optimization method and apparatus, computer device, and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP5324934B2 (en) | Information processing apparatus and information processing method | |
EP2885707B1 (en) | Latency sensitive software interrupt and thread scheduling | |
US7441240B2 (en) | Process scheduling apparatus, process scheduling method, program for process scheduling, and storage medium recording a program for process scheduling | |
WO2017080273A1 (en) | Task management methods and system, and computer storage medium | |
EP1365328A1 (en) | Method for executing parallel process, and multi-processor computer | |
EP3376381A1 (en) | Resource management method and system, and computer storage medium | |
US10271326B2 (en) | Scheduling function calls | |
CN112346836B (en) | Preemption method, device, user equipment and storage medium for shared computing resources | |
US8225320B2 (en) | Processing data using continuous processing task and binary routine | |
US20240202024A1 (en) | Thread processing methods, scheduling component, monitoring component, server, and storage medium | |
CN111459622B (en) | Method, device, computer equipment and storage medium for scheduling virtual CPU | |
JP2000056992A (en) | Task scheduling system, its method and recording medium | |
WO2023165485A1 (en) | Scheduling method and computer system | |
CN120216178A (en) | Dynamic graphics processor sharing method, device and storage medium | |
CN114035926A (en) | Application thread scheduling method, device, storage medium and electronic device | |
CN114691376A (en) | Thread execution method and device, electronic equipment and storage medium | |
RU2450330C2 (en) | Hardware-implemented method of executing programs | |
CN117806789B (en) | Task processing method and device of multi-core operating system and computing device | |
CN110333899B (en) | Data processing method, device and storage medium | |
JP2015141584A (en) | Information processing apparatus, information processing method, and program | |
JP2000020323A (en) | Device and method for scheduling and storage medium | |
CN116225546A (en) | Converter control system task scheduling method based on SYS_BIOS | |
JP2008225641A (en) | Computer system, interrupt control method and program | |
CN110109743B (en) | Real-time process scheduling method | |
EP2280345A1 (en) | A device for and a method of managing computer tasks |
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 |