1. Field of the Invention
The present invention relates to real-time event scheduling systems. In particular, the invention relates to dynamic slip control that takes into account the actual time that events occur.
2. Description of the Related Art
Real-time systems must maintain a timely and accurate interaction with their physical environment in order to meet the overall system design objectives. The times at which the interaction occurs and the values of the system state at the interaction times are critical parts of the system performance. The further the actual interaction time is from the desired interaction time, and the further the system state value is from the desired value, the worse is the quality of the system performance.
The interaction between the real-time system and its environment may be initiated by the real-time system, which is called proactive interaction, or by the environment, which is called reactive interaction. Since the real-time system and its environment are typically distributed systems, their interactions are asynchronous.
When elapsed time does not play a role in the interaction, the situation requires discrete event scheduling only. However, when elapsed time does play a role in the interaction, the situation requires real-time event scheduling. Discrete event scheduling is usually adequate when the real-time system's internal state is purely logical or symbolic. Real-time event scheduling is necessary when the real-time system has time-dependent internal state. Some examples of systems where real-time event scheduling is necessary are observer-based control systems, discrete time observation feedback systems, and real-time simulation systems. In the first case, the real-time system filters its timed observations of the environment. In the second case, the real-time system uses timers to schedule the observation feedback computations. In the third case, the real-time system simulates the control system as well as parts or all of the physical environment.
In many implementations, real-time systems are realized simply as discrete time tasks with periodic scheduling. For example, let x be the real-time system's internal state and let Δ be the scheduling period. The variable k denotes the period number and the function ck updates the internal state to the new period number. Then, at times
0,Δ,2Δ, . . . , kΔ,
the computation
x[k+1]=ck(x[k])
is performed based on the observation at kΔ.
Often, multiple such tasks are scheduled concurrently on the same real-time implementation platform, and techniques such as rate monotonic scheduling are used to guarantee the design performance of such systems. Exemplary references include C. L. Liu and J. W. Layland, Scheduling algorithms for multiprogramming in a hard real-time environment, 20(1) J
Because many real-time platforms may be implemented with periodic scheduling, such an approach is simple and attractive for scheduling each task. However, the periodic scheduling approach, while simple, leads to several drawbacks when implementing event scheduling models.
First, the essential asynchronous nature of the system is lost, leading to added latency in the interaction with the environment. In proactive interactions, this latency arises because the interaction time is different from the desired event time, which is typically the time at which the system's internal state crosses some guard condition. In reactive interactions, this latency arises because the interaction occurs at the end of the scheduled period even though the asynchronous interrupt may occur before the period expires.
Second, additional computational load is placed on the implementation because computations are performed periodically whether or not they are used. This additional computational load may require more expensive real-time implementation platforms.
Third, while the kth event is scheduled at time kΔ, the actual time at which the event occurs is generally off from the scheduled time because of the nonideal nature of the underlying physical implementation platform. Even so, the state value at the scheduled time kΔ, and not the state value at the actual event time, is used in the interaction. This leads to inaccurate interaction with the physical environment.
Given these problems, real-time event scheduling is often desired over event scheduling implemented by a periodic system. However, even if a well-designed real-time system can theoretically guarantee the timely completion of all tasks, in practice the tasks may not be completed at the desired times because of imperfections in the underlying real-time implementation platform.
The discrepancy between the actual and desired interaction times is called the slip of the system. Slip control is an algorithmic technique for ensuring that slip is small. Dynamic slip control uses the application's dynamical model information to reduce both slip and the discrepancy in the system's state values.
Traditional real-time scheduling techniques typically do not use the application's dynamical models for fine-tuning the scheduler performance. While system implementations may use physical time information for scheduling timer interrupts, they do not use physical time information to correct for slip. Thus, while they can achieve some level of slip control for simple applications with periodic schedules, generally they cannot achieve dynamic slip control for general purpose real-time event scheduling. Thus, there is a need for an algorithmic technique for dynamic slip control for real-time event scheduling.
The present invention addresses these and other problems of the prior art by providing an apparatus, method, and computer-readable program code for dynamically controlling slip.
According to one embodiment, a method according to the present invention includes the steps of detecting an actual interrupt time corresponding to an actual interrupt, interacting with a physical environment in response to the actual interrupt, and calculating a wait period based on the actual interrupt time and the interacting step. The wait period corresponds to a next scheduled interrupt time. The method further includes the step of detecting a completion time after the calculating step. The method still further includes the step of reducing the wait period calculated, based on the completion time and the actual interrupt time. The method yet further includes the step of waiting for at most the wait period as resulting from the reducing step.
According to another embodiment, a computer-readable program code according to the present invention includes a computer-readable program detection code, a computer-readable program interaction code, a computer-readable program calculation code, a computer-readable program reduction code, and a computer-readable program wait code. The computer-readable program detection code is configured to detect an actual interrupt time corresponding to an actual interrupt and to store an actual interrupt time value. The computer-readable program interaction code is configured to interact with a physical environment in response to the actual interrupt. The computer-readable program calculation code is configured to calculate a wait period based on the actual interrupt time and the computer-readable program interaction code. The wait period corresponds to a next scheduled interrupt time. The computer-readable program detection code is further configured to detect a completion time, after operation of the computer-readable program calculation code, and to store a completion time value. The computer-readable program reduction code is configured to reduce the wait period based on the completion time value and the actual interrupt time value. The computer-readable program wait code is configured to wait at most for the wait period as resulting from operation of the computer-readable program reduction code.
According to yet another embodiment, an apparatus according to the present invention includes a processor circuit, and a memory circuit. The processor circuit is configured to process instructions and data. The memory circuit is coupled to the processor circuit and is configured to store a computer-readable program code, said computer-readable program code comprising instructions and data, configured to operate with the processor circuit, and is otherwise as described above.
By reducing the wait period based on actual interrupt time (instead of scheduled interrupt time) and on the completion time, slip is prevented from accumulating and is reduced.
A better understanding of the features and advantages of the present invention will be obtained by reference to the following detailed description and accompanying drawings which set forth illustrative embodiments in which the principles of the invention are utilized.
The following detailed description is arranged as follows. First, an ideal theoretical application modeling framework is presented. Then a three-layered implementation structure is put forward. Next, slip is defined and dynamic slip control is described. An algorithmic presentation of the dynamic slip control process is then made. Next, a theoretical example illustrates various system implementations including the dynamic slip control process. Finally, relevant portions of a C++ source code implementation are provided in an appendix.
Although this application uses the terms “hardware” and “software” to refer to the implementation of a preferred embodiment of the present invention, it is contemplated that these specific terms are not required and that the present invention may be implemented in microcode, firmware, etc. as desired.
Ideal Modeling Framework
In defining an ideal proactive scheduling framework, let
[t′0,t1],[t′1,t2], . . . , [t′k,tk+1], (1)
be a sequence of time phases with the following properties:
Let x be the system's continuous state variable. The variable x has piecewise continuous trajectories. In the phase [t′k, tk+1], let the system's dynamical model be given as
{dot over (x)}=fk(x) (2)
with the initial condition x(t′k)=xk.
At time t′k define
Δk=inf{tlgk(x(t))≧0} (3)
tk+1=t′k+Δk (4)
where the function gk(x(t)) defines a guard function.
In the transition from tk+1 to t′k+1, the following computation is performed:
x(t′k+1)=ck(x(tk+1)) (5)
We will interpret the execution of this computation as an interaction of the system with the physical environment. We will treat t′k+1 as the time at which this interaction occurs. The state information at time tk+1 is used for the interaction.
Then, define the value sequence corresponding to the phase sequence (1) as
(x(t′0),x(t1)),(x(t′1),(x(t2)), . . . , (x(t′k),x(tk+1)), (6)
This model is derived from a hybrid system model with switched flow equations and guarded transitions with actions. The hybrid system model is described in R. Alur, C. Courcoubetis, T. Henzinger, and P. Ho, Hybrid Automatia: An Algorithmic Approach to the Specification and Verification of Hybrid Systems, H
In defining an ideal reactive scheduling framework, let Ik≧t′k be the time at which the physical environment interrupts the application given that the kth event has already occurred.
Then, equation (4) is modified as
tk+1=min(t′kΔk,Ik) (7)
Further, the computation to be performed at the kth event may depend on the type of interrupt (proactive vs. reactive) that caused it. Let τk be the type of the interrupt. Then, equation (5) is modified as
x(t′k+a)=ck(τk,x(tk+1)) (8)
Implementation Structure
Application software 102 contains the functional description of the specific application model, namely, the variable x, and the functions fk, gk, and ck.
Scheduling software 104 contains the algorithmic description of the event scheduler, namely, the computational procedure for taking the transitions from tk to t′k and from t′k to tk+1, and for evaluating tk+1, the next event time. Scheduling software 104 is more fully described below with reference to
Implementation platform 106 contains the hardware and software platform that provides the real-time implementation services, namely, physical time information, timer and environment interrupt delivery, and numerical processing.
Physical environment 110 is the real-world system with which event scheduling system 100 interacts. Such interaction may be in the form of signals from physical environment 110 indicating its state, and signals from event scheduling system 100 to which physical environment 110 is to respond. This response may include modifying its state, thereby forming a dynamic feedback loop.
Slip
Let
[{tilde over (t)}′0,{tilde over (t)}1],[{tilde over (t)}′1,{tilde over (t)}2], . . . , [{tilde over (t)}′k,{tilde over (t)}k+1], (9)
be a sequence of slipped time phases with the following properties:
Define slip Sk as the interval between the occurrence of interaction with the physical environment and the scheduled time of that interaction:
Sk={tilde over (t)}′k−t′k (10)
Slip arises from internal factors such as unaccounted processing time as well as external factors such as inaccurate delivery of timer interrupts by the real-time platform. Let sk be the slip during the kth phase. The slip sk arises due to processing and interrupt latency associated with the kth event only. Then, unless special care is taken to account for it, slip could accumulate as
Another effect of inadequate slip control is that the interaction with the physical environment can be based on out-of-date state values. Typically, the value sequence (6) is used in conjunction with the slipped time phase sequence (9), leading to inaccurate interaction with the environment.
Dynamic Slip Control
There are three objectives of slip control. The first is to ensure that slip does not accumulate; i.e., that Sk is independent of k. The second is to ensure that slip is small; i.e., that Sk is as close to zero as possible. The third is to ensure that the interaction with the physical environment is based on up-to-date state values; i.e., that the value sequence is
(x({tilde over (t)}′0),x({tilde over (t)}1)),(x({tilde over (t)}′1),(x({tilde over (t)}2)), . . . , (x({tilde over (t)}′k),x({tilde over (t)}k+1)), (12)
Skenv—random latency introduced by the real-time platform in delivering an interrupt
Skupd—processing time required to integrate the system state flow equation (2)
Skcomp—processing time required to compute the state update computation, equation (5)
Skg—processing time required to compute tk [see equations (3) and (4)]
{tilde over (Δ)}k—time interval to the next timer interrupt
Suppose that the kth timer interrupt is scheduled for time tk. Implementation platform 106 will deliver the interrupt to scheduling software 104 at
{tilde over (t)}k=tk+Skenv
At the time
Tupd={tilde over (t)}k+Skupd
scheduling software 104 will complete the state variable update to time {tilde over (t)}k, yielding x({tilde over (t)}k). At the time
{tilde over (t)}′k=Tupd+Skcomp
system 100 will complete interacting with the physical environment 110, yielding x({tilde over (t)}′k). At the time
Tr={tilde over (t)}′k+Sk+1g
scheduling software 104 will complete the computation of Δk+1. Scheduling software 104 will compute
{tilde over (Δ)}k=Δk−(Tr−{tilde over (t)}k)
and set the timer interrupt to occur after {tilde over (Δ)}k. This ensures that the (k+1)st timer interrupt is scheduled for time tk+1.
Note that slip is
Sk=Skenv+Skupd+Skcomp (13)
Note the following characteristics of equation (13). First, since the right hand side of equation (13) is independent of any cumulative effects, this procedure ensures that slip does not accumulate.
Second, the magnitude of the slip in equation (13) can be reduced by reducing one or more of Skenv, Skupd and Skcomp. In addition, slip can be reduced by estimating each of these contributing factors and then accounting for them in the computation of {tilde over (Δ)}k. The estimation can be accomplished either by analyzing the performance of the real-time platform and the application model in an off-line manner, or by maintaining statistical performance information in an on-line manner.
Third, the computation at {tilde over (t)}′k is based on state values at {tilde over (t)}k and not at tk, ensuring accurate interaction with the physical environment.
Fourth, the slip component Skg is removed altogether from equation (13) because {tilde over (Δ)}k takes the physical time reading Tr into account.
This approach to dynamic slip control works because it uses two important elements: information about the application models and information about the physical time at critical points in the execution cycle.
Because this approach to real-time event scheduling uses the value sequence (12), care must be taken in programming the computations ck in the model.
For example, consider a simple system in which xεR, fk(x)=1, x0=0, guard crossing is triggered whenever x≧Δ, and ck assigns 0 to x. Ideally, in this system, an event is scheduled at each kΔ.
Now, let Skenv=δ for each k. Then, in fact, events will be scheduled at times k(Δ+δ), leading to increasing slip.
The correct modeling of the computation ck is to assign x−Δ to x. Thus, with Skenv=δ, the value of x after ck will be δ. This leads to interrupts being scheduled at each kΔ as desired, and the slip is always δ, which is unavoidable. Note that slip does not accumulate.
Algorithm for Dynamic Slip Control
We will assume that the real-time platform provides the function
current_time( )
to obtain the value of physical time at the time of the call, and the function
τ=set_interrupt_timer(T)
to set the timer interrupt to occur T seconds after the call. The effect of set_interrupt_timer(T) is to suspend the algorithm until either the timer interrupt or the interrupt from the physical environment occurs, after which execution is resumed. The function returns the type of interrupt which caused the execution to be resumed.
We will assume that the scheduler provides the function
next_event_time(k,x)
which solves for {tilde over (Δ)}k, the function
update(k,T)
which integrates equation (2) forward by time T, and the function
computer(τ,k,x)
which invokes the computation (8).
We will assume that the initial slip S0=0. Following is pseudocode for the scheduler algorithm.
x=x0
t=current_time( )
k=1
forever {
Δ=next_event_time(k,x)
τ=set_interrupt_timer(Δ−(current_time( )−{tilde over (t)}))
{tilde over (t)}next=current_time( )
x=update(k,({tilde over (t)}next−{tilde over (t)}))=
{tilde over (t)}={tilde over (t)}next
x=compute(τ,k,x)
k=k+1
}
This pseudocode is detailed with reference to
In step 152, the state variables x and t are initialized by application software 102 and scheduling software 104, respectively, and scheduling software 104 sets the counter k to 1. In step 154, implementation platform 106 notes the current time and scheduling software 104 stores this value as {tilde over (t)}. In step 156, scheduling software 104 computes the time to the next event and stores this value as Δ.
In step 158, implementation platform 106 notes the current time and scheduling software 104 stores this value as Tr. That is, the computation of step 156 takes an amount of time equal to the difference between Tr and {tilde over (t)}. This difference is represented by the period Ske in
In step 160, scheduling software 104 instructs implementation platform 106 of the modified Δ time period, and scheduling software 104 and application software 102 then enters a sleep or inactive mode.
In step 162, implementation platform 106 generates an interrupt, ending the sleep period of step 160. If implementation platform 106 generates a reactive interrupt, that is, an interrupt from physical environment 110, the sleep period ends prematurely. If implementation platform 106 generates a proactive interrupt, that is, on expiration of the modified Δ time period, then the sleep period ends as scheduled, as modified by the slip Skenv (see
In step 164, scheduling software 104 instructs application software 102 to update the state variables corresponding to physical environment 110. Application software 102 then updates the state x using the function ƒk(x). As noted in
In step 166, scheduling software 104 replaces the stored {tilde over (t)} with {tilde over (t)}next in preparation for the incrementation of k when the algorithm is repeated. Note that step 166 is not required to be located between steps 164 and 168, and may be performed at any time prior to the next time {tilde over (t)} is used (that is, in step 168).
In step 168, scheduling software 104 instructs application software 102 to update the state variables corresponding a desired action in relation to physical environment 110. Application software 102 then computes the modified state xk+1 using the function ck. This may also involve implementation platform 106 passing the updated state variables to physical environment 110. As noted in
In step 170, scheduling software 104 increments k, and loops back to step 156.
Source code in C++ language implementing this algorithm is contained in the Appendix.
The controller equation is
where x is the controller's internal state and
where y is the physical system's internal state and
Models of four interfaces are shown in
The dynamic slip control interface of
The no value update interface of
The no slip control interface of
The parameter values for the example were chosen as
Each interface of the system was modeled, simulated and analyzed using the DIADEM real-time software tools and platforms. See A. Deshpande, The DIADEM System for Real-Time Dynamic Event Management, LNCS P
For this example, the error in the case of no value update interface is about five times worse than the error in the case of dynamic slip control interface, and the error in the case of no slip control interface is about five times worse than the error in the case of no value update interface.
The above-described embodiments of the present invention reduce slip in real-time event scheduling systems, thereby improving performance of those systems. Slip is reduced by setting a wait period based on the difference between the actual interrupt time (instead of the scheduled interrupt time) and the completion time of various interactions and calculations.
It should be understood that various alternatives to the embodiments of the invention described herein may be employed in practicing the invention. It is intended that the following claims define the scope of the invention and that structures within the scope of these claims and their equivalents are covered thereby.
This application is a continuation of U.S. patent application Ser. No. 09/318,913 filed on May 26, 1999, now abandoned, which claims the benefit of U.S. Provisional Application No. 60/086,874 filed on May 27, 1998. The contents of each of which are hereby incorporated by reference herein in their entirety.
Number | Name | Date | Kind |
---|---|---|---|
4263647 | Merrell et al. | Apr 1981 | A |
4800521 | Carter et al. | Jan 1989 | A |
5247677 | Welland et al. | Sep 1993 | A |
5260868 | Gupta et al. | Nov 1993 | A |
5301312 | Christopher et al. | Apr 1994 | A |
5325525 | Shan et al. | Jun 1994 | A |
5392429 | Agrawal et al. | Feb 1995 | A |
5408663 | Miller | Apr 1995 | A |
5465335 | Anderson | Nov 1995 | A |
5530879 | Crump et al. | Jun 1996 | A |
5574912 | Hu et al. | Nov 1996 | A |
5619409 | Schultz et al. | Apr 1997 | A |
5623647 | Maitra | Apr 1997 | A |
5623677 | Townsley et al. | Apr 1997 | A |
5636124 | Rischar et al. | Jun 1997 | A |
5640563 | Carmon | Jun 1997 | A |
5687381 | Swanstrom et al. | Nov 1997 | A |
5701481 | Hosaka et al. | Dec 1997 | A |
5781187 | Gephardt et al. | Jul 1998 | A |
5784616 | Horvitz | Jul 1998 | A |
5826080 | Dworzecki | Oct 1998 | A |
5872909 | Wilner et al. | Feb 1999 | A |
5890134 | Fox | Mar 1999 | A |
5902352 | Chou et al. | May 1999 | A |
5938708 | Wallace et al. | Aug 1999 | A |
5944778 | Takeuchi et al. | Aug 1999 | A |
5944840 | Lever | Aug 1999 | A |
5974439 | Bollella | Oct 1999 | A |
5995997 | Horvitz | Nov 1999 | A |
6000029 | Moyer et al. | Dec 1999 | A |
6105048 | He | Aug 2000 | A |
6108683 | Kamada et al. | Aug 2000 | A |
6110220 | Dave et al. | Aug 2000 | A |
6189070 | See et al. | Feb 2001 | B1 |
6272517 | Yue et al. | Aug 2001 | B1 |
6279108 | Squires et al. | Aug 2001 | B1 |
6341303 | Rhee et al. | Jan 2002 | B1 |
6349321 | Katayama | Feb 2002 | B1 |
6359622 | Hayes-Roth | Mar 2002 | B1 |
6385637 | Peters et al. | May 2002 | B1 |
6385638 | Baker-Harvey | May 2002 | B1 |
6425091 | Yang et al. | Jul 2002 | B1 |
6438573 | Nilsen | Aug 2002 | B1 |
6499050 | Boswell et al. | Dec 2002 | B1 |
7207045 | Goiffon | Apr 2007 | B2 |
7451447 | Deshpande | Nov 2008 | B1 |
Number | Date | Country | |
---|---|---|---|
60086874 | May 1998 | US |
Number | Date | Country | |
---|---|---|---|
Parent | 09318913 | May 1999 | US |
Child | 10665875 | US |