Timers in a Virtual Machine
Interval Timer
Virtual Interval Timer Assist
This section describes the results obtained in using timers in a virtual machine cre­
ated by CPo Virtual location 80 (X'50'), the interval timer, contains different values than would
be expected when operating in a real machine. On a real machine, the interval tim­
er is updated 300 times per second when enabled and when the real machine is not
in manual state. The interval timer on a real machine thus reflects system time and
wait state time. In a virtual machine, the interval timer reflects only virtual
processor time, and not wait time. It is updated Qy CP whenever a virtual machine
passes control to CP, and this one updating the entire time the virtual
machine had control. Note that during the time a virtual machine has control, the
virtual interval timer does not change; the virtual processor time used is added to
the virtual interval timer when CP regains control. For some privileged
instructions, CP may be able to simulate the instruction and still return control to
the virtual machine before the end of that virtual machine's time slice. In such
cases, the virtual interval timer is updated but only for those privileged instructions
that require normal or fast reflect entry into the dispatcher. For those privileged
instructions that do not require entry into the dispatcher, the virtual interval timer
is not updated until CP gets control at the end of the time slice.
If the virtual machine assist feature or Extended Control - Program Support is ON, more time is charged to the virtual interval timer than if the feature is OFF. When
the virtual machine assist feature is OFF, the time spent by CP to simulate privi­
leged instructions is not charged to the virtual interval timer; whereas, with the fea­
ture ON, the time spent is charged to the virtual interval timer.
The virtual interval timer assist feature is the updating of the virtual interval timer
and presentation of timer interrupts to the virtual machine by the hardware. When
the software simulates the interval timer, updating occurs only when CP takes over
control. This usually results in an update frequency of once per time slice and
repeatability of timed intervals suffers greatly under these conditions. When the
virtual interval timer assist feature is active, the update frequency is the same for
both virtual and real interval timers, 300 times a second.
In order for the virtual interval timer assist feature to be active, the following
conditions must be met: VM/SP must be running on a Model 135-3, 138, 145-3, 148,3031, 3031AP, 4331, or 4341.
The virtual machine must have enabled the virtual machine assist and the virtu­
al interval timer (SET TIMER {ON I REAL}).
The virtual machine must have enabled both the virtual machine assist and the
virtual interval timer assist (SET ASSIST ON TMR). VM/SP provides an option, called the REALTIMER option, which causes the vir­
tual interval timer to be updated during virtual wait state as well. With the
REAL TIMER option in effect, a virtual interval timer reflects virtual processor
time and virtual wait time, but not CP time used for services for that virtual
Timers in a Virtual Machine 205
Processor Timer TOD Clock
Clock COlllparator
machine, such as privileged instruction execution. The more services a virtual
machine requires from CP, the greater the difference between the time represented
by the interval timer and the actual time used by and for the virtual machine. The
larger the number of active virtual machines contending for system resources, the
greater the difference between virtual machine time and actual elapsed (wall clock)
time.
A virtual machine must have the ECMODE directory option to use the System/370 processor timer.
The processor timer is supported in a virtual machine in much the same way as is rihe interval timer. That is, the processor timer in a virtual machine records only
'virtual processor time, and it is updated when the virtual machine passes control
back to CPo If the real timer option is specified, the virtual processor timer reflects all actual
elapsed time except CP time used for services, such as privileged instruction exe­
cution, for that virtual machine.
The method of sampling the value in the virtual processor timer causes it to appear
to a virtual machine to be updated more often than an interval timer. The privi­
leged instructions Set processor Timer (SPT) and Stbre processor Timer (STPT)
are used to set a doubleword value in the virtual processor timer and to store it in a
doubleword location of virtual storage. When a virtual machine samples the value
in the virtual processor timer by issuing a STPT instruction, CP regains control to
execute the privileged instruction, and updates the time. The act of sampling the
processor timer from a virtual machine causes it to be brought up to date.
The System/370 time-of-day (TOD) clock does not require simulation in a virtual
machine. The System/370 in which CP is operating may have one real TOD clock
for each processor, and all virtual machines can interrogate the real TOD clock.
The Store Clock (STCK) instruction is nonprivileged; any virtual machine can exe­
cute it to store the current value of the TOD clock in its virtual storage. The Set Clock (SCK) instruction, which is used to set the TOD Clock value, can be issued
from a virtual machine, but CP always returns a condition code of zero and does
not actually set the clock. Note that the TOD clock is the only true source of actu­
al elapsed time information for a virtual machine. The base value for the TOD clock in VM/SP is 00:00:00 GMT, January 1,1900. In an attached processor or multiprocessor environment, the TOD clocks are syn­
chronized using the procedure described in the IBM System/3 70: Principles of
Operation.
The clock comparator associated with the TOD clock is used in virtual machines for
generating interrupts based on actual elapsed time. The ECMODE option must be
specified for a virtual machine to use the clock comparator feature. The Set Clock
Comparator (SCKC) instruction specifies a doubleword value that is placed in the
clock comparator. When the TOD clock passes that value, an interrupt is gener­
ated. 206 VM/SP System Programmer's Guide
Previous Page Next Page