STIMER — Set interval timer

Description

The STIMER macro sets a timer to a specified time interval or to an interval that will expire at a specified time of day. An optional asynchronous timer completion exit is given control when the time interval expires; if no asynchronous timer completion routine is specified, no indication that the time interval has expired is provided. A second STIMER macro issued before the first time interval expires overrides the first interval and exit routine.

The time interval may be a ‘real-time interval’ (measured continuously in real time by the clock comparator), or a ‘task-time interval’ (measured, only while the task is in execution, by the CPU timer). See Principles of Operation for information on the clock comparator and CPU timer. If a real-time interval is specified, the task may elect to either continue (REAL) or suspend (WAIT) execution during the interval. If the task elects to continue execution, it may optionally specify an exit routine to be given control on completion of the time interval. If the task elects to suspend execution, it is restarted at the next sequential instruction, sometime after completion of the time interval. If a task-time interval is specified, the task must continue. It may optionally specify an exit routine to be given control on completion of the interval.

STIMER allows you to set one time interval for one task; STIMERM allows you to set 16 separate time intervals for a task. Using the two macros together allows you to set 17 separate intervals for a task.

For information on how to select an MVS/SP version other than the current version, see Compatibility of MVS macros. If your program is to execute in 31-bit addressing mode, you must use the SP Version 2 expansion of this macro or a later version.

Environment

The requirements for the caller are:

Environmental factor Requirement
Minimum authorization: Problem state and any PSW key.
Dispatchable unit mode: Task
Cross memory mode: PASN=HASN=SASN
AMODE: 24- or 31- or 64-bit
ASC mode: Primary
Interrupt status: Enabled for I/O and external interrupts
Locks: No locks held
Control parameters: Must be in the primary address space.

Programming requirements

The timer completion exit routine must be in virtual storage when it is required.

Restrictions

The following restrictions apply to the STIMER macro:
  • Only one STIMER invocation can be active at a time. Ensure that any processing your program performs after issuing the STIMER macro does not also invoke the STIMER macro. For concurrent requests, use the STIMERM macro.
  • Do not issue the STIMER macro while a BTAM OPEN or LINE OPEN operation is in progress. Use STIMERM instead.
  • Do not issue the STIMER macro before invoking dynamic allocation. Use STIMERM instead.
  • For REAL or WAIT requests:
    • If you specify a time of day at which the interval will expire (GMT (Greenwich Mean Time), LT (local time), or TOD (Time of Day) parameters), the time of day you specify must not exceed 24:00:00:00; otherwise, your program receives a X'12F' abend.
    • If you specify a time interval on the MICVL parameter, the interval you specify, when added to the current TOD clock contents, must not exceed the maximum value for the clock comparator (X'FFFFFFFFFFFFFFFF'); otherwise, your program receives a X'12F' abend.
  • For TASK requests, the time interval you specify on MICVL must not exceed the maximum positive value for the CPU timer (X'7FFFFFFFFFFFFFFF'); otherwise, your program receives a X'12F' abend.
  • You can issue STIMER REAL with a timer completion exit routine, and within that routine, you can issue STIMER REAL and specify the same timer completion exit routine. Under these circumstances, IBM® recommends that you specify a time interval rather than a time of day on the STIMER you issue within the timer completion exit routine. If you specify a time of day, it is possible for the timer completion exit routine to receive control later than the time of day you specified, resulting in an infinite loop.
  • The caller can have no enabled, unlocked task (EUT) FRRs established.
  • The time interval you specify on the BINTVL parameter must not exceed X'7FFFFFFF'. If the time interval exceeds X'7FFFFFFF', your program receives a X'12F' abend.
  • If you make use of JES2 main task exit routines or have vendor code that could run under the JES2 main task, then this code cannot use the STIMER macro. Such use would usurp the timer JES2 sets with its use of the STIMER macro. The exit or vendor code would destroy JES2 processing and lead to unpredictable errors. STIMERM is the macro this code must use instead.

Input register information

Before issuing the STIMER macro, the caller does not have to place any information into any register unless using it in register notation for a particular parameter, or using it as a base register.

Output register information

When control returns to the caller, the registers contain:
Register
Contents
0-1
Used as work registers by the system
2-13
Unchanged
14
Used as a work register by the system
15
0 (zero)
When control returns to the caller, the access registers (ARs) contain:
Register
Contents
0-1
Used as work registers by the system
2-13
Unchanged
14-15
Used as work registers by the system

Some callers depend on register contents remaining the same before and after issuing a service. If the system changes the contents of registers on which the caller depends, the caller must save them before issuing the service, and restore them after the system returns control.

Performance implications

None.

Syntax

The STIMER macro is written as follows:

Syntax Description
   
   name name: Symbol. Begin name in column 1.
   
One or more blanks must precede STIMER.
   
STIMER  
   
One or more blanks must follow STIMER.
   

REAL
REAL,exit rtn addr
TASK
TASK,exit rtn addr
WAIT

exit rtn addr: RX-type address, or register (0) or (2) - (12).
   

,BINTVL=stor addr
,DINTVL=stor addr
,MICVL=stor addr
,GMT=stor addr
,TUINTVL=stor addr
,TOD=stor addr
,LT=stor addr

stor addr:  RX-type address, or register (1) or (2) - (12).
Note:  The GMT, TOD, and LT parameters must not be
specified with TASK above.

   
Note: The ERRET parameter is obsolete and is ignored by the system. Therefore, the syntax and parameter descriptions for STIMER no longer contain ERRET. However, the system still accepts ERRET, and it is not necessary to delete it from existing code.

