Task scheduling method, electronic device and computer program product
Patent Information
- Application Number
- CN202111161588.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-30
- Publication Date
- 2026-09-18
- Estimated Expiration
- 2041-09-30
AI Technical Summary
然而,在计算资源执行任务期间,可能会遇到诸如睡眠、互斥(mutex)、锁、读/写等操作来阻塞该计算资源
Smart Images

Figure CN115904644B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of this disclosure relate to the field of computers, and more specifically, to task scheduling methods, electronic devices, and computer program products. Background Technology
[0002] The task scheduler plays a crucial role in a computing system, responsible for scheduling asynchronous tasks from most critical components. Typically, computing systems utilize kernel customizations to implement task scheduling, maximizing the use of system computing resources to achieve good performance, such as deduplication capabilities. With the development of computing systems, more and more task schedulers have emerged, which do not rely on any kernel customizations and exhibit even better performance. However, during task execution on computing resources, operations such as sleeping, mutexes, locks, and read / write operations may block those resources. Once a computing resource is blocked, another waiting thread's task must wait, which degrades the performance of the computing system. Summary of the Invention
[0003] The embodiments disclosed herein provide a scheme for managing computing resources.
[0004] In a first aspect of this disclosure, a task scheduling method is provided. The method may include, if it is determined that an idle task scheduling token exists, causing a first computing resource in a computing system to acquire the idle task scheduling token as a first task scheduling token to execute a first task in a task queue, wherein tasks in the task queue are executed based on task scheduling tokens in a pre-created set of task scheduling tokens. The method may further include, if it is determined that a second task with a higher priority than the first task is to be executed, causing the first computing resource to discard the first task scheduling token to switch from executing the first task to executing the second task. Furthermore, the method may include, if it is determined that the second task has finished executing, causing the first computing resource to retrieve the first task scheduling token to continue executing the first task.
[0005] In a second aspect of this disclosure, an electronic device is provided, including a processor; and a memory coupled to the processor, the memory having instructions stored therein, the instructions causing the electronic device to perform actions when executed by the processor, the actions including: if it is determined that an idle task scheduling token exists, causing a first computing resource in a computing system to acquire the idle task scheduling token as a first task scheduling token to execute a first task in a task queue, the tasks in the task queue being executed based on task scheduling tokens in a pre-created set of task scheduling tokens; if it is determined that a second task with a higher priority than the first task is to be executed, causing the first computing resource to discard the first task scheduling token to switch from executing the first task to executing the second task; and if it is determined that the second task has finished executing, causing the first computing resource to retrieve the first task scheduling token to continue executing the first task.
[0006] In a third aspect of this disclosure, a computer program product is provided, which is tangibly stored on a computer-readable medium and includes machine-executable instructions that, when executed, cause a machine to perform any step of the method according to the first aspect.
[0007] The summary section is provided to present the chosen concepts in a simplified form, which will be further described in the detailed description below. The summary section is not intended to identify key or principal features of this disclosure, nor is it intended to limit the scope of this disclosure. Attached Figure Description
[0008] The above and other objects, features, and advantages of this disclosure will become more apparent from the accompanying drawings, in which the same or similar reference numerals generally represent the same or similar parts. In the drawings:
[0009] Figure 1 A schematic diagram of an example environment according to an embodiment of the present disclosure is shown;
[0010] Figure 2 A schematic diagram of a task state for task scheduling according to an embodiment of the present disclosure is shown;
[0011] Figure 3 A flowchart of a task scheduling process according to an embodiment of the present disclosure is shown;
[0012] Figure 4 A schematic diagram of thread states for task scheduling according to embodiments of the present disclosure is shown; and
[0013] Figure 5 A block diagram of an example device that can be used to implement embodiments of the present disclosure is shown. Detailed Implementation
[0014] The principles of this disclosure will now be described with reference to several exemplary embodiments shown in the accompanying drawings.
[0015] The term "comprising" and its variations as used herein signify open inclusion, i.e., "including but not limited to". Unless otherwise stated, the term "or" means "and / or". The term "based on" means "at least partially based on". The terms "one example embodiment" and "one embodiment" mean "a set of example embodiments". The term "another embodiment" means "another set of embodiments". The terms "first", "second", etc., may refer to different or the same objects. Other explicit and implicit definitions may also be included below.
[0016] As discussed above, during the execution of a task in a sequence of tasks on a computational resource such as a thread, operations such as sleeping, mutexes, locks, and read / write operations may occur, forcing the computational resource to pause its current task and prioritize the execution of these operations. Once a thread is blocked, other waiting threads must wait, thus degrading the performance of the computational system. In traditional scheduling designs, the scheduling system in the system kernel is configured to check the state of all threads and collect the status of each thread (e.g., available, unavailable, blocked, etc.). If there are not enough available threads, the system kernel will wake up callback threads in the user-programmable space to create new threads to execute the blocked tasks.
[0017] The drawback of this approach is that it has poor compatibility with user-customized processes associated with the system kernel, and traditional task scheduling methods do not demonstrate good performance when there are many blocking and contention scenarios.
[0018] To at least partially address the aforementioned drawbacks, embodiments of this disclosure provide a novel task scheduling scheme. This scheme optimizes task scheduling efficiency and improves computing system performance without relying on the system kernel. Specifically, by redesigning the system scheduling process, particularly by creating a token mechanism for computing resources such as threads, the current state of each computing resource can be obtained more accurately and meticulously, thereby fully utilizing computing resources in paused or suspended states when conditions are met. Thus, even if task blocking still exists, computing resources can be fully utilized, and tasks in the task queue can be executed promptly.
[0019] Figure 1 A schematic diagram of an example environment 100 according to an embodiment of the present disclosure is shown. In this example environment 100, devices and / or processes according to embodiments of the present disclosure may be implemented. Figure 1As shown, the example environment 100 may include a computing resource queue 110, a task scheduler 120, and a task queue 130.
[0020] In some embodiments, the computing resource queue 110 may include, for example: Figure 1 The computing resources 111, 112, ..., N shown can be threads. It should be understood that threads can be created for orderly scheduling to execute corresponding tasks.
[0021] In some embodiments, the task scheduler 120 can be any device or module with scheduling capabilities. As a non-limiting example, the task scheduler 120 can be located on any type of fixed computing device, mobile computing device, or portable computing device, including but not limited to desktop computers, laptop computers, notebook computers, netbook computers, tablet computers, smartphones, etc. All or part of the task scheduler 120 can also be distributed in the cloud.
[0022] In some embodiments, task queue 130 may include, for example: Figure 1 Tasks 131, 132, ..., M are shown. To more clearly illustrate the various states that a task may enter throughout its execution cycle, refer to... Figure 2 Describe the transitions between various states. Figure 2 A schematic diagram of a task state 200 for task scheduling according to an embodiment of the present disclosure is shown.
[0023] like Figure 2 As shown, task state 200 includes at least five states: task initialization state 201, task execution state 202, task completion state 203, task system call state 204, and task pending state 205.
[0024] In task initialization state 201, as described above, computing resources such as threads in computing resource queue 110 are responsible for retrieving asynchronous tasks, such as task 131, from task queue 130. Once a task is retrieved by a computing resource, it enters task initialization state 201. In this state, the computing resource can allocate a task structure, an independent stack for task execution, and an independent scheduler context (including task execution registers such as EBP, ESP, EIP, and other data structures that facilitate linking or statistics) for the task. Afterward, the task context (registers) needs to be set to prepare function entry points and a stack for the task.
[0025] Next, we enter task execution state 202. At this point, we need a task context swap to save the current thread's context (stack, EIP, etc.) to the thread's data structure and move the task's context to the CPU's registers. This ensures that all local data during task execution is stored in the task stack and allows the task to migrate across threads.
[0026] If no blocking occurs, the task can be completed directly, i.e., task completion status 203. At this time, the task scheduler 120 can evaluate and report the task cost based on parameters such as the task execution time, and the thread executing the task can be released.
[0027] It should be understood that during task execution, some function calls that may block thread execution may be encountered, such as `pthread_mutex_lock`, `pthread_cond_wait`, `sleep`, and I / O read / write operations. In these cases, the task can be set to enter system call state 204. Before the system call task is actually executed, the thread executing the task can be set to relinquish its acquired token, which could allow the thread to occupy CPU time to execute the corresponding task. The token can be pre-created based on user requirements and system performance.
[0028] After a system call completes its task, the thread returns and attempts to retrieve the token it discarded, or it can try to acquire another free token. If both fail, the thread has no token and therefore cannot execute the task. The task then enters the pending state 205. Pending tasks exchange contexts with the current thread, return to the scheduler, and save their current context to the task's data structure. Next, the scheduler queues pending asynchronous tasks in the pending task queue. Once a thread completes its assigned task, it can retrieve pending tasks from the pending task queue, restore its context, and then proceed to the task execution state 202, and finally the task completion state 203.
[0029] After describing the various states of the task, the following section will combine... Figure 3 The process of task scheduling according to embodiments of this disclosure is described in detail. For ease of understanding, the specific data mentioned in the following description are exemplary and not intended to limit the scope of this disclosure. It is understood that the embodiments described below may also include additional actions not shown and / or actions shown may be omitted, and the scope of this disclosure is not limited in this respect.
[0030] Figure 3A flowchart of a process 300 for task scheduling according to an embodiment of the present disclosure is shown. In some embodiments, process 300 may be performed in... Figure 1 The task scheduler 120 is implemented in [the system / process]. Refer to [the relevant documentation / reference]. Figure 1 This description describes a task scheduling process 300 according to an embodiment of the present disclosure. For ease of understanding, the specific examples mentioned in the following description are exemplary and are not intended to limit the scope of this disclosure.
[0031] like Figure 3 As shown, at 302, the task scheduler 120 determines whether a free task scheduling token exists before assigning a task to a thread. It should be understood that a task scheduling token is a tag created by the user that enables computing resources in the computing system to execute tasks in the task queue. In other words, only threads assigned a task scheduling token are CPU threads. If a free task scheduling token exists, the process proceeds to 304.
[0032] In 304, task scheduler 120 can make the first computing resource in the computing system (e.g., Figure 1 The computing resource 111) obtains an idle task scheduling token as the first task scheduling token to execute the first task in the task queue 130 (e.g., Figure 1 Task 131 in the task queue 130 is executed based on task scheduling tokens in a pre-created set of task scheduling tokens. It should be understood that the number of task scheduling tokens in the set is predetermined based on user requirements and / or system performance.
[0033] In some embodiments, if it is determined that there is no pending first task 131 or other tasks in task queue 130, task scheduler 120 can pause the first computing resource. It should be understood that task scheduler 120 may continuously monitor task queue 130, and when there is a pending first task 131 or other tasks in task queue 130, task scheduler 120 can reactivate the first computing resource to execute the corresponding task. Since the first computing resource has already obtained the task scheduling token as described above, it can quickly execute the task without waiting, thereby improving the efficiency of task scheduling.
[0034] In some embodiments, if it is determined that no free task scheduling token exists, the task scheduler 120 may suspend the first computing resource until a free task scheduling token becomes available. It should be understood that suspending a thread is slightly different from spinning it. When a thread that has acquired a task scheduling token is deactivated (e.g., has no tasks), it can be said that the thread is suspended, while when a thread that has not acquired a task scheduling token is deactivated, it can be said that the thread is suspended.
[0035] During the above process, high-priority operations such as sleeping, mutexes, locks, and read / write operations may occur at any time. Therefore, at step 306, the task scheduler 120 needs to determine at any time whether there is a second task with a higher priority than the first task. If there is a second task with a higher priority, then proceed to step 308.
[0036] At 308, task scheduler 120 can cause the first computing resource to discard the first task scheduling token to switch from executing the first task to executing the second task (e.g., Figure 1 (Task 132 in task queue 130). In some embodiments, in order to make reasonable use of the task scheduling token, the task scheduler 120 may reactivate a suspended second computing resource in the computing system to retrieve a discarded task scheduling token.
[0037] Alternatively, or additionally, computing resources can be created instead of reactivating them. For example, task scheduler 120 can first check if the total number of computing resources in the computing system is less than a threshold. If it is determined that the total number of computing resources in the computing system is less than the threshold, task scheduler 120 can create a third computing resource to retrieve the discarded task scheduling token. Thus, even when there are insufficient suspended computing resources, task processing can continue by creating new computing resources.
[0038] However, it should be understood that the total number of computing resources created is finite. Therefore, this threshold number can be set to be less than or equal to the sum of the maximum number of computing resources available for executing a third task with a higher priority than the first task (e.g., the system-scheduled task mentioned above) and the number of tokens in the task scheduling token set. As an example, the total number of computing resources required, such as threads, can be determined according to the following equation:
[0039] The total number of threads required = Nmst + Ntt + margin value.
[0040] Where Nmst represents the maximum number of system scheduling threads, Ntt represents the maximum number of task scheduling tokens, and the margin value is any positive integer determined by the user.
[0041] It should be understood that the number of suspended computing resources is finite in order to ensure system performance. Therefore, the task scheduler 120 needs to determine the total number of suspended computing resources in the computing system, and when the total number is determined to be greater than a threshold number, suspend the first computing resource until the total number of suspended computing resources is less than or equal to the threshold number. Therefore, this threshold number can be set to be less than the number of tokens in the task scheduling token set. As an example, the total number of required computing resources, such as threads, can be determined according to the following equation:
[0042] The total number of paused threads = k * Ntt.
[0043] Where k < 1 and k > 0.
[0044] At step 310, if the task scheduler 120 determines that the second task has finished executing, it can cause the first computing resource to retrieve the first task scheduling token to continue executing the first task. In some embodiments, if it is determined that the first computing resource has not retrieved the task scheduling token, the task scheduler 120 can cause the first computing resource to obtain a second task scheduling token from the set of task scheduling tokens to continue executing the first task. The second task scheduling token can be any task scheduling token in the token set that is different from the first task scheduling token.
[0045] It should be understood that if there are no other free task scheduling tokens in the set of task scheduling tokens, the task scheduler 120 may suspend the first computing resource until a free task scheduling token becomes available.
[0046] In some embodiments, to effectively assess task costs, the task scheduler 120 can determine the time required to execute the first task based on the start and end times of when the first computing resource is enabled and the time when the first task is paused. Since the cost of each task can be evaluated after execution, it is possible to determine which computing resource in the set can prioritize processing subsequent tasks based on this cost. In other words, the task scheduler 120 can determine or modify the order in which each computing resource executes the next task based on the cost of each task. In this way, each computing resource can be used reasonably and in a balanced manner.
[0047] In some embodiments, the thread or computing resource mentioned above is an operating system thread, and the task scheduling token mentioned above is a CPU thread.
[0048] Furthermore, it should be understood that higher priority tasks typically refer to tasks such as interrupts (ISRs). Additionally, for ordinary asynchronous tasks, pending tasks have higher priority because they are often interrupted by system call tasks such as interrupts.
[0049] For a more detailed explanation Figure 3 The specific process of task scheduling in [the context of the task scheduling process] is now combined with [the following text is incomplete and requires further context]. Figure 4 A schematic diagram of thread state 400 for task scheduling according to an embodiment of the present disclosure is further described. (See attached diagram.) Figure 4 As shown, thread state 400 can include at least thread initialization state 401, thread token binding state 402, thread working state 403, thread system call state 404, thread suspended state 405, and thread paused state 406.
[0050] like Figure 4 As shown, after a thread, intended as a computing resource, is created, it enters the thread initialization state 401. In this state, the thread sets its associated attributes and adds itself to the computing resource queue 110. After initializing the thread's data structure, it attempts to find a task scheduling token from the task scheduling token set. If the task scheduling token is found, the thread enters the thread token binding state 402.
[0051] In thread token binding state 402, the thread acquires a token for an asynchronous task in the global task run queue. If the task queue contains tasks to be processed, the thread can enter thread working state 403, allowing it to execute the task. It should be understood that once the task is completed, the thread can re-enter thread token binding state 402 and continue to acquire tasks to be processed from the task queue, entering thread working state 403.
[0052] As described above, during task execution, if a higher-priority task, such as a system call task, is received, the thread enters the thread system call state 404. In this state, the thread discards its task scheduling token and then attempts to notify another thread in the thread queue to acquire the task scheduling token so that the tasks in the task queue can continue to execute. For example, a suspended thread can be reactivated, or a new thread can be created. Furthermore, when the system call task completes, the thread can first attempt to reacquire its discarded task scheduling token. If this fails, it can iterate through all task scheduling tokens in the scheduler to try to obtain an idle CPU thread. If all fail, it needs to transfer its current task context to the thread context, thereby queuing the current task in the suspended task queue, and then enters the thread suspended state 405. Additionally, when a thread finds no available task scheduling token during thread initialization, it can enter the thread suspended state 405. Accordingly, if an available task scheduling token is subsequently found, the suspended thread can be awakened or reactivated, thus returning to the thread initialization state 401.
[0053] Furthermore, when a thread does not obtain a task from the task queue, it can be set to a thread paused state 406. Thread paused state 406 represents a thread that has obtained a task scheduling token but has not found a task to execute. When it is subsequently determined that a task exists in the task queue, the paused thread will be awakened and attempt to obtain a task directly from the queue. In this case, the thread does not need to obtain a task scheduling token again, thus pausing threads can execute tasks much faster than suspended threads. It should be understood that the more paused threads there are, the better the system's task scheduling performance will be. However, too many paused threads can lead to severe contention between threads, so the total number of paused threads needs to be determined as mentioned above. If the number of paused threads is too large, the excess paused threads need to be converted to a thread suspended state 405.
[0054] As described above, by creating task scheduling tokens, this disclosure adds more thread states, thereby enabling more granular sensing and control of each thread, thus improving the efficiency of task scheduling.
[0055] Figure 5 A schematic block diagram of an example electronic device 500 that can be used to implement embodiments of the present disclosure is shown. For example, the electronic device 500 can be used to implement… Figure 1 The task scheduler 120 is shown. As shown, the electronic device 500 includes a central processing unit (CPU) 501, which can perform various appropriate actions and processes according to computer program instructions stored in read-only memory (ROM) 502 or loaded from storage unit 508 into random access memory (RAM) 503. The RAM 503 may also store various programs and data required for the operation of the device 500. The CPU 501, ROM 502, and RAM 503 are interconnected via bus 504. An input / output (I / O) interface 505 is also connected to bus 504.
[0056] Multiple components in device 500 are connected to I / O interface 505, including: input unit 506, such as keyboard, mouse, etc.; output unit 507, such as various types of monitors, speakers, etc.; storage unit 508, such as disk, optical disk, etc.; and communication unit 509, such as network card, modem, wireless transceiver, etc. Communication unit 509 allows device 500 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0057] Processing unit 501 executes the various methods and processes described above, such as process 300. For example, in some embodiments, the various methods and processes described above may be implemented as computer software programs or computer program products tangibly contained in a machine-readable medium, such as storage unit 508. In some embodiments, part or all of the computer program may be loaded and / or installed on device 500 via ROM 502 and / or communication unit 509. When the computer program is loaded into RAM 503 and executed by CPU 501, one or more steps of any of the processes described above may be performed. Alternatively, in other embodiments, CPU 501 may be configured by any other suitable means (e.g., by means of firmware) to execute processes such as process 300.
[0058] This disclosure can be a method, apparatus, system, and / or computer program product. A computer program product may include a computer-readable storage medium having computer-readable program instructions loaded thereon for performing various aspects of this disclosure.
[0059] Computer-readable storage media can be tangible devices capable of holding and storing instructions for use by an instruction execution device. Computer-readable storage media can be, for example—but not limited to—electrical storage devices, magnetic storage devices, optical storage devices, electromagnetic storage devices, semiconductor storage devices, any non-transitory storage devices, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of computer-readable storage media include: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable compact disc read-only memory (CD-ROM), digital multifunction disc (DVD), memory sticks, floppy disks, mechanical encoding devices, such as punch cards or recessed protrusions storing instructions thereon, and any suitable combination of the foregoing. The computer-readable storage media used herein are not to be construed as transient signals themselves, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides or other transmission media (e.g., light pulses through fiber optic cables), or electrical signals transmitted through wires.
[0060] The computer-readable program instructions described herein can be downloaded from computer-readable storage media to various computing / processing devices, or downloaded via a network, such as the Internet, local area network, wide area network, and / or wireless network, to an external computer or external storage device. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards them to the computer-readable storage media in the respective computing / processing device.
[0061] Computer program instructions used to perform the operations of this disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, status setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages such as Smalltalk, C++, etc., and conventional procedural programming languages such as the "C" language or similar programming languages. The computer-readable program instructions may execute entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, electronic circuitry, such as programmable logic circuitry, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), is personalized by utilizing the status information of the computer-readable program instructions to implement various aspects of this disclosure.
[0062] Various aspects of this disclosure are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-readable program instructions.
[0063] These computer-readable program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that, when executed by the processing unit of the computer or other programmable data processing apparatus, they create means for implementing the functions / actions specified in one or more blocks of the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium that causes a computer, programmable data processing apparatus, and / or other device to operate in a particular manner. Thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing aspects of the functions / actions specified in one or more blocks of the flowchart and / or block diagram.
[0064] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to perform the functions / actions specified in one or more boxes of a flowchart and / or block diagram.
[0065] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction containing one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those shown in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0066] Various embodiments of this disclosure have been described above. These descriptions are exemplary and not exhaustive, nor are they limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles, practical applications, or improvements to the technology in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.
Claims
1. A task scheduling method, comprising: In response to the determination that an idle task scheduling token exists, the first computing resource in the computing system is enabled: Obtain the idle task scheduling token as the first task scheduling token; as well as The first task in the task queue is executed, and the tasks in the task queue are executed based on task scheduling tokens in a pre-created set of task scheduling tokens; In response to determining that there is a second task to be executed and that the second task has a higher priority than the first task, the first computing resource: Discard the first task scheduling token; as well as Switch from executing the first task to executing the second task; In response to determining that the second task has been completed, the first computing resource: Retrieve the first task scheduling token; as well as Continue performing the first task; In response to determining that the total number of suspended computing resources is greater than a first threshold number, the first computing resource is suspended until the total number of suspended computing resources is less than or equal to the first threshold number. The number of the first thresholds is less than the number of tokens in the task scheduling token set.
2. The method according to claim 1, further comprising: If it is determined that no idle task scheduling token exists, the first computing resource is suspended until an idle task scheduling token exists.
3. The method of claim 1, wherein obtaining the idle task scheduling token to execute the first task comprises: If it is determined that there is no first task to be executed in the task queue, the first computing resource is paused until there is a first task to be executed in the task queue.
4. The method according to claim 1, further comprising: If it is determined that the first computing resource has not retrieved the task scheduling token, the first computing resource shall obtain an idle second task scheduling token from the set of task scheduling tokens to continue executing the first task. If there is no free second task scheduling token in the set of task scheduling tokens, the first computing resource is suspended until a free task scheduling token is available.
5. The method of claim 1, wherein causing the first computing resource to discard the task scheduling token comprises: Reactivate the suspended second computing resource in the computing system to retrieve the discarded task scheduling token; or If it is determined that the total number of computing resources in the computing system is less than a second threshold, a third computing resource is created to retrieve the discarded task scheduling token. Wherein the second threshold number is less than or equal to the sum of the maximum number of computing resources available to execute a third task with a higher priority than the first task and the number of tokens in the task scheduling token set.
6. The method according to claim 1, further comprising: Based on the start and end times of the activation of the first computing resource and the time when the first task was paused, the time required to execute the first task is determined, so as to update the priority of the first computing resource.
7. An electronic device, comprising: processor; as well as A memory coupled to the processor, the memory having instructions stored therein, which, when executed by the processor, cause the electronic device to perform actions, the actions including: In response to determining that there is an idle task scheduling token, a first computing resource in the computing system acquires the idle task scheduling token as a first task scheduling token to execute a first task in a task queue, wherein the tasks in the task queue are executed based on task scheduling tokens in a pre-created set of task scheduling tokens; In response to determining that a second task with a higher priority than the first task is to be executed, the first computing resource discards the first task scheduling token to switch from executing the first task to executing the second task; and In response to determining that the second task has finished executing, the first computing resource retrieves the first task scheduling token to continue executing the first task; and In response to determining that the total number of suspended computing resources is greater than a first threshold number, the first computing resource is suspended until the total number of suspended computing resources is less than or equal to the first threshold number. The number of the first thresholds is less than the number of tokens in the task scheduling token set.
8. The electronic device according to claim 7, wherein the action further includes: If it is determined that no idle task scheduling token exists, the first computing resource is suspended until an idle task scheduling token exists.
9. The electronic device of claim 7, wherein obtaining the idle task scheduling token to execute the first task comprises: If it is determined that there is no first task to be executed in the task queue, the first computing resource is paused until there is a first task to be executed in the task queue.
10. The electronic device according to claim 7, wherein the action further includes: If it is determined that the first computing resource has not retrieved the task scheduling token, the first computing resource shall obtain an idle second task scheduling token from the set of task scheduling tokens to continue executing the first task. If there is no free second task scheduling token in the set of task scheduling tokens, the first computing resource is suspended until a free task scheduling token is available.
11. The electronic device of claim 7, wherein causing the first computing resource to discard the task scheduling token comprises: Reactivate the suspended second computing resource in the computing system to retrieve the discarded task scheduling token; or If it is determined that the total number of computing resources in the computing system is less than a second threshold, a third computing resource is created to retrieve the discarded task scheduling token. Wherein the second threshold number is less than or equal to the sum of the maximum number of computing resources available to execute a third task with a higher priority than the first task and the number of tokens in the task scheduling token set.
12. The electronic device according to claim 7, wherein the action further includes: Based on the start and end times of the activation of the first computing resource and the time when the first task was paused, the time required to execute the first task is determined, so as to update the priority of the first computing resource.
13. A computer program product tangibly stored on a computer-readable medium and comprising machine-executable instructions that, when executed, cause a machine to perform the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Efficient method for the scheduling of work loads in a multi-core computing environment
US20130061233A1
Devices and methods for resource allocation
US20180165123A1