WO2022095862A1 - 调整线程优先级的方法、终端及计算机可读存储介质 - Google Patents
调整线程优先级的方法、终端及计算机可读存储介质 Download PDFInfo
- Publication number
- WO2022095862A1 WO2022095862A1 PCT/CN2021/128287 CN2021128287W WO2022095862A1 WO 2022095862 A1 WO2022095862 A1 WO 2022095862A1 CN 2021128287 W CN2021128287 W CN 2021128287W WO 2022095862 A1 WO2022095862 A1 WO 2022095862A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- thread
- priority
- state
- adjusting
- threads
- Prior art date
Links
- 238000000034 method Methods 0.000 title claims abstract description 120
- 230000008569 process Effects 0.000 claims abstract description 71
- 238000012544 monitoring process Methods 0.000 claims abstract description 20
- 230000000903 blocking effect Effects 0.000 claims description 21
- 230000006870 function Effects 0.000 claims description 18
- 238000004891 communication Methods 0.000 claims description 10
- 238000004590 computer program Methods 0.000 claims description 10
- 238000001514 detection method Methods 0.000 claims description 7
- 230000002159 abnormal effect Effects 0.000 claims description 4
- 230000007704 transition Effects 0.000 claims description 4
- 238000013468 resource allocation Methods 0.000 claims description 3
- 230000004622 sleep time Effects 0.000 claims description 3
- 238000010586 diagram Methods 0.000 description 6
- 238000012545 processing Methods 0.000 description 5
- 238000012546 transfer Methods 0.000 description 4
- 230000008901 benefit Effects 0.000 description 3
- 238000007726 management method Methods 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 2
- 238000005457 optimization Methods 0.000 description 2
- 230000000694 effects Effects 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000011084 recovery Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 230000007723 transport mechanism Effects 0.000 description 1
- 238000012384 transportation and delivery Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR 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
- G06F9/4887—Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues involving deadlines, e.g. rate based, periodic
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR 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/4812—Task transfer initiation or dispatching by interrupt, e.g. masked
- G06F9/4818—Priority circuits therefor
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR 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/4812—Task transfer initiation or dispatching by interrupt, e.g. masked
- G06F9/4831—Task transfer initiation or dispatching by interrupt, e.g. masked with variable priority
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR 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
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR 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/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5027—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
- G06F9/5038—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the execution order of a plurality of tasks, e.g. taking priority or time dependency constraints into consideration
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR 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/52—Program synchronisation; Mutual exclusion, e.g. by means of semaphores
- G06F9/524—Deadlock detection or avoidance
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR 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/52—Program synchronisation; Mutual exclusion, e.g. by means of semaphores
- G06F9/526—Mutual exclusion algorithms
Definitions
- the present disclosure relates to, but is not limited to, the field of terminals, in particular, but not limited to, a method for adjusting thread priority, a terminal, and a computer-readable storage medium.
- the method, terminal and computer-readable storage medium for adjusting thread priority provided by the present disclosure mainly solve the technical problem that the thread is executed according to the preset priority, which leads to the problem of low system performance.
- an embodiment of the present disclosure provides a method for adjusting thread priority.
- the method includes: monitoring the state of at least one thread; when monitoring that at least one thread is in a preset blocking state, detecting each The running state and associated state of the thread; the priority of one or at least two threads in the same process is adjusted according to the running state and the associated state of each thread.
- An embodiment of the present disclosure further provides a terminal, where the terminal includes a monitoring module, a detection module, and an adjustment module.
- the monitoring module is configured to monitor the status of at least one thread.
- the detection module is configured to detect the running state and associated state of each thread in the same process when the monitoring module monitors that at least one thread is in a preset blocking state.
- the adjustment module is configured to adjust the priority of one or at least two threads in the same process according to the running state and associated state of each thread.
- An embodiment of the present disclosure further provides a terminal, where the terminal includes a processor, a memory, and a communication bus.
- the communication bus is configured to implement the connection communication between the processor and the memory.
- the processor is configured to execute one or more computer programs stored in the memory to implement the steps of the method of adjusting thread priority as described above.
- Embodiments of the present disclosure further provide a computer storage medium, where one or more programs are stored in the computer-readable storage medium, and the one or more programs can be executed by one or more processors to implement the above-mentioned adjustment thread The steps of the priority method.
- FIG. 1 is a basic flowchart of a method for adjusting thread priority according to Embodiment 1 of the present disclosure
- FIG. 2 is a detailed flowchart of a method for adjusting thread priority according to Embodiment 2 of the present disclosure
- FIG. 3 is a schematic diagram of the composition of a terminal according to Embodiment 3 of the present disclosure.
- FIG. 4 is a schematic diagram of the composition of a terminal according to Embodiment 4 of the present disclosure.
- FIG. 5 is a schematic state diagram of a thread according to Embodiment 4 of the present disclosure.
- FIG. 6 is a schematic structural diagram of a terminal according to Embodiment 5 of the present disclosure.
- the present disclosure proposes a method for adjusting thread priority, which will be described below with reference to this embodiment.
- FIG. 1 is a basic flowchart of a method for adjusting thread priority according to Embodiment 1 of the present disclosure, and the method includes the following steps S101 to S103.
- At least one thread may include: a thread that calls a process scheduling function and needs to wait for system resources to suspend running; and/or, when there is an interrupted or abnormal process in the current instruction executed by the CPU, and in the current instruction
- the thread that executes the process scheduling function For example, after the CPU executes the current instruction and before executing the next instruction, it detects that an interrupt or exception occurs after the execution of the current instruction, and compares the process priority of the interrupt or exception with the process priority of the next instruction. When the priority is higher than the process priority of the next instruction, the interrupt service routine will be executed, and when the interrupt is returned, the thread of the process scheduling function will be executed.
- the calling process scheduling function can be schedule().
- the IO flag can be set before calling the process scheduling function. At this time, it can be determined whether the thread is a state switch caused by IO resources.
- the thread When the thread uses network resources, it will call the socket socket interface. Some flags can be added to the socket interface. When the thread state switches, you can know whether the thread is blocked due to network resources.
- monitoring the state of at least one thread may include: detecting that at least one thread implements a waiting policy, and at least one thread is in a waiting state; or, detecting that at least one thread implements a sleep policy, and the sleep time exceeds a first preset duration , at least one thread changes from the waiting state to the ready state; or, it is detected that at least one thread executes the strategy of waiting to call the current thread and continues to execute the next thread after the execution of the current thread is completed, and the waiting time exceeds the second preset time length, and at least one thread is waited for.
- the state transitions to the ready state; or, upon detecting that at least one thread issues a request for acquiring input or output resources, at least one thread transitions from the waiting state to the ready state.
- the waiting strategy is the wait() method, which allows the current thread to suspend execution and release the object lock flag.
- the sleep strategy is the sleep() method, which makes the current thread suspend execution for a period of time, allowing other threads to have the opportunity to continue execution, but it does not release the object lock.
- the strategy of waiting for the execution of the current thread to continue to execute the next thread is the join() method, so that the thread that calls this method is executed before that, that is, waits for the thread that calls this method to finish executing before continuing to execute.
- the preset blocking state in this step may include: blocking because the system resource cannot be obtained or the thread voluntarily giving up the CPU.
- the system resources include at least one of the following: network resources and I/O resources.
- the system resources may also include memory, CPU resources, and the like.
- the synchronization lock is occupied by other threads.
- the thread can directly conclude that the thread is in a preset blocking state.
- the associated state associated with each thread may include: the priority order of each thread, or the priority order of each thread and the mutual wake-up information of each thread.
- S103 Perform priority adjustment on one or at least two threads in the same process according to the running state and associated state of each thread.
- Adjusting the priority of at least one thread in each thread according to the running state and priority of each thread may further include: when each thread has a third thread in a ready state and a fourth thread in a waiting state, confirming the third thread The priority of the thread and the fourth thread; when the priority of the third thread is lower than that of the fourth thread, and the third thread and the fourth thread wake up from each other, the priority of the third thread is adjusted to be before the fourth thread.
- the information of each thread of the same process is counted, and according to the statistical information, it is determined whether there is a thread in the ready-runnable state in the current process that blocks a thread with a higher priority than the thread in the ready-runnable state.
- the statistical information of each thread of the same process includes: the running state of the thread, the time slice, the priority, and the information that the threads wake up each other before. Among them, if it is found that two threads frequently wake up each other, one is in the runnable state and the other is in the wait state, the thread in the wait state is largely because the thread in the runnable state cannot be executed, and the priority of the runnable thread is increased. Priority access to resources.
- the statistical information can also use the external proc of the operating system or the sys file system node to output thread status, scheduling information, IO information, network information, etc., and external applications can generate intelligent policies based on these information and input them to the system to make priority transfer more intelligent. .
- each thread after adjusting the priority of one or at least two threads in the same process according to the running state and associated state of each thread, wait for the system resource to allocate a running time slice according to the adjusted priority of each thread Process each thread to restore the adjusted priority of each thread.
- the state of at least one thread is monitored, and when it is detected that at least one thread is in a preset blocking state, the running state and the associated state of each thread in the same process are detected, and according to the running state and the associated state of each thread, the One or at least two threads in the same process are prioritized. This dynamically adjusts thread priorities and improves system performance.
- the method for adjusting thread priority of the present disclosure can realize dynamic adjustment of thread priority, thereby improving system performance.
- the method for adjusting thread priority of the present disclosure will be described below with reference to an application scenario.
- FIG. 2 is a detailed flowchart of a method for adjusting thread priority according to Embodiment 2 of the present disclosure.
- the method for adjusting thread priority includes the following steps S201 to S209.
- S201 Monitor the thread state, when the thread state switches from the running state to the non-running state.
- Synchronization blocking When the running thread acquires the synchronization lock of the object, if the synchronization lock is occupied by another thread, the virtual machine will put the thread into the "lock pool", indicating that the block is caused by lock competition, and no judgment is required. .
- S203 Thread control management, maintaining the state of each thread of the same process.
- S204 and S206 may be performed simultaneously.
- S204 Statistical information on the running state, time slice and priority of the threads, and information on mutual wake-up between threads.
- S207 The thread is in a ready state but has a low priority. If other threads of the same process have a high priority and are in a waiting state, the policy in the policy library is executed to transmit the priority.
- S209 Restore the adjusted priority of at least one thread and wait for the next round of resource scheduling.
- relevant information such as thread status, running time, priority, IO resource usage, network resource usage, etc. can be counted, so that it is possible to know which threads are related to each other. If one thread is in the wait state due to system resources such as IO and network, and another thread is in the runnable state (the thread in the runnable state can be executed, but cannot be executed because the time slice is used up), it indicates that the thread in the runnable state is very likely Because the time slice cannot be run, another thread is waiting, so the priority in the waiting state can be passed to the runnable thread, so that the runnable thread has time slice execution.
- the present disclosure proposes a terminal, which will be described below with reference to this embodiment.
- FIG. 3 is a schematic diagram of the composition of a terminal according to Embodiment 3 of the present disclosure.
- the terminal includes a monitoring module 301 , a detection module 302 , and an adjustment module 303 .
- the monitoring module 301 is configured to monitor the status of at least one thread.
- the detection module 302 is configured to detect the running state and associated state of each thread in the same process when the monitoring module 301 monitors that at least one thread is in a preset blocking state.
- the adjustment module 303 is configured to adjust the priority of one or at least two threads in the same process according to the running state and associated state of each thread.
- At least one thread may include: a thread that calls a process scheduling function and needs to wait for system resources to suspend running; and/or, when there is an interrupted or abnormal process in the current instruction executed by the CPU, and in the current instruction
- the thread that executes the process scheduling function For example, after the CPU executes the current instruction and before executing the next instruction, it detects that an interrupt or exception occurs after the execution of the current instruction, and compares the process priority of the interrupt or exception with the process priority of the next instruction. When the priority is higher than the process priority of the next instruction, the interrupt service routine will be executed, and when the interrupt is returned, the thread of the process scheduling function will be executed.
- the calling process scheduling function can be schedule().
- the IO flag can be set before calling the process scheduling function. At this time, it can be determined whether the thread is a state switch caused by IO resources.
- the thread When the thread uses network resources, it will call the socket socket interface. Some flags can be added to the socket interface. When the thread state switches, you can know whether the thread is blocked due to network resources.
- monitoring the state of at least one thread may include: detecting that at least one thread implements a waiting policy; or, detecting that at least one thread implements a sleep policy, and the sleep time exceeds a first preset duration, and at least one thread is in the waiting state Transfer to the ready state; or, detect that at least one thread executes the strategy of waiting to call the current thread and continue to execute the next thread after the execution is completed, and the waiting time exceeds the second preset time length, and at least one thread is transferred from the waiting state to the ready state; or , it is detected that at least one thread issues a request to obtain input or output resources, and at least one thread transitions from the waiting state to the ready state.
- the waiting strategy is the wait() method, which allows the current thread to suspend execution and release the object lock flag.
- the sleep strategy is the sleep() method, which makes the current thread suspend execution for a period of time, allowing other threads to have the opportunity to continue execution, but it does not release the object lock.
- the strategy of waiting for the execution of the current thread to continue to execute the next thread is the join() method, so that the thread that calls this method is executed before that, that is, waits for the thread that calls this method to finish executing before continuing to execute.
- the preset blocking state in this embodiment may include: blocking because the system resource cannot be obtained or the thread voluntarily giving up the CPU.
- the system resources include at least one of the following: network resources and I/O resources.
- the system resources may also include memory, CPU resources, and the like.
- Adjusting the priority of at least one thread in each thread according to the running state and priority of each thread may further include: when each thread has a third thread in a ready state and a fourth thread in a waiting state, confirming the third thread The priority of the thread and the fourth thread; when the priority of the third thread is lower than that of the fourth thread, and the third thread and the fourth thread wake up from each other, the priority of the third thread is adjusted to be before the fourth thread.
- the information of each thread of the same process is counted, and according to the statistical information, it is determined whether there is a thread in the ready-runnable state in the current process that blocks a thread with a higher priority than the thread in the ready-runnable state.
- the statistical information of each thread of the same process includes: the running state of the thread, the time slice, the priority, and the information that the threads wake up each other before. Among them, if it is found that two threads frequently wake up each other, one is in the runnable state and the other is in the wait state, the thread in the wait state is largely because the thread in the runnable state cannot be executed, and the priority of the runnable thread is increased. Priority access to resources.
- the statistical information can also use the external proc of the operating system or the sys file system node to output thread status, scheduling information, IO information, network information, etc., and external applications can generate intelligent policies based on these information and input them to the system to make priority transfer more intelligent. .
- the process may further include: waiting for system resource allocation to run according to the adjusted priority of each thread The time slice of each thread is processed; the priority of each thread that is adjusted is restored.
- the terminal includes a monitoring module, a detection module, and an adjustment module.
- the monitoring module monitors that at least one thread is in a preset blocking state
- the detection module detects the running state and associated state of each thread in the same process
- the adjustment module adjusts the priority of one or at least two threads in the same process according to the detected running state and associated state of each thread in the same process. Dynamically adjust thread priority to improve system performance.
- the method for adjusting thread priority of the present disclosure can realize dynamic adjustment of thread priority and improve system performance.
- the terminal of the present disclosure will be described below with reference to an application scenario.
- FIG. 4 is a schematic diagram of the composition of a terminal according to Embodiment 4 of the present disclosure.
- the terminal includes: a monitoring/processing module 401 , a state management module 402 , an intelligent policy module 403 , an optimization module 404 and a recovery module 405 .
- the monitoring/processing module 401 monitors the running state of the thread. According to different conditions of the thread in the execution process, at least three different running states can be defined, as shown in FIG. 5 .
- the thread in the running state will enter the waiting state due to the occurrence of the waiting event.
- the thread in the waiting state will enter the ready state, and the scheduling policy of the processor will cause the switching between the running state and the ready state, including the following each embodiment.
- the CPU For passive calls, after the CPU executes the current instruction, before executing the next instruction, the CPU needs to determine whether an interrupt or exception occurs after the execution of the current instruction. If an interrupt occurs, the CPU will compare the priority of the incoming interrupt with the priority of the current process. If the priority of the new task is higher, the interrupt service routine will be executed. When the interrupt is returned, the thread scheduling function schedule will be executed, which needs to be done. monitor.
- the IO flag will be set before calling the schedule function. At this time, it can be judged whether the thread is a state switch caused by IO resources.
- the state management module 402 is responsible for the current states of various threads in the thread pool, namely wait, runnable, running, and block.
- the intelligent strategy module 403 is responsible for counting the running status and time of each thread, and making corresponding plans.
- the optimization module 404 dynamically adjusts the priority of the thread.
- the restoration module 405 restores the default running state of the thread and waits for resource scheduling.
- the present disclosure can dynamically adjust the priority of threads, schedule resources and release resources to the greatest extent through the collection of thread state information in the early stage, according to the running state and dynamic statistical information of time, so as to improve the resource waiting time of the application program and improve the It is one of the factors that affects the collection performance the most, especially for mobile phones with smaller memory and more applications installed, the more obvious the performance improvement effect will be. Especially for mobile phones with small memory, it can greatly reduce the occurrence of IO and improve the fluency of mobile phones.
- the present disclosure may also be used for future in-vehicle products, computers, tablet computers, and the like.
- This embodiment also provides a terminal, as shown in FIG. 6 , which includes a processor 601 , a memory 602 and a communication bus 603 .
- the communication bus 603 is configured to implement connection communication between the processor 601 and the memory 602 .
- the processor 601 is configured to execute one or more computer programs stored in the memory 602 to implement at least one step in the method for adjusting thread priority in the first embodiment or the second embodiment.
- Embodiments of the present disclosure also provide a computer-readable storage medium included in any method or technology for storing information, such as computer-readable instructions, data structures, computer program modules, or other data Implemented volatile or nonvolatile, removable or non-removable media.
- Computer-readable storage media include but are not limited to RAM (Random Access Memory, random access memory), ROM (Read-Only Memory, read-only memory), EEPROM (Electrically Erasable Programmable Read Only Memory, electrically erasable programmable read-only memory) ), flash memory or other memory technology, CD-ROM (Compact Disc Read-Only Memory), digital versatile disk (DVD) or other optical disk storage, magnetic cartridges, magnetic tape, magnetic disk storage or other magnetic storage devices, Or any other medium that can be used to store the desired information and that can be accessed by a computer.
- RAM Random Access Memory
- ROM Read-Only Memory
- EEPROM Electrically Erasable Programmable Read Only Memory
- flash memory or other memory technology
- CD-ROM Compact Disc Read-Only Memory
- DVD digital versatile disk
- the computer-readable storage medium in this embodiment may be used to store one or more computer programs, and the stored one or more computer programs may be executed by a processor, so as to realize the adjustment thread priority in the first embodiment or the second embodiment above at least one step of the method.
- the functional modules/units in the system, and the device can be implemented as software (which can be implemented by computer program codes executable by a computing device). ), firmware, hardware, and their appropriate combination.
- the division between functional modules/units mentioned in the above description does not necessarily correspond to the division of physical components; for example, one physical component may have multiple functions, or one function or step may be composed of several physical components Components execute cooperatively.
- Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor or microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit .
- communication media typically embodies computer readable instructions, data structures, computer program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and can include any information delivery, as is well known to those of ordinary skill in the art medium. Therefore, the present disclosure is not limited to any particular combination of hardware and software.
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
Description
Claims (10)
- 一种调整线程优先级的方法,其中,所述方法包括:监控至少一个线程的状态;当监控到所述至少一个线程处于预设阻塞状态时,检测同一进程中的各线程的运行状态和关联状态;根据所述各线程的运行状态和关联状态对所述同一进程中的一个或至少两个线程的各线程进行优先级调整。
- 如权利要求1所述调整线程优先级的方法,其中,所述至少一种线程包括:调用进程调度函数,且需要等待系统资源而暂停运行的线程;和/或,当CPU执行的当前指令中有中断或异常的进程,且所述当前指令中的中断或异常的进程优先级高于所述CPU执行下一条指令的进程优先级时,执行进程调度函数的线程。
- 如权利要求1所述调整线程优先级的方法,其中,所述监控至少一个线程的状态包括:检测所述至少一个线程执行等待策略,所述至少一个线程为等待状态;或,检测到所述至少一个线程执行休眠策略,且休眠时间超过第一预设时长,所述至少一个线程由等待状态转入就绪状态;或,检测到所述至少一个线程执行等待调用当前线程执行完毕后继续执行下一线程的策略,且等待时间超过第二预设时长,所述至少一个线程由等待状态转入就绪状态;或,检测到所述至少一个线程发出获取输入或输出资源的请求,所述至少一个线程由等待状态转入就绪状态。
- 如权利要求1-3任一项所述调整线程优先级的方法,其中,所述根据所述各线程的运行状态和关联状态对所述同一进程中的一个或至少两个线程进行优先级调整包括:确认各线程的优先级;根据所述各线程的运行状态、所述优先级调整各线程中至少一个线程的优先级。
- 如权利要求4所述调整线程优先级的方法,其中,所述根据所述各线程的运行状态、优先级来调整各线程中至少一个线程的优先级包括:当各线程中有处于就绪状态的第一线程,以及处于等待状态的第二线程时,确认第一线程与第二线程的优先级;当第一线程的优先级低于第二线程时,将第一线程的优先级调整至所述第二线程之前。
- 如权利要求4所述调整线程优先级的方法,其中,所述根据所述各线程的运行状态、优先级来调整各线程中至少一个线程的优先级包括:当各线程中有处于就绪状态的第三线程,以及处于等待状态的第四线程时,确认第三线程与第四线程的优先级;当第三线程的优先级低于第四线程,所述第三线程和所述第四线程互相唤醒时,将第三线程的优先级调整至所述第四线程之前。
- 如权利要求1-3任一项所述调整线程优先级的方法,其中,所述根据所述各线程的运行状态和关联状态对所述同一进程中的一个或至少两个线程进行优先级调整之后还包括:根据调整后的各线程的优先级,等待系统资源分配运行的时间片对各线程进行处理;恢复被调整的各线程的优先级。
- 一种终端,其中,所述终端包括:监控模块,配置为监控至少一个线程的状态;检测模块,配置为当所述监控模块监控到所述至少一个线程处于预设阻塞状态时,检测同一进程中的各线程的运行状态和关联状态;调整模块,配置为根据所述各线程的运行状态和关联状态对所述同一进程中的一个或至少两个线程进行优先级调整。
- 一种终端,其中,所述终端包括:处理器;存储器;通信总线,配置为实现处理器和存储器之间的连接通信,所述处理器配置为执行存储器中存储的一个或者多个计算机程序,以实现如权利要求1至7中任一项所述的调整线程优先级方法的步骤。
- 一种计算机可读存储介质,其中,所述计算机可读存储介质存储有一个或者多个计算机程序,所述一个或者多个计算机程序可被一个或者多个处理器执行,以实现如权利要求1至7中任一项所述的调整线程优先级方法的步骤。
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
US18/036,145 US20230409391A1 (en) | 2020-11-09 | 2021-11-03 | Thread priority adjusting method, terminal, and computer-readable storage medium |
EP21888559.8A EP4242842A4 (en) | 2020-11-09 | 2021-11-03 | EXECUTION THREAD PRIORITY SETTING METHOD, TERMINAL AND COMPUTER READABLE STORAGE MEDIUM |
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011238906.9A CN114461353A (zh) | 2020-11-09 | 2020-11-09 | 调整线程优先级的方法、终端及计算机可读存储介质 |
CN202011238906.9 | 2020-11-09 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2022095862A1 true WO2022095862A1 (zh) | 2022-05-12 |
Family
ID=81403904
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2021/128287 WO2022095862A1 (zh) | 2020-11-09 | 2021-11-03 | 调整线程优先级的方法、终端及计算机可读存储介质 |
Country Status (4)
Country | Link |
---|---|
US (1) | US20230409391A1 (zh) |
EP (1) | EP4242842A4 (zh) |
CN (1) | CN114461353A (zh) |
WO (1) | WO2022095862A1 (zh) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118567744A (zh) * | 2022-11-10 | 2024-08-30 | 荣耀终端有限公司 | 应用程序运行的方法及电子设备 |
CN117112241B (zh) * | 2023-10-24 | 2024-02-06 | 腾讯科技(深圳)有限公司 | 调度优先级调整方法、装置、设备及存储介质 |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1276887A (zh) * | 1997-10-23 | 2000-12-13 | 国际商业机器公司 | 多线程处理器系统中的线程切换控制 |
US20070198980A1 (en) * | 2006-02-22 | 2007-08-23 | Samsung Electronics Co., Ltd. | Apparatus for forcibly terminating thread blocked on input/output operation and method for the same |
CN108509260A (zh) * | 2018-01-31 | 2018-09-07 | 深圳市万普拉斯科技有限公司 | 线程识别处理方法、装置、计算机设备和存储介质 |
CN109992436A (zh) * | 2017-12-29 | 2019-07-09 | 华为技术有限公司 | 线程阻塞检测方法及设备 |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5247675A (en) * | 1991-08-09 | 1993-09-21 | International Business Machines Corporation | Preemptive and non-preemptive scheduling and execution of program threads in a multitasking operating system |
AU731871B2 (en) * | 1996-11-04 | 2001-04-05 | Sun Microsystems, Inc. | Method and apparatus for thread synchronization in object-based systems |
-
2020
- 2020-11-09 CN CN202011238906.9A patent/CN114461353A/zh active Pending
-
2021
- 2021-11-03 WO PCT/CN2021/128287 patent/WO2022095862A1/zh active Application Filing
- 2021-11-03 US US18/036,145 patent/US20230409391A1/en active Pending
- 2021-11-03 EP EP21888559.8A patent/EP4242842A4/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1276887A (zh) * | 1997-10-23 | 2000-12-13 | 国际商业机器公司 | 多线程处理器系统中的线程切换控制 |
US20070198980A1 (en) * | 2006-02-22 | 2007-08-23 | Samsung Electronics Co., Ltd. | Apparatus for forcibly terminating thread blocked on input/output operation and method for the same |
CN109992436A (zh) * | 2017-12-29 | 2019-07-09 | 华为技术有限公司 | 线程阻塞检测方法及设备 |
CN108509260A (zh) * | 2018-01-31 | 2018-09-07 | 深圳市万普拉斯科技有限公司 | 线程识别处理方法、装置、计算机设备和存储介质 |
Non-Patent Citations (1)
Title |
---|
See also references of EP4242842A4 |
Also Published As
Publication number | Publication date |
---|---|
EP4242842A1 (en) | 2023-09-13 |
EP4242842A4 (en) | 2024-04-24 |
CN114461353A (zh) | 2022-05-10 |
US20230409391A1 (en) | 2023-12-21 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9027027B2 (en) | Thread management based on device power state | |
US8239869B2 (en) | Method, system and apparatus for scheduling computer micro-jobs to execute at non-disruptive times and modifying a minimum wait time between the utilization windows for monitoring the resources | |
CN107491346B (zh) | 一种应用的任务处理方法、装置及系统 | |
US20120210104A1 (en) | Suspendable interrupts for processor idle management | |
US8056083B2 (en) | Dividing a computer job into micro-jobs for execution | |
CN111209110B (zh) | 一种实现负载均衡的任务调度管理方法、系统和存储介质 | |
WO2022095862A1 (zh) | 调整线程优先级的方法、终端及计算机可读存储介质 | |
CN111897637B (zh) | 作业调度方法、装置、主机及存储介质 | |
WO2017156676A1 (zh) | 一种针对应用的处理方法、装置及智能终端 | |
US6820263B1 (en) | Methods and system for time management in a shared memory parallel processor computing environment | |
CN112346834B (zh) | 数据库的请求处理方法和装置、电子设备和介质 | |
US20180329750A1 (en) | Resource management method and system, and computer storage medium | |
US8132171B2 (en) | Method of controlling thread access to a synchronization object | |
CN108572898A (zh) | 一种控制接口的方法、装置、设备、以及存储介质 | |
CN112817772A (zh) | 一种数据通信方法、装置、设备及存储介质 | |
CN111538585A (zh) | 一种基于node.js的服务器进程调度方法、系统和装置 | |
US20130326528A1 (en) | Resource starvation management in a computer system | |
US9229716B2 (en) | Time-based task priority boost management using boost register values | |
CN114461365A (zh) | 一种进程调度处理方法、装置、设备和存储介质 | |
EP2490100A1 (en) | Suspendable interrupts for processor idle management | |
CN118051320A (zh) | 线程池任务执行控制方法、装置、设备及存储介质 | |
AU2007261611A2 (en) | Computer micro-jobs | |
CN115292012A (zh) | 线程池的管理方法及系统、智能终端、存储介质 | |
CN110769046B (zh) | 一种报文获取方法、装置、电子设备及机器可读存储介质 | |
JP2007323256A (ja) | 割込制御方法および情報処理装置 |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 21888559 Country of ref document: EP Kind code of ref document: A1 |
|
WWE | Wipo information: entry into national phase |
Ref document number: 18036145 Country of ref document: US |
|
WWE | Wipo information: entry into national phase |
Ref document number: 2021888559 Country of ref document: EP |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
ENP | Entry into the national phase |
Ref document number: 2021888559 Country of ref document: EP Effective date: 20230609 |