Parameters

The parameters are explained as follows:

REAL
REAL,exit rtn addr
TASK
TASK,exit rtn addr
WAIT
Specifies whether the timer interval is a real-time interval (REAL or WAIT) or a task-time interval (TASK). You must specify one of these parameters.

For REAL, the interval is decreased continuously. If the TOD, GMT, or LT parameter is coded, the interval expires at the indicated time of day.

For TASK, the interval is decreased only when the associated task is running.

For WAIT, the interval is decreased continuously. The task is to be placed in the wait condition until the interval expires.

The exit rtn addr is the address of the timer completion exit routine to be given control after the specified time interval expires. The routine does not get control immediately when the interval completes, but at some time after the interval completes, depending on the system's work load and the relative dispatching priority of the associated task. The routine must be in virtual storage when it is required. The exit routine receives control in the same environment that the caller had when the caller issued the STIMER macro. The contents of the registers when the exit routine is given control are as follows:
Register
Contents
0-12
Do not contain any information for use by the routine.
13
Address of a system-provided, 72-byte save area.
14
Return address (to the system).
15
Address of the exit routine.

The exit routine is responsible for saving and restoring registers. The exit routine runs as a subroutine, and must return control to the address identified in register 14. Although timing services allows only one active time interval for a task, it does not serialize the use of an asynchronous timer completion exit routine.

,BINTVL=stor addr
,DINTVL=stor addr
,GMT=stor addr
,MICVL=stor addr
,TOD=stor addr
,TUINTVL=stor addr
,LT=stor addr
Specifies the storage address and format for the time of day, or time interval, to be set. You must specify one of these parameters.

For BINTVL, the address is a 4-byte area containing the time interval. The time interval is represented as an unsigned 32-bit binary number; however, the high-order bit of the time interval must not be set. Therefore, the time interval specified cannot exceed X'7FFFFFFF'. The low-order bit of the time interval has a value of 0.01 second.

For DINTVL, the address is a doubleword in virtual storage containing the time interval. The time interval is presented as zoned decimal digits of the form:

HHMMSSth, where:
HH
is hours (24-hour clock)
MM
is minutes
SS
is seconds
t
is tenths of seconds
h
is hundredths of seconds

For GMT, the address is an 8-byte area containing the Greenwich mean time at which the interval is to be completed. The time is presented as zoned decimal digits of the form HHMMSSth, as described above under DINTVL.

For MICVL, the address is a doubleword containing the time interval. The time interval is represented as an unsigned 64-bit binary number; bit 51 is the low-order bit of the interval value and equivalent to 1 microsecond.

For TUINTVL, the address is a fullword containing the time interval. The time interval is presented as an unsigned 32-bit binary number; the low-order bit has a value of one timer unit (approximately 26.04166 microseconds).

For TOD and LT, the address is a doubleword containing the local time of day at which the interval is to be completed. The time is presented as zoned decimal digits of the form HHMMSSth, as described under DINTVL.

The LT and TOD parameters perform identical functions. However, the name for the LT parameter (LT, or local time) describes the function more accurately than does the name for the TOD parameter (TOD, or time-of-day). Therefore, for clarity purposes, IBM recommends the use of the LT parameter instead of TOD.

Note: For the DINTVL, GMT, TOD, and LT parameters, the zoned decimal digits are not checked for validity. Thus, the specification of incorrect digits can result in an X'0C7' abend, or a time interval different from that desired.
Note:
  1. The time interval specified by an STIMER macro has no relation to the time interval specified in an EXEC statement.
  2. If no exit routine address is specified, there is no indication of completion except when WAIT is specified.
  3. The TTIMER and CPUTIMER macros provide a facility for determining the remaining time interval associated with STIMER.

The priorities of other tasks in the system can also affect the accuracy of the time interval measurement. If you code REAL or WAIT, the interval is decreased continuously and can expire when the task is not active. After the time interval expires, assuming the task is not in the wait condition for any other reasons, the task is placed in the ready condition and competes for control with the other ready tasks in the system. The additional time required before the task becomes active depends on the relative dispatching priority of the task.

ABEND codes

STIMER might abnormally terminate with one the following abend codes: X'12F' (with reason code X'0', X'4', X'C', X'10', X'14', X'28'), or X'AC7' (with reason code X'2'). See z/OS MVS System Codes for an explanation and response for these codes.

Return and reason codes

STIMER returns a return code of 0 in register 15.

Examples

Example 1: Request the installation's asynchronous exit routine, located at location EXIT, to receive control after fourteen hundredths of a second (specified by INTVLONG) have elapsed in real time.
          STIMER   REAL,EXIT,BINTVL=INTVLONG
          ⋮
INTVLONG  DC F '14'     TIME INTERVAL
Example 2: Request that this task's exit routine, located at location EXIT, receive control when the local time of day specified at location LOCAL occurs.
          STIMER   REAL,EXIT,LT=LOCAL
          ⋮
LOCAL     DS       2F
Example 3: Request that this task be put into a wait state until 60 seconds have passed.
          STIMER   WAIT,BINTVL=INTV2
          ⋮
INTV2     DC  F'6000'
Example 4: Request that this task's exit routine, located at location EXIT, receive control when the task has executed 60 seconds.
          STIMER   TASK,EXIT,BINTVL=INTV1
          ⋮
INTV1     DC  F'6000'