This application claims priority to Japanese Patent Application No. JP2003-398823 filed Nov. 28, 2003, the entire text of which is specifically incorporated by reference herein.
The present invention relates to a system, method and recording medium capable of guaranteeing assignment of calculation resources to which simultaneous multithread (SMT) technology is applied to a real-time process, giving as many calculation resources as possible to a non-real-time process at the same time and thereby improving the throughput of the entire system.
A real time operating system (real-time OS) may include functionality to ensure that an event handler, such as an interrupt service routine started by an external interrupt, corresponding of the event is started within a predetermined time period. For example, during file input/output or screen drawings processing a supply voltage or a sensor error may occur, causing an interrupt service routine to start within several microseconds to milliseconds for applications requiring real-time processing of an event. Such a real-time OS is a preemptive multitask OS created with importance attached to a real-time processing capacity and is preferably used for applications required to start an event handler and carry out processing the moment an event occurs.
One of requirements for a real-time OS is to guarantee an amount of processing per a unit time of a process in a system. Conventionally, a real-time system provided with a real-time OS is often used for built-in applications and its processes in the system are often fixed. For this reason, the necessary processing performance is secured by carefully setting a priority relationship in a group of processes and causing the processes to cooperate with one another. However, even the built-in system is becoming a substantially open type system. It is becoming increasingly difficult to predicatively understand the type and behavior of an application operating under the system.
In response, there is a proposal on a resource reservation type system. This resource reservation type system reserves an execution time of a calculation resource, such as a central processing unit (CPU), with a maximum value of the calculation time necessary to achieve a required amount of processing for a real-time process having a deadline and can thereby reliably satisfy a demand by the deadline.
However, in simultaneous multithread (SMT) technology that allows a plurality of threads to operate simultaneously on a single CPU, the amount of calculation that the CPU can execute within a certain time varies a great deal under the influence of other threads (hereinafter referred to as “back processor thread”) operating simultaneously on the same CPU. As a result, in an environment in which SMT technology is applied, there is a problem that it is not possible to obtain a scheduled amount of calculation despite the fact that a necessary calculation time is reserved through a reservation of the calculation resource. Note that the above-described thread is basic unit whereby the operating system (OS) assigns execution times of the CPU and one or more threads are generated in a process, which is a unit that OS controls a program.
One possible method to solve the above described problem is a method which disables the SMT function, preventing executions of the back processor threads which are simultaneously operating on a single CPU when a real-time process is in progress in order to obtain a scheduled amount of calculation. However, this method has a problem of wasting the characteristic of SMT improving the system throughput by simultaneously executing processes.
Furthermore, one example of a system that solves the above described problem is TimeSys Linux/RT by TimeSys Corporation. This real-time OS provides a reservation function of a calculation time corresponding to a multiprocessor system. However, this reservation function does not take SMT into consideration and involves a problem that the calculation rate of the CPU varies in an unpredictable manner on a system using SMT and reserving execution times of the CPU makes it impossible to guarantee the calculation performance.
Hiroshi Inoue et al., “CPU Resource Reservation in System Using SMT”, Japan Society for Software Science and Technology, 6th Workshop About Systems for Programming and Applications, Mar. 12 to 14, 2003, discloses that it is not possible to secure an amount of calculation scheduled in an environment in which the above described reservation function uses SMT and has proposed to let back processor threads to be simultaneously executed to sit idle when a reserved process is in progress or to execute other processes which always fall under the same combination with the reserved process as a method for solving this problem.
Jain. R., Hughes. C. J., Adve. S. V. “Soft Real—Time Scheduling on Simultaneous Multithreaded Processors,” 23rd IEEE Real—Time Systems Symposium, Dec. 3-5, 2002 proposes, as another method for solving the problem, scheduling of a soft real-time process in an environment in which SMT is used. Scheduling is performed by selecting processes on which simultaneously executing a combination of real-time tasks has little influence.
However, in the method whereby when the above described reserved process is in progress, back processor threads to be simultaneously executed are left idle or processes are always executed in the same combination. Idling means that the SMT function is not fully utilized. Furthermore, processes that must always be executed in the same combination involves a problem that it is not applicable to a system in which other unknown processes are mixed. In addition, scheduling of soft real-time processes on a system using SMT tolerates deadline errors of 5% or less, resulting in a problem that it is not possible to reliably guarantee the amount of calculation by a deadline.
The present invention is implemented in view of the above described problems to help guarantee a deadline of a real-time process on a CPU using SMT and at the same time processing other processes whenever possible to improve the system throughput. When a reserved process is dispatched to a calculation resource, a determination is made as to whether there is a slack time until a deadline. If so, another process is dispatched. The determination of slack time is made on an as-needed basis. The processor can continue other processes when there is a slack time and dispatch other processes when there is no slack time, to let operating back processor threads sit idle and allow the reserved processes to occupy calculation resources and thereby guarantee a predetermined amount of calculation by the deadline.
Thus, one exemplary aspect of the present invention is a calculation resource reservation system for guaranteeing a process requesting a predetermined amount of calculation of a calculation resource that the predetermined amount of calculation is obtained by a deadline. The calculation resource is configured to process a plurality of processes simultaneously. The calculating resource reservation system includes a measuring section configured to measure an amount of calculation of the process obtained through calculation processing by the calculation resource. A slack time decision section is configured to generate an interrupt to the calculation processing using said calculation resource, acquire the amount of calculation acquired by an interrupt generation time from said measuring section, provide the amount of calculation acquired to the calculation resource so as to calculate a slack time, and determine whether the slack time is available or not. A processing interruption section is configured to interrupt the processing of other processes by the calculation resource if the slack time decision section determines that the slack time is not available.
Another exemplary aspect of the invention is a calculation resource reservation method for guaranteeing a process requesting a predetermined amount of calculation of a calculation resource that the predetermined amount of calculation is obtained by a deadline. The method includes a measuring operation to measure an amount of calculation of the process obtained through calculation processing by the calculation resource. A generating operation is configured to generate an interrupt to the calculation processing using the calculation resource and acquire the amount of calculation acquired by an interrupt generation time. A providing operation offers the amount of calculation acquired to the calculation resource so as to calculate a slack time and determine whether the slack time is available or not. An interrupting operation interrupts the processing of other processes by the calculation resource if the slack time is not available.
Yet another exemplary aspect of the invention is a computer program product embodied in a tangible media. The computer program product is configured to cause a program to measure an amount of calculation of the process obtained through calculation processing by the calculation resource, generate an interrupt to the calculation processing and acquire the amount of calculation acquired by the interrupt generation time, calculate a slack time using the amount of calculation acquired and determine whether the slack time is available or not, and interrupt the processing of other processes by the calculation resource if the slack time is not available.
By providing a system, method and computer program product of the present invention, it is possible to use simultaneous multithread technology (SMT) to improve throughput while guaranteeing a deadline of a real-time process on a calculation resource such as a CPU through the reservation of the calculation resource.
10 . . . System
20 . . . Television antenna
30 . . . Remote controller
40 . . . Video cassette recorder
41 . . . Processor
42 . . . Storage device
43 . . . Reception section
44 . . . Television tuner
50 . . . Display device
60 . . . Calculation resource reservation system
61 . . . Measuring section
62 . . . Slack time decision section
62
a . . . Interrupt generation time setting section
62
b . . . Amount of calculation decision section
63 . . . Processing interruption section
The present invention is explained according to specific embodiments shown in the attached drawings below, however, the present invention is not limited to those embodiments.
In the embodiment shown in
The above described compression processing and channel change processing are executed using a process as one processing unit. Compression processing of arbitrary image and speech needs to be completed before the next image and speech data is received and if the compression processing is not completed before the next image and speech data is received, the data is lost. In the case of this processing, one process comprises data reception, compression processing and reception of the next data and this process has a deadline by which it must complete the processing before the next data is received. Therefore, this process is a real-time process. In contrast, the channel change processing is preferably processed as soon as possible, but since it has no deadline, the channel change processing can be performed with a certain delay. The process as a processing unit of this processing is a non-real-time process.
The calculation resource reservation system of the present invention is a system for guaranteeing assignment of calculation resources to the above described real-time process and at the same time performing scheduling so that as many calculation resources as possible are assigned to the above described non-real-time process. That is, it is a system for assigning processes and reserving calculation resources. More specifically, it is a system that checks the amount of calculation obtained for a real-time process as appropriate, obtains the remaining amount of calculation from the amount of calculation, calculates the remaining time until a deadline, decides whether there is a time space (referred to herein as “slack time”) or not from the remaining time and the remaining amount of calculation, interrupts the execution of threads in the non-real-time process when there is no slack time, and assigns all calculation resources to the real-time process to ensure that a predetermined amount of calculation is achieved by the deadline.
Referring to
Furthermore, the calculation resource reservation system 60 can generate an interrupt to interrupt calculation processing by the processor 41, causes the processor 41 to calculate a slack time, decide whether there is a slack time or not based on the calculation result, releases interrupts to the other processes when it decides that there is no slack time, only assigns the processor 41 to the above described process and guarantee that the amount of calculation can be achieved by a deadline. When the predetermined amount of calculation that should be achieved by the deadline is obtained, the processor 41 can be assigned to other processes from that time to the deadline.
One embodiment of the calculation resource reservation system of the present invention will be explained with reference to
A real-time process having a deadline is assigned by the OS to the processor 41 and the processing is started by the processor 41. In
In the embodiment shown in
Furthermore, during the interrupt, the slack time decision section 62 gives the amount of calculation acquired from the measuring section 61 to the processor 41, causes the processor 41 to calculate the slack time and decides whether there is a slack time or not from this result. Note that a slack time ts can be calculated by the formula, ts=(td−t0)−(cr−c0).
td is a deadline, t0 is an interrupt generation time, cr is a predetermined amount of calculation represented by the calculation time when there is no influence of a back processor thread (that is, the value of a predetermined amount of calculation when no back processor thread is executed on the value processor 41 expressed as a calculation time), c0 is an amount of calculation obtained by the time t0 represented by a calculation time when there is no influence of the back processor thread as in the case of cr. For example, c0 can be calculated by calculating a value of amount of calculation/calculation time from a predetermined amount of calculation and a predetermined calculation time corresponding to the predetermined amount of calculation and using this value and the measured amount of calculation. A unit for this calculation time is, for example, ms (millisecond). A slack time is a value obtained by subtracting a remaining calculation time to be obtained from the remaining time until the above described deadline. The slack time decision section 62 decides whether the calculated slack time is 0 or exceeds 0. When the slack time is 0, this means that unless the processor 41 is only assigned to the real-time process, it is not possible to acquire the predetermined amount of calculation by the deadline and when the slack time exceeds 0, the processor 41 can still be assigned to other processes (hereinafter referred to as “non-real-time processes”).
When the slack time decision section 62 decides that there is no slack time, the processor 41 should only be assigned to the real-time process, and therefore the processing interruption section 63 suspends non-real-time processes being processed on the processor 41. When the processor 41 is also carrying out another process, that process is also suspended. As described above, this allows the processor 41 to be assigned to only the real-time process and ensures that the amount of calculation to be acquired by the deadline is acquired. In reality, since threads are being executed on the processor 41, they can be suspended by letting the back processor threads of the non-real-time processes sit idle. Note that the suspended state of the suspended non-real-time processes, that is, context is stored in a storage section (not shown) such as a cache. The context refers to an internal state of a program or a situation in which the program is placed or given condition, etc., which becomes material for making a decision when the program being executed selects the processing content, and, for example, when an operator or function which can take a plurality of types of arguments selects a type of a return value according to the type of each argument, the context is the type of the argument when the operator or function is invoked. In the present invention, when the real-time process is completed by a deadline, by releasing the assignment of the processor to the real-time process, the processor 41 can read the context from the storage section (not shown) and start processing from the state in which the non-real-time process was suspended.
Furthermore, when the slack time decision section 62 decides that the slack time exceeds 0, an interrupt is generated again a certain time later, the amount of calculation obtained so far is acquired and given to the processor 41 so as to calculate a slack time and decide whether the slack time is 0 or not based on this result. By repeating this, it is possible to guarantee the deadline of the real-time process and at the same time also assign calculation resources to non-real-time processes effectively and thereby improve the system throughput. Note that an interrupt by the slack time decision section 62 is by far smaller than a processing time of one process. Furthermore, the amount of calculation is acquired and the slack time is calculated within this interrupt time.
When the slack time decision section 62 generates an interrupt at certain time intervals, the slack time calculated by the processor 41 may become a negative value. When the slack time becomes a negative value, this means that even if the processor 41 is only assigned to the real-time process, it is not possible to obtain an amount of calculation to be obtained by the deadline. Therefore, the present invention can shorten time intervals of interrupt generation and provides the slack time with a threshold to decide whether the slack time exceeds, for example, 0.01 ms or not so as to guarantee the deadline of the real-time process. Functions such as a calculation of the slack time, decision as to whether there is a slack time or not and suspension of other processes can also be realized by including the functions in an interrupt handler which is an executable code sent to the processor 41 during an interrupt and causing the processor 41 to execute this handler.
One embodiment of the present invention can also include a step of causing the processor to calculate a slack time at the time of dispatch, deciding whether there is a slack time or not and dispatching the non-real-time process when there is a slack time. In this case, it is possible to include the above-described dispatching step between step 300 and step 310.
The interrupt generation time setting section 62a causes the processor 41 to calculate the next interrupt generation time tn using a deadline, amount of calculation to be obtained by the deadline, interrupt generation time, amount of calculation obtained by the interrupt generation time and the formula, tn=(td−t0)−(cr−c0)+t0.
td is a deadline, to is an interrupt generation time, cr is a value of a predetermined amount of calculation expressed by a calculation time when there is no influence of the back processor threads and c0 is a value of an amount of calculation obtained until t0 expressed by a calculation time when there is no influence of the back processor threads. Note that this tn is the sum of t0 and slack time. During the period from t0 to tn, even when no amount of calculation is obtained, the slack time only decreases and the slack time exists in this period, and therefore generating an interrupt in this period goes to waste. The interrupt generation time setting section 62a causes the processor 41 to calculate the time at which the slack time becomes 0, that is, tn when no amount of calculation is obtained using the above described formula, sets it in the slack time decision section 62 so that an interrupt is generated at the time obtained and prevent any unnecessary interrupt from being generated. When no amount of calculation is obtained in the period from t0 to tn, it is possible to let the back processor thread sit idle at time tn, only assign the processor 41 to the real-time process and acquire a predetermined amount of calculation to be acquired by a deadline. Using this interrupt generation time setting section 62a, it is possible to reduce the number of times interrupts are generated and carryout processing more efficiently. This function can also be included in the aforementioned interrupt handler and realized by causing the processor 41 to execute this handler.
When it is decided in step 540 that there is a slack time, a next interrupt generation time is calculated and the next interrupt generation time is set at the time acquired (step 550). Returning to step 530, a next interrupt is generated and an amount of calculation is acquired. When it is decided in step 510 there is no slack time, the execution of threads of non-real-time processes is suspended (step 560) and the processor is only assigned to the real-time process. Furthermore, when it is decided in step 540 there is no slack time, the execution of back processor threads is suspended (step 560) and the processor is only assigned to the real-time process. When the real-time process is completed, the processing of the non-real-time process can be resumed (step 570). After the deadline is reached, if the real-time process is dispatched to the processor, the processing in steps 500 to 570 can be performed again. When the real-time process is not dispatched, the processing by the processor is completed when the non-real-time process is completed (step 580).
To check the slack time, the interrupt generation time setting section 62a calculates a next interrupt generation time. The measuring section 61 measures the amount of calculation of the real-time process. When the measuring section 61 detects the completion of the real-time process, the amount of calculation decision section 62b responds to the detection, decides that the predetermined amount of calculation is obtained before the interrupt generation time, notifies it to the slack time decision section 62 and cancels the interrupt. In this case, it is possible to release the assignment of resources to the real-time process, assign the resources to the non-real-time process, and the processor can execute the back processor thread of the non-real-time process. When it is decided that the predetermined amount of calculation could not be obtained before the interrupt generation time, there is no notification to the slack time decision section 62 and the slack time decision section 62 generates an interrupt at the time set by the interrupt generation time setting section 62a. This function can also be realized by being included in the aforementioned interrupt handler and causing the processor 41 to execute this handler.
When it is decided in step 710 and step 740 that there is no slack time, the execution of the thread of the non-real-time process is suspended (step 770) and the processor is only assigned to the real-time process. Furthermore, when it is decided in step 760 that the predetermined amount of calculation could be obtained before the interrupt generation time, the assignment to the resources to the real-time process is released, the resources are assigned to the non-real-time processes and the processing of the non-real-time processes is resumed (step 780). After the deadline is reached, if the real-time process is dispatched to the processor, it is possible to carry out the processing in steps 700 to 780 again. When the real-time process is not dispatched, the processing by the processor is completed when the non-real-time process is completed (step 790).
The present invention can further reduce the number of times interrupts are generated using a minimum guaranteed value of assignment of calculation resources to the real-time process. This can be adopted when it is known that minimum guaranteed calculation performance can be obtained even when the non-real-time process is assigned to the calculation resources. In this case, the interrupt generation time setting section 62a can calculate a next interrupt generation time tnusing the formula, tn=[(td−t0)−(cr−c0)]/(1−α)+t0.
td is a deadline, to is an interrupt generation time, cr is the value of a predetermined amount of calculation represented by a calculation time when there is no influence of the back processor thread and c0 is the value of an amount of calculation acquired at time to represented by a calculation time when there is no influence of the back processor thread. Furthermore, α is a minimum guaranteed value and is also the value of a minimum guaranteed amount of calculation performance obtained when a non-real-time process is processed represented by a ratio with respect to the calculation performance obtained when the non-real-time process is not processed and takes a value within a range of 0 or above and less than 1. When α is a value close to 1, this means that substantially no non-real-time process is carried out and there is substantially no influence of the non-real-time process compared to the processing of the real-time process. On the contrary, when α is 0, this means that the entire processor is occupied by the non-real-time process and the real-time process is not processed at all.
The reservation of the calculation resource using the calculation resource reservation system of the present invention will be explained in detail.
First, at time 0, the slack time is calculated. Since it is time 0 and the calculation time is also 0, slack time 4 ms is calculated from the above described formula ts=(td−t0)−(cr−c0). Since there is a slack time, the back processor thread is not left idle and an interrupt is generated at time 4 ms. As described above, this interrupt is executed to acquire a calculation time at time 4 ms. The embodiment shown in
In the embodiment shown in
For example, when a minimum guaranteed value a is 0.5, it is guaranteed that the processor performance of 50% can always be assigned to the real-time process. As described above, a slack time of 4 ms is calculated, but the next interrupt is calculated as time 8 ms from the above described formula tn=[(td−t0)−(cr−c0)]/(1−α)+t0. This means that when the processor carries out processing using a minimum guaranteed value, the time at which the slack time becomes 0 is 8 ms. In the embodiment shown in
Here,
According to the result shown in
Furthermore, when the case where the present invention system is used is compared to a conventional case where processing of a non-real-time process being in real-time process is suspended and a non-real-time process is processed after the real-time process is completed, it is possible to confirm that the amount of processing of the non-real-time process can be obtained with a throughput of a maximum of 1.9 times or at least a throughput equivalent to the conventional throughput.
The present invention has been explained using the embodiments shown in the attached drawings so far, but the present invention is not limited to the embodiments shown in the attached drawings, and it is also possible to achieve the functions of the various sections by executing a program as described above. In this case, the present invention can also be provided as a recording medium in which the program is recorded. When the present invention is provided as a recording medium, the program can be executed by the processor which is a calculation resource and the program can be provided as an interrupt handler as shown above. However, in this case, the processor executes the program to generate an interrupt, decides a slack time and suspends the non-real-time process.
Since the system of the present invention is a system that guarantees a deadline for a real-time process and at the same time processes other processes whenever possible to improve the system throughput, it is preferably used for an aircraft control system or medical system, etc., whose deadline must be strictly observed.
The foregoing description of the invention has been presented for purposes of illustration and description. It is not intended to be exhaustive or to limit the invention to the precise form disclosed, and other modifications and variations may be possible in light of the above teachings. For example, the invention may a computer program product embodied in a tangible media. The tangible media may include, but is not limited to, computer readable random access memory, read only memory, magnetic memory, optical memory and the like.
The embodiments disclosed were chosen and described in order to best explain the principles of the invention and its practical application to thereby enable others skilled in the art to best utilize the invention in various embodiments and various modifications as are suited to the particular use contemplated. It is intended that the appended claims be construed to include other alternative embodiments of the invention except insofar as limited by the prior art.
Number | Date | Country | Kind |
---|---|---|---|
JP2003-398823 | Nov 2003 | JP | national |