Thread scheduling method and device, electronic equipment and computer readable storage medium
By introducing scheduling methods of supervised queues and supervised threads into the operating system, other thread response delay problems caused by long-term execution of high priority threads are solved, processor utilization and thread efficiency are improved, and task throughput of the operating system is ensured. .
Patent Information
- Application Number
- CN202310723744.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-16
- Publication Date
- 2024-12-17
AI Technical Summary
In existing operating systems, long-term execution of threads with high priority causes other critical threads to fail to respond in time, reducing the operating system's task throughput and processor utilization.
Introduce regulatory queues and regulatory threads, by adding managed threads in ready state to the regulatory queue and scheduling them when the regulatory thread switches to the working state, avoiding long-term processor occupancy, while simulating regular systems in hibernation state Interrupt to ensure timely responses from other threads.
It improves the processor utilization rate and the processing efficiency of other ordinary threads, avoids response delay caused by the long-term occupancy of the processor by managed threads, and ensures the task throughput of the operating system and the timely response of threads.
Smart Images

Figure CN119149181A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of operating systems, and in particular to a thread scheduling method and device, an electronic device, and a computer-readable storage medium. Background Art
[0002] There are usually multiple threads in the operating system, each of which is used to execute different tasks. However, the number of threads that a processor can run simultaneously is limited. In this regard, a set of thread scheduling methods is usually used in related technologies to schedule thread execution to ensure that key tasks can be executed in a timely manner.
[0003] In practice, it is found that in related technologies, multiple threads are usually scheduled based on priority, that is, threads with high priority are run first, and threads with low priority are run later. However, if the task corresponding to the thread with high priority and ready first is more complex and takes a long time to execute, other critical threads may not be responded to in time, thereby reducing the task throughput of the operating system. Summary of the invention
[0004] The embodiments of the present application disclose a thread scheduling method and device, an electronic device, and a computer-readable storage medium, which can intermittently schedule some managed threads to prevent a managed thread from occupying the processor for a long time, so as to ensure that other managed threads can be responded to in a timely manner.
[0005] In a first aspect, an embodiment of the present application discloses a thread scheduling method, which is applied to an operating system. The method includes:
[0006] Adding a managed thread in a ready state to a supervision queue, wherein the managed thread is one or more threads among a plurality of threads included in the operating system, and the managed thread is a thread managed by a supervision thread;
[0007] When there is a managed thread in the supervision queue, the supervision thread is controlled to switch between a working state and a sleeping state, and when the supervision thread is switched to the working state, the managed thread in the supervision queue is scheduled by the supervision thread.
[0008] A second aspect of an embodiment of the present application discloses a thread scheduling device, which is applied to an operating system. The device includes:
[0009] A first adding unit, configured to add a managed thread in a ready state to a supervision queue, wherein the managed thread is one or more threads among a plurality of threads included in the operating system, and the managed thread is a thread managed by a supervision thread;
[0010] The scheduling unit is used to control the supervision thread to switch between a working state and a sleeping state when there is a managed thread in the supervision queue, and to schedule the managed thread in the supervision queue through the supervision thread when the supervision thread switches to the working state.
[0011] A third aspect of the present application discloses an electronic device, including:
[0012] A memory storing executable program code;
[0013] a processor coupled to the memory;
[0014] The processor calls the executable program code stored in the memory to execute the thread scheduling method disclosed in the first aspect of the embodiment of the present application.
[0015] A fourth aspect of an embodiment of the present application discloses a computer-readable storage medium storing a computer program, wherein the computer program enables a computer to execute the thread scheduling method disclosed in the first aspect of an embodiment of the present application.
[0016] Compared with the related art, the embodiments of the present application have the following beneficial effects:
[0017] In the embodiment of the present application, some critical threads that need to be responded to in time can be divided into managed threads, which are different from other ordinary threads in the operating system that are scheduled by the global scheduler, and the managed threads are scheduled by the supervisory thread. Among them, the operating system can also establish a supervisory queue for storing managed threads, and then when there are managed threads in the supervisory queue, the supervisory thread can switch between the working state and the dormant state, and when the supervisory thread switches to the working state, the supervisory thread can schedule the managed threads in the supervisory queue, thereby avoiding a situation where a certain managed thread occupies the processor for a long time, resulting in other managed threads being unable to get a timely response. In addition, after the supervisory thread switches from the dormant state to the working state, only the managed threads in the supervisory queue are scheduled, and the normal operation of other ordinary threads in the operating system will not be affected, that is, the operation of other ordinary threads will not be interrupted, thereby improving the utilization of the processor and the processing efficiency of other ordinary threads. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0019] Figure 1It is a flowchart of a thread scheduling method disclosed in an embodiment of the present application;
[0020] Figure 2 It is a flowchart of another thread scheduling method disclosed in an embodiment of the present application;
[0021] Figure 3 is a schematic diagram of a supervision queue disclosed in an embodiment of the present application;
[0022] Figure 4 is a schematic diagram of a global ready queue and a supervision queue disclosed in an embodiment of the present application;
[0023] Figure 5 It is a flowchart of another thread scheduling method disclosed in an embodiment of the present application;
[0024] Figure 6 It is a scheduling diagram of a managed thread disclosed in an embodiment of the present application;
[0025] Figure 7 It is a scheduling diagram of another managed thread disclosed in an embodiment of the present application;
[0026] Figure 8 It is a structural diagram of a thread scheduling device disclosed in an embodiment of the present application;
[0027] Fig. 9 It is a structural schematic diagram of an electronic device disclosed in an embodiment of the present application. DETAILED DESCRIPTION
[0028] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0029] It should be noted that the terms "first", "second", "third" and "fourth" in the specification and claims of the present application are used to distinguish different objects rather than to describe a specific order. The terms "including" and "having" in the embodiments of the present application and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device including a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0030] The embodiments of the present application disclose a thread scheduling method and device, an electronic device, and a computer-readable storage medium, which can intermittently schedule only some managed threads to avoid a managed thread occupying the processor for a long time, so as to ensure that other managed threads can be responded to in a timely manner.
[0031] The technical solution of the present application will be described in detail below in conjunction with specific embodiments.
[0032] In order to more clearly illustrate a thread scheduling method disclosed in an embodiment of the present application, the thread scheduling method in the related art is first introduced below.
[0033] In the related art, in order to ensure that key tasks can be responded to in a timely manner, embedded operating systems, such as real-time operating systems (RTOS), generally use priority-based scheduling to schedule threads, that is, whenever a higher priority thread is ready, it always preempts the currently running low priority thread; at the same time, the operating system generally uses a time slice round-robin scheduling method to schedule threads of the same priority, that is, the operating system will generate a periodic (for example, every 10ms, every 15ms) global timed system interrupt (SysTick, system tick), and then the operating system can check whether the time slice (that is, a certain duration, the specific value can be dynamically adjusted according to the running requirements of the thread) allocated to the running thread during each interruption is used up. If it is exhausted, other ready threads of the same priority are selected to run, so that threads of the same priority are fairly scheduled, reducing the response time of the thread. However, the time slice round-robin scheduling method requires periodic system interrupts, which not only increases the power consumption of the operating system, but also causes the running threads in the operating system to be interrupted intermittently, thereby reducing the actual utilization of the processor.
[0034] In this regard, in the related art, the operating system can also schedule threads using an event-driven priority scheduling method, that is, the operating system selects other threads to run according to priority only when the running thread is blocked, awakened, or relinquished the processor. However, in practice, it is found that although the event-driven priority scheduling method does not introduce system interrupts, if the task corresponding to the first ready thread is more complex and takes a long time to execute, other threads at the same priority level will not receive a timely response, which will cause the task throughput of the operating system to decrease, or even cause large-scale task timeouts.
[0035] In this regard, an embodiment of the present application provides a thread scheduling method, which can divide some critical threads that need to be responded to in a timely manner into managed threads, which are different from other ordinary threads in the operating system that are scheduled by the global scheduler, and the managed threads are scheduled by the supervisory thread. Among them, the operating system can also establish a supervisory queue for storing managed threads, and then when there are managed threads in the supervisory queue, the supervisory thread can switch between the working state and the dormant state, and when the supervisory thread switches to the working state, the supervisory thread can schedule the managed threads in the supervisory queue, thereby avoiding a situation where a certain managed thread occupies the processor for a long time, resulting in other managed threads being unable to get a timely response. In addition, after the supervisory thread switches from the dormant state to the working state, only the managed threads in the supervisory queue are scheduled, and the normal operation of other ordinary threads in the operating system will not be affected, that is, the operation of other ordinary threads will not be interrupted, thereby improving the utilization of the processor and the processing efficiency of other ordinary threads.
[0036] Based on this, the thread scheduling method and device, electronic device, and computer-readable storage medium disclosed in the embodiments of the present application are introduced below.
[0037] See also Figure 1 , Figure 1 1 is a flowchart of a thread scheduling method disclosed in an embodiment of the present application. Optionally, the method can be applied to various operating systems, including but not limited to the above-mentioned RTOS system, Windows operating system or Android operating system, etc., which are not limited here. Optionally, the method can include the following steps:
[0038] 102. Add a managed thread in a ready state to a supervision queue. A managed thread is one or more threads among multiple threads included in the operating system. A managed thread is a thread managed by a supervision thread.
[0039] An operating system usually includes multiple threads. A thread is the smallest unit that the operating system can perform computational scheduling on. Different threads can be used to perform different system tasks. In an embodiment of the present application, one or more threads included in the multiple threads of the operating system may be divided into managed threads. Unlike other common threads that are managed by the global scheduler of the operating system, managed threads are managed by supervisory threads.
[0040] The managed threads can be divided by the operating system according to the priority or criticality of the system tasks. For example, the thread currently used to upgrade the operating system needs to be run in time and is a critical task, so the operating system can divide the thread used to upgrade the operating system into a managed thread; optionally, the thread can also be divided into a managed thread when the task it executes has a demand, which is not limited here.
[0041] Optionally, when the operating system determines that there is a managed thread that needs to be scheduled separately, it can establish a corresponding supervision thread and supervision queue, and then the managed thread can be added to the supervision queue when it is in the ready state, so as to facilitate the subsequent supervision thread to manage and schedule the managed thread in the supervision queue. The ready state may refer to a state where the thread can be run at any time. Optionally, the supervision thread may be a thread whose priority is greater than or equal to the priority of the managed thread.
[0042] For example, assuming that a thread of the second priority level needs to be scheduled based on a time slice alone, the operating system can establish a first-priority supervisory thread and a corresponding supervisory queue. Then, when the second-priority thread is in a ready state, it can be added to the supervisory queue to wait for the scheduling of the supervisory thread.
[0043] 104. When there is a managed thread in the supervision queue, control the supervision thread to switch between a working state and a sleeping state, and when the supervision thread switches to the working state, schedule the managed thread in the supervision queue through the supervision thread.
[0044] In an embodiment of the present application, the supervisory thread can be blocked on the supervisory queue when there is no managed thread in the supervisory queue, that is, the supervisory thread can be in a waiting state until there is a managed thread in the supervisory queue, and then the supervisory thread is unblocked and switches between the working state and the sleeping state to simulate the effect of periodically generating system interruptions.
[0045] It is understandable that, in order to reduce the power consumption of the operating system and improve the operating efficiency of other threads, the embodiment of the present application completely turns off the periodic system interrupt function. Optionally, the operating system can control the supervisory thread to switch between the working state and the dormant state according to the target frequency through a timer, thereby simulating the effect of periodically generating system interrupts. Among them, the target frequency can be set by the developer based on a lot of development experience, and the typical value may include every 10ms or every 15ms, which is not limited here.
[0046] It should be noted that ordinary threads usually have three options when they fail to obtain resources (such as semaphores, events): directly return an error, keep waiting for the resource, or wait for a certain period of time, and then perform error handling if it still cannot be obtained. In an operating system with periodic system interrupts, the operation of "waiting for a certain period of time" can be implemented based on periodic system interrupts. However, since the embodiment of the present application completely turns off the periodic system interrupt function, the operating system can also control the thread to wait for a first duration through a timer when the thread fails to obtain the target resource. If the thread cannot obtain the target resource within the first duration, the corresponding error handling is performed. Optionally, the timer can also be used to implement the sleep of other threads for any duration, which is not limited here.
[0047] Furthermore, when the supervisory thread switches from a sleep state to a working state, the supervisory thread can manage and schedule the managed threads in the supervisory queue, for example, moving the managed thread in the supervisory queue to the global ready queue for execution, or, when the managed thread in the global ready queue is in a running state and not in a blocked state, forcibly moving the managed thread from the global ready queue back to the supervisory queue, to avoid the managed thread occupying the processor all the time, thereby causing other managed threads to fail to be responded to in a timely manner.
[0048] Among them, the global ready queue can be a queue that is scheduled and managed by the global scheduler of the operating system. Optionally, the global ready queue can be scheduled using a target thread scheduling method, and the target thread scheduling method is a scheduling method that does not generate system interrupts. Optionally, the scheduling method that does not generate system interrupts can include the above-mentioned event-driven priority scheduling method or the short job priority scheduling method, which is not limited here. Among them, the short job priority scheduling method refers to a scheduling method in which threads that need to run for a shorter time are run first, and threads that need to run for a longer time are run later.
[0049] By implementing the methods disclosed in the above embodiments, some critical threads that need to be responded to in a timely manner can be divided into managed threads. Different from other ordinary threads in the operating system that are scheduled by the global scheduler, managed threads are scheduled by the supervisory thread. Among them, the operating system can also establish a supervisory queue for storing managed threads, and then when there are managed threads in the supervisory queue, the supervisory thread can switch between the working state and the dormant state, and when the supervisory thread switches to the working state, the supervisory thread can schedule the managed threads in the supervisory queue, thereby avoiding the situation where a certain managed thread occupies the processor for a long time, resulting in other managed threads being unable to get a timely response. In addition, after the supervisory thread switches from the dormant state to the working state, only the managed threads in the supervisory queue are scheduled, and the normal operation of other ordinary threads in the operating system will not be affected, that is, the operation of other ordinary threads will not be interrupted, thereby improving the utilization rate of the processor and the processing efficiency of other ordinary threads.
[0050] See also Figure 2 , Figure 2 1 is a flowchart of another thread scheduling method disclosed in an embodiment of the present application. Optionally, the method can be applied to various operating systems, including but not limited to the above-mentioned RTOS system, Windows operating system or Android operating system, etc., which are not limited here. Optionally, the method can include the following steps:
[0051] 202. Add the first managed thread currently in the ready state to the supervision queue, and increase the count value of the semaphore corresponding to the supervision queue by one.
[0052] In the embodiment of the present application, the first managed thread may be any managed thread included in the operating system. Optionally, when the first managed thread completes preliminary preparations and is in a state where it can be run at any time, it can be determined that the first managed thread is in a ready state. Optionally, the preliminary preparations may include, but are not limited to: parameter configuration, obtaining instructions, etc., which are not limited here.
[0053] The following combination Figure 3 To explain, Figure 3 3 is a schematic diagram of a supervision queue disclosed in an embodiment of the present application. In which, when the first managed thread 310 is in a ready state, the first managed thread 310 can be added to the supervision queue 320, and the first managed thread 310 can also send a counting instruction to the semaphore corresponding to the supervision queue 320, so that the count value of the semaphore corresponding to the supervision queue 320 increases by one.
[0054] The semaphore is used to indicate whether there is a managed thread in the ready state in the supervision queue 320. Optionally, when the semaphore is zero, or there is no instance in the semaphore, it means that there is no managed thread in the supervision queue 320, and the supervision thread 330 can be blocked on the semaphore of the supervision queue 320. The supervision thread 330 being blocked on the semaphore of the supervision queue 320 means that: when the semaphore of the supervision queue 320 is zero, the supervision thread 330 is in a waiting state until the semaphore is not zero and the blocking state is released to start working.
[0055] Optionally, when the semaphore is not zero, or there is an instance in the semaphore, it means that there is a managed thread in the supervision queue 320, then the supervision thread 330 can release the blocking state and switch between the working state and the sleeping state according to the target frequency.
[0056] By implementing the above method, the supervisory thread can use the semaphore to assist the supervisory thread in determining whether there is a managed thread in the supervisory queue. If there is a managed thread in the supervisory queue, the supervisory thread can schedule the managed thread immediately, thereby improving the response speed to the managed thread.
[0057] As an optional implementation, when the first managed thread 310 currently in the ready state is added to the supervision queue 320, the operating system can obtain the current virtual count value; further, the operating system can use the current virtual count value as the ready time point corresponding to the first managed thread 310.
[0058] Among them, the virtual count value is a monotonically increasing count value. Each time the supervisory thread 330 switches from a dormant state to a working state, the operating system can increase the virtual count value by one, thereby providing a time reference for the operating system. It should be noted that in an operating system with a system interrupt function turned on, the count value usually increases with the generation of a system interrupt. However, in an embodiment of the present application, in order to reduce the power consumption of the operating system and improve the operating efficiency of other threads, the system interrupt function is in a closed state, and the periodic dormancy of the supervisory thread 330 is used to simulate a system interrupt, and the virtual count value can be increased by one each time the supervisory thread 330 switches from a dormant state to a working state.
[0059] It should be further explained that after each managed thread in the ready state is added to the supervision queue 320, the operating system can use the current virtual calculation value as the ready time point of the managed thread currently added to the supervision queue 320. The ready time point is used to indicate the order in which multiple managed threads switch to the ready state. For example, the ready time point corresponding to the managed thread a in the ready state is 6, and the ready time point corresponding to the managed thread b in the ready state is 8, which means that the managed thread a switches to the ready state before the managed thread b.
[0060] Furthermore, the ready time point can also assist the supervisory thread 330 in determining the order in which the managed threads in the supervisory queue 320 switch to the ready state, and then the supervisory thread 330 can give priority to scheduling the managed thread that switches to the ready state first, thereby avoiding the managed thread that switches to the ready state first from waiting for too long, thereby improving the response speed of the operating system to the managed threads.
[0061] By implementing the above method, the operating system can use the current virtual calculation value as the ready time point of the managed thread currently added to the supervision queue after each managed thread in the ready state is added to the supervision queue, thereby facilitating the subsequent supervision thread to determine the order in which the managed threads in the supervision queue switch to the ready state according to the ready time point, and then the supervision thread can give priority to scheduling the managed thread that switches to the ready state first, thereby avoiding the managed thread that switches to the ready state first waiting for too long, and improving the response speed of the operating system to the managed threads.
[0062] 204. If the count value of the semaphore corresponding to the supervision queue is not zero, it is determined that there is a managed thread in the supervision queue, and the supervision thread is controlled to switch between a working state and a sleeping state.
[0063] 206. When the supervision thread switches to the working state, the managed threads in the supervision queue are scheduled by the supervision thread.
[0064] In an embodiment of the present application, each time the supervisory thread switches from a sleep state to a working state, the operating system may increase the current virtual computing value by one, indicating that the supervisory thread has completed another sleep state, and also indicating that a time slice of a fixed duration has ended.
[0065] As an optional implementation, the operating system may add the managed thread to the supervision queue and manage the managed thread through the supervision thread. Optionally, the supervision thread may use the first thread scheduling method to schedule the managed thread in the supervision queue. Optionally, the first thread scheduling method may include a time slice-based round-robin scheduling method, an earliest deadline priority scheduling method, a random scheduling method, or a completely fair scheduling method, which is not limited here.
[0066] In some other optional embodiments, the operating system can add other common threads except the managed threads among the multiple threads included in the operating system to the global ready queue. The threads in the global ready queue are scheduled by the global scheduler according to the target thread scheduling method. As mentioned above, the target thread scheduling method can be a scheduling method that does not generate system interrupts, which will not be described in detail here.
[0067] By implementing the above method, other ordinary threads except the managed threads can be added to the global ready queue. Since the global ready queue does not generate regular system interruptions, other ordinary threads can be prevented from being interrupted regularly, thereby improving the utilization of the processor and the processing efficiency of other ordinary threads. In addition, when all managed threads are in a blocked state, or there are no managed threads in the supervisory queue, the threads in the entire operating system are scheduled according to the target thread scheduling method, and the operating system no longer generates interruptions, thereby reducing the power consumption of the operating system and improving the utilization of the processor.
[0068] Optionally, the supervisory thread may correspond to the first priority, the managed thread may correspond to the second priority, and the first priority is greater than or equal to the second priority. Optionally, the priorities corresponding to the managed threads may be the same; the common threads may include threads corresponding to the second priority and threads corresponding to other priorities, which are not limited here.
[0069] Preferably, a first priority level that the supervisory thread can correspond to may be greater than a second priority level that the managed thread can correspond to.
[0070] By implementing the above method, the first priority corresponding to the supervisory thread can be greater than or equal to the second priority corresponding to the managed thread, so that the supervisory thread is always executed before the managed thread, thereby improving the scheduling efficiency of the supervisory thread on the managed thread.
[0071] See also Figure 4 , Figure 4 3 is a schematic diagram of a global ready queue and a supervisory queue disclosed in an embodiment of the present application. Among them, the supervisory queue 320 may include multiple managed threads, the supervisory thread 330 corresponds to the first priority, the first priority may be "N-1", and the managed thread 370 corresponds to the second priority, the second priority may be "N". Figure 4 The smaller the value corresponding to the medium priority, the higher the corresponding priority. The global ready queue 350 may also include ordinary threads corresponding to various priorities. It should be noted that Figure 4 This is merely an exemplary illustration for the convenience of explanation and should not be construed as limiting the embodiments of the present application.
[0072] Implementing the methods disclosed in the above embodiments can avoid a situation where a managed thread occupies the processor for a long time, resulting in other managed threads being unable to get a timely response. In addition, the operation of other ordinary threads will not be interrupted regularly, thereby improving the utilization of the processor and the processing efficiency of other ordinary threads; and, after each managed thread in the ready state is added to the supervision queue, the operating system can use the current virtual calculation value as the ready time point of the managed thread currently added to the supervision queue, so as to facilitate the subsequent supervision thread to determine the order of switching to the ready state of each managed thread in the supervision queue according to the ready time point, and then the supervision thread can give priority to scheduling the managed thread that switches to the ready state first, avoiding the managed thread that switches to the ready state first waiting for too long, and improving the response speed of the operating system to the managed thread; and, other ordinary threads except the managed thread can be added to the global ready queue, and since the global ready queue will not generate regular system interruptions, other ordinary threads can be prevented from being interrupted regularly, thereby improving the utilization of the processor and the processing efficiency of other ordinary threads. In addition, when all managed threads are in a blocked state, or there are no managed threads in the supervision queue, the threads in the entire operating system are scheduled according to the target thread scheduling method, and the operating system no longer generates interrupts, thereby reducing the power consumption of the operating system and improving the utilization of the processor; and, the first priority corresponding to the supervision thread can be greater than or equal to the second priority corresponding to the managed thread, so that the supervision thread is always executed before the managed thread, thereby improving the scheduling efficiency of the supervision thread for the managed thread.
[0073] See also Figure 5 , Figure 5 This is a flowchart of another thread scheduling method disclosed in an embodiment of the present application. Optionally, the method can be applied to various operating systems, including but not limited to the above-mentioned RTOS system, Windows operating system or Android operating system, etc., which are not limited here. Optionally, the method can include the following steps:
[0074] 502. Add a managed thread in a ready state to a supervision queue. A managed thread is one or more threads among a plurality of threads included in the operating system. A managed thread is a thread managed by a supervision thread.
[0075] 504. When there is a managed thread in the supervision queue, control the supervision thread to switch between a working state and a sleeping state.
[0076] 506. When the supervisory thread switches to the working state, at least one second managed thread in the supervisory queue is moved to the global ready queue through the supervisory thread. The global ready queue is a queue that adopts the target thread scheduling method. The target thread scheduling method is a scheduling method that does not generate system interruption.
[0077] See also Figure 6 , Figure 6 It is a scheduling diagram of a managed thread disclosed in an embodiment of the present application. Optionally, when the supervisory thread 330 switches to the working state, it can move at least one second managed thread 340 in the supervisory queue 320 to the global ready queue 350, so that the second managed thread 340 runs under the scheduling of the global scheduler corresponding to the global ready queue 350. Among them, the second managed thread 340 can be the managed thread arranged at the front in the supervisory queue 320, or the second managed thread 340 can be the managed thread with the earliest ready time point, which is not limited here. Therefore, the second managed thread 340 with a relatively early ready time point can be run first, avoiding the second managed thread 340 from waiting for too long, thereby improving the response speed to the managed thread. Figure 6 The global ready queue 350 shown may be a queue that adopts the target thread scheduling method as described above, which will not be described in detail here.
[0078] As an optional implementation, when switching to the working state, the supervisory thread can determine whether there is a managed thread in the global ready queue; if there is a managed thread in the global ready queue, the supervisory thread can move at least one second managed thread in the supervisory queue to the global ready queue.
[0079] In another optional implementation, if the third managed thread that was last added to the global ready queue already exists in the global ready queue, the supervisory thread can determine whether the third managed thread that was last added to the global ready queue is in a blocked state. If the third managed thread is in a blocked state, it means that there are no managed threads in the global ready queue that need to be scheduled to run. In this case, the supervisory thread can take out at least one second managed thread from the supervisory queue and move it to the global ready queue. The third managed thread being in a blocked state means that the third managed thread is in a waiting state and will not work again until a trigger condition is detected.
[0080] By implementing the above method, when there is no managed thread in the global ready queue or the managed thread last added to the global ready queue has been blocked, the supervision queue can take out a new managed thread from the supervision queue and add it to the global ready queue to ensure that there is always a managed thread in the global ready queue waiting to be scheduled to run, thereby improving the response speed for the managed thread, the scheduling flexibility of the supervision thread, and the processing efficiency of the processor.
[0081] As another optional implementation, if the third managed thread last added to the global ready queue is in a blocked state, and there are no other managed threads in the supervision queue, the supervision thread can be controlled to block on the supervision queue until a new managed thread is added to the supervision queue. Further, when a new managed thread is added to the supervision queue, the supervision thread can release the supervision state, and when switching to the working state, move the new managed thread in the supervision queue to the global ready queue.
[0082] When implementing the above method, if there are no other managed threads in the supervision queue that can be scheduled to the global ready queue, the supervision thread can be blocked on the supervision queue, so that when a new managed thread is added to the supervision queue, the supervision thread can move the newly added managed thread to the global ready queue as soon as possible, thereby improving the response speed for the managed thread.
[0083] See also Figure 7 , Figure 7 Optionally, if the third managed thread 360 last added to the global ready queue 350 is not in a blocked state, and the third managed thread 360 is in a running state, the supervisory thread 330 can put the third managed thread 360 in the global ready queue 350 back into the supervisory queue 320.
[0084] Optionally, for each time the third managed thread 360 runs in the global ready queue for a time slice, the count value of the number of runs corresponding to the third managed thread 360 may be increased by one. Optionally, if the current count value of the number of runs corresponding to the third managed thread 360 increases compared to the previous count value, it can be determined that the third managed thread 360 is still in the running state. The previous count value is the count value of the number of runs corresponding to the third managed thread 360 detected when the supervisory thread last switched to the working state.
[0085] It is understandable that the global ready queue 350 does not periodically generate a system interrupt to reschedule the third managed thread 360. In this case, if the third managed thread 360 is in a running state and is not in a blocked state, the third managed thread 360 will continue to run without intervention, resulting in the inability to respond to other managed threads in the supervision queue 320 in a timely manner. Optionally, the supervision thread 330 can put the third managed thread 360 in the global ready queue 350 back into the supervision queue 320.
[0086] Optionally, the supervisor thread 330 may move other managed threads in the supervisor queue 320 except the third managed thread 360 to the global ready queue 350. In an optional implementation, in the case where the supervisor thread 330 always moves the managed thread arranged at the front in the supervisor queue 320 to the global ready queue 350, the supervisor thread 330 may put the third managed thread 360 in the global ready queue 350 at the end of the supervisor queue 320 to avoid the supervisor thread 330 taking precedence over other managed threads and move the third managed thread 360 to the global ready queue 350 again.
[0087] Furthermore, the operating system may obtain the current virtual count value and use the current virtual count value as the ready time point of the third managed thread 360. By using the current virtual count value as the ready time point of the third managed thread 360, the ready time point of the third managed thread 360 rejoining the supervision queue 320 may be later than the ready time points of other managed threads in the supervision queue 320, and thus, in the case where the supervision thread 330 always moves the managed thread with the earliest ready time point in the supervision queue 320 to the global ready queue 350, it may be avoided that the supervision thread 330 takes precedence over other managed threads and the third managed thread 360 is moved to the global ready queue 350 again.
[0088] By implementing the above method, the supervisory thread can force the third managed thread that has been running in the global ready queue to be put back into the supervisory queue, so that other managed threads in the supervisory queue can be scheduled to run in the global ready queue, thereby avoiding the situation where other managed threads in the supervisory queue cannot be responded to in time.
[0089] As another optional implementation, if the third managed thread last added to the global ready queue is not in a blocked state and the third managed thread is not in a running state, the supervisory thread may be controlled to switch to a dormant state.
[0090] Among them, if the current count value of the number of runs corresponding to the third managed thread does not increase compared to the previous count value, it can be determined that the third managed thread is not in a running state. Optionally, if the current count value of the number of runs corresponding to the third managed thread is zero, it can also be determined that the third managed thread is not in a running state. It can be understood that if the third managed thread is not in a blocked state, it means that it can still run when the third managed thread is scheduled, but the third managed thread is not in a running state at present, which means that the third managed thread may still be waiting for the global scheduler to schedule and then run. In this regard, the supervisory thread may not schedule the third managed thread, but directly switch to a dormant state to save power consumption.
[0091] Optionally, when the control supervisory thread is switched to the sleep state, the current virtual count value may be increased by one to indicate that the supervisory thread is in a periodic sleep state again.
[0092] By implementing the above method, when the third managed thread is not in a blocked state and is not in a running state, it can be not scheduled, thereby avoiding the situation where the third managed thread is removed from the global ready queue before it is run, thereby ensuring that all managed threads added to the global ready queue can be scheduled and run. In addition, when it is determined that there is no scheduling demand for managed threads, the supervisory thread can directly switch to a dormant state to save power consumption.
[0093] As an optional implementation, when the supervisory thread is in a dormant state, if the third managed thread last added to the global ready queue is in a blocked state, the supervisory thread can be immediately controlled to switch to a working state to schedule the managed thread, for example: taking a new managed thread from the supervisory queue and putting it into the global ready queue.
[0094] By implementing the above method, when the third managed thread added to the global ready queue is in a blocked state, the supervisory thread in the dormant state no longer needs to wait for the end of the dormant period to switch to the working state, but can immediately switch to the working state to schedule the managed thread, so as to avoid the situation where there are no managed threads in the global ready queue to be scheduled, while there are managed threads in the supervisory queue waiting for scheduling, thereby improving the response speed for the managed threads and improving the utilization of the processor.
[0095] Implementing the methods disclosed in the above embodiments can avoid the situation where a managed thread occupies the processor for a long time, resulting in other managed threads being unable to respond in time. In addition, the operation of other ordinary threads will not be interrupted periodically, thereby improving the utilization rate of the processor and the processing efficiency of other ordinary threads; and, when there is no managed thread in the global ready queue, or the managed thread last added to the global ready queue is blocked, the supervision queue can take out a new managed thread from the supervision queue and add it to the global ready queue to ensure that there is always a managed thread in the global ready queue waiting to be scheduled to run, thereby improving the response speed for the managed thread, the scheduling flexibility of the supervision thread, and the processing efficiency of the processor; and, if there is no other managed thread in the supervision queue that can be scheduled to the global ready queue, the supervision thread can be blocked on the supervision queue to be added when a new managed thread is added In the case where the third managed thread is in the supervision queue, the supervision thread can move the newly added managed thread to the global ready queue as soon as possible, thereby improving the response speed for the managed thread; and, the supervision thread can force the third managed thread that has been running in the global ready queue to be put back into the supervision queue, so that other managed threads in the supervision queue can be scheduled to run in the global ready queue, thereby avoiding the situation that other managed threads in the supervision queue cannot be responded to in time; and, when the third managed thread is not in a blocked state and the third managed thread is not in a running state, it can be not scheduled, thereby avoiding the situation that the third managed thread is moved out of the global ready queue before it runs, thereby ensuring that the managed threads added to the global ready queue can be scheduled and run. In addition, when it is determined that there is no demand for scheduling managed threads, the supervisory thread can directly switch to a sleep state to save power consumption; and, when the third managed thread added to the global ready queue is in a blocked state, the supervisory thread in the sleep state no longer has to wait for the sleep time to end before switching to a working state, but can immediately switch to a working state to schedule the managed thread, so as to avoid the situation where there are no managed threads in the global ready queue to be scheduled, while there are managed queues in the supervisory queue waiting for scheduling, thereby improving the response speed to the managed threads and improving the utilization of the processor.
[0096] See also Figure 8 , Figure 8 80 is a schematic diagram of the structure of a thread scheduling device disclosed in an embodiment of the present application. Optionally, the device can apply various operating systems, including but not limited to the above-mentioned RTOS system, Windows operating system or Android operating system, etc., which are not limited here. Optionally, the device may include a first adding unit 802 and a scheduling unit 804, wherein:
[0097] A first adding unit 802 is used to add a managed thread in a ready state to a supervision queue, wherein a managed thread is one or more threads among a plurality of threads included in the operating system, and a managed thread is a thread managed by a supervision thread;
[0098] The scheduling unit 804 is used to control the supervision thread to switch between the working state and the sleeping state when there is a managed thread in the supervision queue, and to schedule the managed thread in the supervision queue through the supervision thread when the supervision thread switches to the working state.
[0099] By implementing the above device, some critical threads that need to be responded to in a timely manner can be divided into managed threads. Different from other ordinary threads in the operating system that are scheduled by the global scheduler, managed threads are scheduled by the supervisory thread. Among them, the operating system can also establish a supervisory queue for storing managed threads, and then when there are managed threads in the supervisory queue, the supervisory thread can switch between the working state and the dormant state, and when the supervisory thread switches to the working state, the supervisory thread can schedule the managed threads in the supervisory queue, thereby avoiding the situation where a certain managed thread occupies the processor for a long time, resulting in other managed threads not being able to get a timely response. In addition, after the supervisory thread switches from the dormant state to the working state, only the managed threads in the supervisory queue are scheduled, and it will not affect the normal operation of other ordinary threads in the operating system, that is, the operation of other ordinary threads will not be interrupted, thereby improving the utilization rate of the processor and the processing efficiency of other ordinary threads.
[0100] As an optional implementation, the first adding unit 802 is further configured to add the first managed thread currently in the ready state to the supervision queue, and increase the count value of the semaphore corresponding to the supervision queue by one;
[0101] Furthermore, the scheduling unit 804 is further configured to determine that there is a managed thread in the supervision queue when the count value of the semaphore corresponding to the supervision queue is not zero, and control the supervision thread to switch between the working state and the sleeping state.
[0102] By implementing the above device, the supervisory thread can use semaphores to assist the supervisory thread in determining whether there is a managed thread in the supervisory queue. If there is a managed thread in the supervisory queue, the supervisory thread can schedule the managed thread immediately, thereby improving the response speed to the managed thread.
[0103] As an optional implementation, the first adding unit 802 is also used to add the first managed thread that is currently in the ready state to the supervision queue, and obtain the current virtual count value, the virtual count value is used to indicate the cumulative number of times the supervision thread switches from the sleep state to the working state; and, use the current virtual count value as the ready time point corresponding to the first managed thread and the ready time points corresponding to the multiple managed threads respectively, which are used to indicate the order in which the multiple managed threads switch to the ready state.
[0104] By implementing the above device, the operating system can use the current virtual calculation value as the ready time point of the managed thread currently added to the supervision queue after each managed thread in the ready state is added to the supervision queue, thereby facilitating the subsequent supervision thread to determine the order in which the managed threads in the supervision queue switch to the ready state according to the ready time point, and then the supervision thread can give priority to scheduling the managed thread that switches to the ready state first, thereby avoiding the managed thread that switches to the ready state first waiting for too long, and improving the response speed of the operating system to the managed threads.
[0105] As an optional implementation, Figure 8 The device shown may also include an increasing unit not shown, wherein:
[0106] The counting unit is used to increase the current virtual count value by one each time the supervision thread switches to the working state.
[0107] By implementing the above device, each time the supervisory thread switches to the working state, the current virtual count value can be increased by one, so as to increase a time reference value for the operating system.
[0108] As an optional implementation, the scheduling unit 804 is also used to move at least one second managed thread in the supervision queue to the global ready queue through the supervision thread. The global ready queue is a queue that adopts the target thread scheduling method. The target thread scheduling method is a scheduling method that does not generate system interrupts.
[0109] As an optional implementation, the scheduling unit 804 is further configured to move at least one second managed thread in the supervision queue to the global ready queue through the supervision thread when no managed thread exists in the global ready queue;
[0110] Alternatively, if the third managed thread last added to the global ready queue is in a blocked state, at least one second managed thread in the supervision queue is moved to the global ready queue by the supervision thread.
[0111] By implementing the above device, the supervision queue can take out a new managed thread from the supervision queue and add it to the global ready queue when there is no managed thread in the global ready queue or the managed thread last added to the global ready queue has been blocked, so as to ensure that there is always a managed thread in the global ready queue waiting to be scheduled to run, thereby improving the response speed for the managed thread, the scheduling flexibility of the supervision thread, and the processing efficiency of the processor.
[0112] As an optional implementation, the scheduling unit 804 is also used to control the supervisory thread to switch to a blocked state until a new managed thread is added to the supervisory queue when the third managed thread last added to the global ready queue is in a blocked state and there are no other managed threads in the supervisory queue.
[0113] When the above device is implemented, if there are no other managed threads in the supervision queue that can be scheduled to the global ready queue, the supervision thread can be blocked on the supervision queue, so that when a new managed thread is added to the supervision queue, the supervision thread can move the newly added managed thread to the global ready queue as soon as possible, thereby improving the response speed to the managed thread.
[0114] As an optional implementation, Figure 8 The device shown may also include an insertion unit and an acquisition unit (not shown), wherein:
[0115] The putting unit is used to put the third managed thread in the global ready queue back into the supervision queue through the supervision thread when the third managed thread last added to the global ready queue is not in a blocked state and the third managed thread is in a running state;
[0116] The acquiring unit is used to acquire the current virtual count value and use the current virtual count value as the ready time point of the third managed thread.
[0117] By implementing the above device, the supervisory thread can force the third managed thread that has been running in the global ready queue to be put back into the supervisory queue, so that other managed threads in the supervisory queue can be scheduled to run in the global ready queue, thereby avoiding the situation where other managed threads in the supervisory queue cannot be responded to in time.
[0118] As an optional implementation, Figure 8 The device shown may also include a sleep unit not shown, wherein:
[0119] The sleep unit is used to control the supervision thread to switch to the sleep state when the third managed thread last added to the global ready queue is not in the blocked state and the third managed thread is not in the running state.
[0120] By implementing the above device, when the third managed thread is not in a blocked state and is not in a running state, it can be not scheduled, thereby avoiding the situation where the third managed thread is removed from the global ready queue before it is run, thereby ensuring that all managed threads added to the global ready queue can be scheduled and run. In addition, when it is determined that there is no scheduling demand for managed threads, the supervisory thread can directly switch to a dormant state to save power consumption.
[0121] As an optional implementation, the scheduling unit 804 is further used to control the supervision thread to switch between the working state and the sleeping state according to the target frequency;
[0122] Alternatively, when the supervisory thread is in the dormant state, if the third managed thread last added to the global ready queue is in the blocked state, the supervisory thread is controlled to switch to the working state.
[0123] By implementing the above device, when the third managed thread added to the global ready queue is in a blocked state, the supervisory thread in the dormant state no longer needs to wait for the end of the dormant period to switch to the working state, but can immediately switch to the working state to schedule the managed thread, so as to avoid the situation where there are no managed threads in the global ready queue to be scheduled, while there are managed threads in the supervisory queue waiting to be scheduled. This can improve the response speed for the managed threads and also improve the utilization rate of the processor.
[0124] As an optional implementation, Figure 8 The device shown may also include a second adding unit not shown, wherein:
[0125] The second adding unit is used to add other common threads except managed threads among the multiple threads included in the operating system to the global ready queue, wherein the threads in the global ready queue are scheduled by the global scheduler according to the target thread scheduling method, and the target thread scheduling method is a scheduling method that does not generate system interrupts.
[0126] By implementing the above device, other ordinary threads except the managed threads can be added to the global ready queue. Since the global ready queue does not generate regular system interruptions, other ordinary threads can be prevented from being interrupted regularly, thereby improving the utilization of the processor and the processing efficiency of other ordinary threads. In addition, when all managed threads are in a blocked state, or there are no managed threads in the supervision queue, the threads in the entire operating system are scheduled according to the target thread scheduling method, and the operating system no longer generates interruptions, thereby reducing the power consumption of the operating system and improving the utilization of the processor.
[0127] As an optional implementation manner, the supervisory thread corresponds to a first priority, the managed thread corresponds to a second priority, and the first priority is greater than or equal to the second priority.
[0128] By implementing the above device, the first priority corresponding to the supervisory thread can be greater than or equal to the second priority corresponding to the managed thread, so that the supervisory thread is always executed before the managed thread, thereby improving the scheduling efficiency of the supervisory thread on the managed thread.
[0129] See also Fig. 9 , Fig. 9 It is a structural schematic diagram of an electronic device disclosed in an embodiment of the present application.
[0130] like Fig. 9 As shown, the electronic device may include:
[0131] A memory 901 storing executable program codes;
[0132] A processor 902 coupled to the memory 901;
[0133] The processor 902 calls the executable program code stored in the memory 901 to execute the thread scheduling method disclosed in the above embodiments.
[0134] An embodiment of the present application discloses a computer-readable storage medium storing a computer program, wherein the computer program enables a computer to execute the thread scheduling method disclosed in the above embodiments.
[0135] The embodiments of the present application also disclose an application publishing platform, wherein the application publishing platform is used to publish a computer program product, wherein when the computer program product runs on a computer, the computer executes part or all of the steps of the method in the above method embodiments.
[0136] It should be understood that the "one embodiment" or "an embodiment" mentioned throughout the specification means that the specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. Those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required for the present application.
[0137] In the various embodiments of the present application, it should be understood that the size of the serial numbers of the above-mentioned processes does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0138] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0139] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0140] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-accessible memory. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a memory and includes several requests for a computer device (which can be a personal computer, a server or a network device, etc., specifically a processor in a computer device) to perform some or all of the steps of the above-mentioned methods of various embodiments of the present application.
[0141] Those skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium, and the storage medium includes a read-only memory (ROM), a random access memory (RAM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electronically erasable rewritable read-only memory (EEPROM), a compact disc (CD-ROM) or other optical disc storage, magnetic disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.
[0142] The thread scheduling method and device, electronic device, and computer-readable storage medium disclosed in the embodiments of the present application are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A thread scheduling method, It is characterized in that The method comprises: Adding a managed thread in a ready state to a supervision queue, wherein the managed thread is one or more threads among a plurality of threads included in the operating system, and the managed thread is a thread managed by a supervision thread; When there is a managed thread in the supervision queue, the supervision thread is controlled to switch between a working state and a sleeping state, and when the supervision thread is switched to the working state, the managed thread in the supervision queue is scheduled by the supervision thread.
2. The method according to claim 1, It is characterized in that The step of adding the managed thread in the ready state to the supervision queue includes: Adding the first managed thread currently in the ready state to the supervision queue, and increasing the count value of the semaphore corresponding to the supervision queue by one; And, when there is a managed thread in the supervision queue, controlling the supervision thread to switch between a working state and a sleeping state includes: If the count value of the semaphore corresponding to the supervision queue is not zero, it is determined that there is a managed thread in the supervision queue, and the supervision thread is controlled to switch between a working state and a sleeping state.
3. The method according to claim 1, It is characterized in that The step of adding the managed thread in the ready state to the supervision queue includes: Adding the first managed thread currently in the ready state to the supervision queue, and obtaining a current virtual count value, where the virtual count value is used to represent the cumulative number of times the supervision thread switches from the sleep state to the working state; The current virtual count value is used as the ready time point corresponding to the first managed thread, and the ready time points corresponding to the multiple managed threads are used to indicate the sequence in which the multiple managed threads switch to the ready state.
4. The method according to claim 3, It is characterized in that The method further comprises: Each time the supervisory thread switches to the working state, the current virtual count value is increased by one.
5. The method according to claim 1, It is characterized in that The step of scheduling the managed threads in the supervision queue by the supervision thread includes: At least one second managed thread in the supervisory queue is moved to a global ready queue by the supervisory thread, wherein a global scheduler corresponding to the global ready queue does not generate a periodic system interrupt when performing thread scheduling.
6. The method according to claim 5, It is characterized in that The step of moving at least one second managed thread in the supervisory queue to a global ready queue by the supervisory thread comprises: In a case where no managed thread exists in the global ready queue, moving at least one second managed thread in the supervisory queue to the global ready queue by the supervisory thread; Alternatively, if the third managed thread last added to the global ready queue is in a blocked state, at least one second managed thread in the supervisory queue is moved to the global ready queue by the supervisory thread.
7. The method according to claim 6, It is characterized in that The method further comprises: If the third managed thread last added to the global ready queue is in a blocked state and there is no managed thread in the supervision queue, the supervision thread is controlled to switch to a blocked state until a new managed thread is added to the supervision queue.
8. The method according to any one of claims 5 to 7, It is characterized in that The controlling the supervisory thread to switch between a working state and a dormant state includes: In the case that the supervisory thread is in the dormant state, if the third managed thread last added to the global ready queue is in the blocked state, the supervisory thread is controlled to switch to the working state.
9. The method according to claim 5, It is characterized in that The method further comprises: If the third managed thread last added to the global ready queue is not in a blocked state, and the third managed thread is in a running state, then the third managed thread in the global ready queue is put back into the supervision queue through the supervision thread; A current virtual count value is obtained, and the current virtual count value is used as the ready time point of the third managed thread.
10. The method according to claim 5, It is characterized in that The method further comprises: If the third managed thread last added to the global ready queue is not in a blocked state, and the third managed thread is not in a running state, the supervisory thread is controlled to switch to the dormant state.
11. The method according to any one of claims 1 to 7, 9 and 10, It is characterized in that The controlling the supervisory thread to switch between a working state and a dormant state includes: The supervision thread is controlled to switch between a working state and a sleeping state according to a target frequency.
12. The method according to any one of claims 1 to 7, 9 and 10, It is characterized in that The method further comprises: Other common threads except the managed thread among the multiple threads included in the operating system are added to a global ready queue, wherein the threads in the global ready queue are scheduled by a global scheduler according to a target thread scheduling method, and the global scheduler does not generate periodic system interrupts when scheduling threads.
13. The method according to any one of claims 1 to 7, 9 and 10, It is characterized in that The supervisory thread corresponds to a first priority, the managed thread corresponds to a second priority, and the first priority is greater than or equal to the second priority.
14. A thread scheduling device, It is characterized in that The device comprises: A first adding unit, configured to add a managed thread in a ready state to a supervision queue, wherein the managed thread is one or more threads among a plurality of threads included in the operating system, and the managed thread is a thread managed by a supervision thread; The scheduling unit is used to control the supervision thread to switch between a working state and a sleeping state when there is a managed thread in the supervision queue, and to schedule the managed thread in the supervision queue through the supervision thread when the supervision thread switches to the working state.
15. An electronic device, It is characterized in that It comprises a memory storing executable program code, and a processor coupled to the memory; wherein the processor calls the executable program code stored in the memory to execute the method according to any one of claims 1 to 13.
16. A computer-readable storage medium storing a computer program, It is characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 13 is implemented.
