The present invention relates to the field of computer systems, more particularly relating to methods and apparatuses for scheduling activities.
Multi-threading is a technique that split instructions into multiple streams of executions (or threads) so that they can be processed in parallel.
Hyper-Threading Technology is a technology from Intel® Corporation of Santa Clara, Calif. that enables execution of threads in parallel using a single processor. Hyper-Threading Technology is a form of simultaneous multi-threading technology (SMT) where multiple threads of software applications can be executed simultaneously on one processor. This is achieved by duplicating the architectural state, with each architecture state sharing one set of processor execution resources.
In addition to throughput, power consumption is becoming an important consideration for modern systems. This is especially true for battery-run mobile systems, in which the average power consumption for a given fixed application is a crucial parameter to consider for the evaluation of the overall performance of the system. This is also true for other systems such as, for example server systems, because the cost to provide energy to the cluster is a concern for the service providers. Today, most of the energy saving are done via dynamic voltage/frequency scaling.
The following drawings disclose various embodiments of the present invention for purposes of illustration only and are not intended to limit the scope of the invention.
In one embodiment, a method for scheduling activities is disclosed. A ready-to-be-dispatched activity is dispatched if there is another activity running. If there is no other activity running, a ready-to-be-dispatched activity may be delayed until another activity is ready to be dispatched so that both activities are dispatched together.
In the following description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the present invention. It will be evident, however, to one skilled in the art that the present invention may be practiced without these specific details. In other instances, well-known structures, processes and devices are shown in block diagram form or are referred to in a summary manner in order to provide an explanation without undue detail.
In the following description, an application may include one or more threads. A thread may include one or more activities (or segments), and activities from two or more threads may run in parallel. Although the description refers to scheduling activities, the techniques described may also be used to schedule threads, processes, tasks, segments of processes, segments of tasks, etc. For example, the techniques may be used to schedule threads using a processor supporting Hyper Threading technology.
In multi-threaded architectures, most schedulers are designed for maximum throughput where activities are dispatched immediately after they are ready-to-be-dispatched so that they can finish as fast as possible. This generally works well for throughput-oriented tasks, and any delay in dispatching the activities may be viewed as possibly impacting performance. In a typical activity scheduling scheme, when one activity finishes its work, that activity puts its data into a buffer for a next activity to work on. For example, a real-time video application may include one activity to capture the video, one activity to encode the bit stream, and another activity to send out the bit stream. These activities have been naturally synchronized by the video-frame and the bit-stream buffers. Normally, when the input data is ready the next activity will immediately work on the data. The same activity may be dispatched repeatedly at different times. A period between a time when an activity is dispatched and a next time the same activity is dispatched is referred to as a cycle period. Depending on the application, the cycle period may be small or large. When the cycle period is small, there may be some overlapping in the execution time.
In the example illustrated in
When the cycle period is large, there may not be any overlap in executions among the activities. For example, as illustrated in
The diagram in
The period when one or both of the activities 310 and 315 are running is referred to as a non-halted period 330. During the non-halted period 330, the processor may remain busy and consume power. Note that the non-halted period 330 also includes the overlap period 325.
By delaying the starting time or the dispatch of the activity 315, in addition to increasing the overlap period 325, a period of no execution is introduced. This period is referred to as a halted or idle period 335. For one embodiment, during the halted period 335, the processor may be less busy and therefore may consume less power. For example, when using a processor supporting Hyper-Threading Technology, because powering up additional execution units for two simultaneous threads is more economical and the processor consumes less power when it is halted (or when both logical processors are halted), less energy is consumed. Thus, it may be advantageous to overlap the busy cycles of one logical processor with those of the other logical processor.
Dispatching the activities (or threads, processes, tasks, etc.) in this coordinated manner may be done at different multiple levels. For example, at the application level, synchronization points may be hand-tuned so that the second activity may not wake up until the first activity is waken up. Following are two code examples that may be used to schedule activites in a real-time application. In the first code example, the second activity is waken up when the first activity finished, as is typically done:
In the second code example, the second activity is not waken up when the first activity finishes its work. Instead, the second activity is waken up at the same time when the first activity is waken up by the external timer. In this example, the dispatch of the second activity is delayed.
The second activity in the above code example may be delayed by being queued in a buffer. For one embodiment, a time-out scheme may be implemented such that a ready-to-be-dispatched but delayed activity may be dispatched. For example, the time-out scheme may include setting a predetermined maximum amount of delay by which an activity may be queued in the buffer before being dispatched. In another embodiment, activities may have different priorities and each priority may be associated with a different delay time before being dispatched.
For one embodiment, when real-time constraints of the activities and their schedules are known ahead of time, compilers and schedulers in a real-time operating system (OS) may schedule the activities using the same techniques described herein. Moreover, without prior knowledge of real-time scheduling of the task, an activity-dispatch buffer may be designed in the OS level or in the processor level. Similar to the “write combining” buffer in modern processors, when there is only one ready-to-be-dispatched activity in the system, the activity-dispatch buffer will delay dispatching it. When there is another activity ready to be dispatched, two activities will be dispatch simultaneously. In the Hyper-Threading Technology processor example, two logical processors may wake up at the same time. The activity-dispatch buffer may increase the overlap between the execution time of activities and thus increases the parallelism in the workloads.
From block 410, when there is no other activity running, the process moves to block 415 where a test is made determine if there is another activity ready to be dispatched. If there is another activity ready to be dispatched, the process moves from block 415 to block 435 where both activities are dispatched to increase execution overlap.
From block 415, if there is not another activity ready to be dispatched, the process moves to block 420 where a test is made determine if the current ready-to-be-dispatched activity can be delayed. The activity may not be delayed, for example, because it may have been assigned a high priority and its dispatch and completion may be important to other activities. If the activity may not be delayed, the process moves from block 420 to block 425 where the activity is dispatched. In this example, the activity is dispatched even though it may be the only activity running.
From block 420, if the activity may be delayed, the process moves to block 430 where the dispatch of the activity is delayed until another ready-to-be-dispatched activity is received. When another ready-to-be-dispatched activity is received, the two activities are dispatched, as shown in block 435. In one embodiment, a delay period may be used to avoid excessive delay. For example, if another ready-to-be-dispatched activity is not received after the delay period, the activity may be dispatched by itself without additional delay.
The operations of these various methods may be implemented by a processor in a computer system, which executes sequences of computer program instructions that are stored in a memory which may be considered to be a machine-readable storage media. The memory may be random access memory, read only memory, a persistent storage memory, such as mass storage device or any combination of these devices. Execution of the sequences of instruction may cause the processor to perform operations according to the process described in
The instructions may be loaded into memory of the computer system from a storage device or from one or more other computer systems (e.g. a server computer system) over a network connection. The instructions may be stored concurrently in several storage devices (e.g. DRAM and a hard disk, such as virtual memory). Consequently, the execution of these instructions may be performed directly by the processor.
In other cases, the instructions may not be performed directly or they may not be directly executable by the processor. Under these circumstances, the executions may be executed by causing the processor to execute an interpreter that interprets the instructions, or by causing the processor to execute a compiler which converts the received instructions to instructions that which can be directly executed by the processor.
In other embodiments, hard-wired circuitry may be used in place of or in combination with software instructions to implement the present invention. Thus, the present invention is not limited to any specific combination of hardware circuitry and software, nor to any particular source for the instructions executed by the computer system.
Methods and systems for scheduling activities have been disclosed. Activities may be delayed to increase overlapping between the execution time of the activities. By delaying the dispatch of the activities, average power consumption on multi-threading processors may be reduced.
Although the present invention has been described with reference to specific exemplary embodiments, it will be evident that various modifications and changes may be made to these embodiments without departing from the broader spirit and scope of the invention as set forth in the claims. For example, although processors supporting Hyper-Threading Technology are described in the examples, other multi-threading processors may also be used. For another example, although the techniques have been described in connection with activities and threads, the techniques may also be used in other applications to increase processor idle time. Accordingly, the specification and drawings are to be regarded in an illustrative rather than a restrictive sense.
Number | Name | Date | Kind |
---|---|---|---|
4430707 | Kim | Feb 1984 | A |
4493020 | Kim et al. | Jan 1985 | A |
4908750 | Jablow | Mar 1990 | A |
5133077 | Karne et al. | Jul 1992 | A |
5339415 | Strout et al. | Aug 1994 | A |
5420808 | Alexander et al. | May 1995 | A |
5539681 | Alexander et al. | Jul 1996 | A |
5553256 | Fetterman et al. | Sep 1996 | A |
5627984 | Gupta et al. | May 1997 | A |
5781775 | Ueno | Jul 1998 | A |
5790826 | Thusoo et al. | Aug 1998 | A |
5828895 | Chan et al. | Oct 1998 | A |
5841999 | Le et al. | Nov 1998 | A |
5872972 | Boland et al. | Feb 1999 | A |
6101597 | Colwell et al. | Aug 2000 | A |
6163838 | Merchant et al. | Dec 2000 | A |
6212544 | Borkenhagen et al. | Apr 2001 | B1 |
6272520 | Sharangpani et al. | Aug 2001 | B1 |
6345287 | Fong et al. | Feb 2002 | B1 |
6356918 | Chuang et al. | Mar 2002 | B1 |
6385715 | Merchant et al. | May 2002 | B1 |
6393550 | Fetterman et al. | May 2002 | B1 |
6493741 | Emer et al. | Dec 2002 | B1 |
6505250 | Freund et al. | Jan 2003 | B2 |
6567840 | Binns et al. | May 2003 | B1 |
6647408 | Ricart et al. | Nov 2003 | B1 |
6662203 | Kling et al. | Dec 2003 | B1 |
6675190 | Schabernack et al. | Jan 2004 | B1 |
6839833 | Hartnett et al. | Jan 2005 | B1 |
6848029 | Coldewey | Jan 2005 | B2 |
6952825 | Cockx et al. | Oct 2005 | B1 |
6952827 | Alverson et al. | Oct 2005 | B1 |
7213135 | Burky et al. | May 2007 | B2 |
7376844 | Feyt | May 2008 | B2 |
20030041090 | Armstrong et al. | Feb 2003 | A1 |
20030110230 | Holdsworth et al. | Jun 2003 | A1 |
20040073769 | Debes et al. | Apr 2004 | A1 |
20050149936 | Pilkington | Jul 2005 | A1 |
Number | Date | Country | |
---|---|---|---|
20040083478 A1 | Apr 2004 | US |