| Prev | Next | Start of Chapter | Next Chapter | Contents | Glossary | Index | Comments | (22 out of 22)

Timing Parameters

The Timing Parameters system table controls several scheduler settings and other computational parameters.

Defining the Scheduler Mode

The Scheduling-mode attribute defines the timing mode of the scheduler (how the G2 clock ticks), and how tasks are scheduled. G2 has three scheduler modes:


Note: A clock tick is a measure of time within G2 that may or may not be equivalent to one second of real time. The relationship between a clock tick and real time is determined by the value of the Scheduler-mode attribute.

Real Time

If the scheduler mode is real time, a clock tick corresponds to one second of real time. If G2 completes all of the tasks that are scheduled for a particular second before the second ends, G2 waits until the second is over before starting to process tasks scheduled for the next second.

If G2 has tasks left over at the end of a second, it begins processing tasks scheduled for the next second, anyway. When this happens, G2 schedules the remaining old tasks with the tasks scheduled for the new second, preserving the priority of all tasks, and preserving temporal ordering within priorities. G2 performs tasks from the previous second before it performs tasks with an equal priority from the next second. It does not, however, perform lower priority tasks from the previous second before higher priority tasks from the next second. The default mode is real time.

Simulated Time

Simulated time always attempts to match real time. However, when running in simulated time, G2 completes all of the tasks scheduled for one second before moving on to the tasks scheduled for the next second. As a result, a second of simulated time may last longer than a second of real time. Consequently, the simulator clock may run slower than the real-time clock.

If you pause a KB, reach a breakpoint, or suspend G2, the simulated time stops. When you resume, the simulated time does not leap ahead to match real time. Thus, simulated time lags behind real time as a result of such interruptions.

As Fast As Possible

When the Scheduler-mode is set to as-fast-as-possible, and all tasks in the current task queue are complete, the scheduler checks to see if tasks are scheduled on the future task queue. If tasks are scheduled, the scheduler ticks the clock forward all the way to the time of the next scheduled task and starts its execution cycle. If no tasks are in the future task queue, the scheduler becomes idle and does not tick the clock until tasks appear on the future task queue. For more information about the scheduler and the current and future task queues, see Scheduling and Prioritizing Tasks.

As fast as possible time is a convenient scheduler mode for discrete event simulations, so that tests that might otherwise require hours to complete require only minutes.


Caution: The G2 clock has a limit of 17 calendar years. Reaching that limit, for example when running simulations using the as fast as possible mode, will abort G2.

Specifying the Minimum Scheduling Interval

The Minimum-scheduling-interval attribute specifies the length of time for a clock tick, which determines how long the scheduler has to perform tasks between clock ticks. The default value is the time interval 1 second. Possible values for the attribute are any non-negative-number time interval, or continuous.

If you are entering a time interval (rather than continuous as the interval), the interval value must be a multiple of a second, or divide evenly into a second. If you enter another kind of value, G2 rounds the value up to the next valid minimum scheduling interval. For example, if you enter .333 seconds as the minimum scheduling interval, G2 rounds that number up to .334 upon completing the edit. Entering .666 seconds causes G2 to behave as if the value were 1.0, rounding it to 1 second.

When the Minimum-scheduling-interval attribute is set to a time interval, the scheduler advances the G2 clock by multiples of that amount (for instance, .333 seconds, or 1 second). When a time interval is in effect, G2 rounds the execution times of scheduled tasks up to the next clock tick. For example, if the current subsecond time is 5.0, and the Minimum-scheduling-interval is set to 0.25 seconds, G2 schedules the action start update report after 0.6 seconds to run at 5.75 seconds, current subsecond time.

If the interval is continuous, the scheduler ticks the clock at the task schedule times, and remains idle between those tasks. Continuous scheduling incurs clock ticks of various lengths, as tasks are scheduled. For example, if the scheduler ticks the clock, completes the tasks on the current task queue, and then sees that there is something scheduled on the future task queue in .2 seconds, the clock ticks at that time. Conversely, if nothing is scheduled on the future task queue for 5 minutes after the current task completes, the scheduler does not tick the clock until then.

Controlling the G2 Sleep Interval Under VMS

When G2 has nothing to do, it relinquishes the CPU (sleeps) until some event awakens it. G2 is event-driven for all types of events on all platforms except VMS: it can sleep indefinitely, and wakes as soon as an event gives it something to do.

Under VMS, G2 is event driven for all types of events except GUI events in the local G2 window (as distinct from a Telewindow). To avoid locking out such events, G2 when running under VMS wakes periodically and polls for them. The maximum time that G2 can sleep under VMS without polling for GUI events is its maximum sleep interval.

Sleep intervals are relevant only to G2's response to GUI events in the local window under VMS and OpenVMS on the Alpha and VAX VMS platforms. G2 is event-driven for all other types of events under VMS, and for all types of events whatsoever on all other platforms.

The Milliseconds-to-sleep-when-idle attribute sets the maximum time, in milliseconds, that G2 can sleep under VMS. When this time expires, G2 wakes and polls for GUI events. The attribute has no effect on G2's processing speed: it is strictly a timeout that triggers polling when G2 is idle. Setting Milliseconds-to-sleep-when-idle has no effect except under VMS.

The default value, obtained by specifying use default, is 40 milliseconds. By adjusting this value you can trade off between the CPU load when G2 is idle and G2's response time to GUI events.

As you raise the value above the default, fewer CPU cycles are lost to polling, but GUI operations, such as dragging an icon from one location to another on a workspace, can appear to jump as G2 wakes up to process them.

As you decrease the sleep interval, the G2 percent-run-time meter shows higher and higher values. If the sleep interval is zero, the meter returns 100.0, and G2 does not sleep at all. The result is maximum GUI response time, and considerable waste of CPU cycles.

Specifying the G2-Meter Lag Time

The Meter-lag-time attribute tells G2 how many seconds of data to use when computing values for G2 meters.

Frequently, performance values are expressed in events per second or are measured in seconds. For example, a G2 meter can track the number of formulas G2 evaluates each second, or how long a clock tick actually lasts in terms of seconds. G2 meters can compute such values for the most recent clock tick, or they can compute values based on an average result of recent clock ticks. The Meter-lag-time attribute controls how many seconds worth of data G2 uses in evaluating each meter.

The Meter-lag-time attribute holds a value of 0 seconds or any longer time interval. If it holds 0 seconds, G2 meters reflect only the activity in the most recently completed clock tick. As its value increases, the values of G2 meters change more smoothly over time.

G2 computes lagged values as follows:

new lagged value =
(1 - ) * previous lagged value
+ ( * current value)

where:
Is equal to min (1.0, clock tick length / meter lag time)

This is an Euler approximation of first-order delay. Note that if the meter lag time is zero or is less than the latest clock tick length, then = 1.0, and the new lagged value = the current value, with no lag.

Specifying the Interface Mode to Use

The Interface-mode attribute specifies which interface mode G2 uses, as follows:

This interface mode... Causes G2 to...
always service interface first
Make responding to the mouse and keyboard a priority over all scheduled events.
interruptible interface service
Give an equal share of computing time to the keyboard and mouse, the Inference Engine, the G2 Simulator and other data servers. The G2 Simulator is a superseded capability. For more information, see Appendix F, Superseded Practices.

Adjusting the G2 Clock

The Clock-adjustment-in-minutes attribute adjusts G2's clock as follows:

This clock adjustment... Causes G2 to...
positive number
Increase the clock by the specified number of minutes.
negative number
Increase the clock by the specified negative number.
0
Leave the clock unchanged.

Controlling the Foreign Function Timeout Interval

The Foreign-function-timeout-interval attribute controls the interval of time that G2 waits for a return value after calling a foreign function. If the interval is exceeded, G2 signals an error. Specify an integer to represent the interval in seconds.


Note: Setting the Timeout-interval attribute of an individual foreign function definition overrides the value set for the Foreign-function-timeout-interval attribute of the Timing Parameters system table for that function.

Controlling Foreign Image Reconnection

The Reconnect-to-foreign-image-after-timeout? attribute controls whether G2 reconnects to a foreign image (a group of foreign functions) after the foreign function timeout interval expires. If the value for this attribute is yes, G2 makes a single attempt to reconnect to the foreign image. If the value is no, G2 does not attempt to reconnect.

Setting the Uninterrupted Procedure Limit

The Uninterrupted-procedure-execution-limit attribute sets a limit on the amount of execution time a procedure can use without entering a wait state that allows other processing to occur. Specify an integer to represent the number of seconds, or none. The actual limit for this attribute is 24 hours. Note that setting the execution time limit locally for a procedure overrides the limit set for this attribute.

Class-Specific Attributes of Timing Parameters

The class-specific attributes of the Timing Parameters system table are:

Attribute Description
Scheduler-mode
The current mode in which the scheduler is running.
Allowable values:
{real time | simulated time | as fast as possible}
Default value:
real time


Minimum-scheduling-interval
The length of the G2 clock tick.
Allowable values:
{subsecond-interval | continuous}
Default value:
1 second


Milliseconds-to-sleep-when-idle
Controls the interval of time, in milliseconds, that G2 sleeps while the G2 process is idle.
Allowable values:
any positive integer
use default

Default value:
use default


Meter-lag-time
The number of seconds of data to use when computing G2 meter values.
Allowable values:
time-interval
Default value:
10 seconds


Interface-mode
Specifies which interface mode G2 uses.
Allowable values:
{interruptible interface service | always service interface first}
Default value:
interruptible interface service


Clock-adjustment-in-minutes
The number of minutes to adjust G2's clock.
Allowable values:
integer
Default value:
0


Foreign-function-timeout-interval
The interval of time that G2 waits for a return value after calling a foreign function.
Allowable values:
{none | time interval}
Default value:
30 seconds


Reconnect-to-foreign-image-after-timeout?
Whether G2 reconnects to a foreign image (a group of foreign functions) after the foreign function timeout interval expires.
Allowable values:
{yes | no}
Default value:
no


Uninterrupted-procedure-execution-limit
A limit on the amount of execution time a procedure can use without entering a wait state that allows other processing to occur.
Allowable values:
{time-interval | none}
Default value:
30 seconds

| Prev | Next | Start of Chapter | Next Chapter | Contents | Glossary | Index | Comments | (22 out of 22)

Copyright © 1997 Gensym Corporation, Inc.