Intime.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Dan Swinehart April 14, 1982 11:31 am
Maureen Stone June 3, 1982 10:51 am
Paul Rovner July 20, 1983 1:27 pm
Doug Wyatt, April 14, 1985 8:20:24 pm PST
DIRECTORY
Basics USING [DivMod, HighHalf, LowHalf],
Process USING [Milliseconds, Ticks];
Intime: DEFINITIONS
IMPORTS Basics
= BEGIN
MsTicks: TYPE = Process.Milliseconds; -- expressed in milliseconds
MSTicks: TYPE = LONG CARDINAL; -- long milliseconds
DeltaTicks: TYPE = Process.Ticks;
grain of resolution for Increek events
DeltaTime: TYPE = DeltaTicks [0..256);
expresses time differences in tick units
maxDeltaTime: DeltaTime = LAST[DeltaTime];
fits in a short event value cell
msPerDeltaTick: MsTicks;
deltaTicksPerSecond: DeltaTicks;
DeltaDeltaTime: TYPE = DeltaTime [0..16); -- must fit in Action first word
maxDeltaDeltaTime: DeltaDeltaTime = LAST[DeltaDeltaTime];
Overlap: TYPE = {loShort, hiShort};
EventTime: TYPE = MACHINE DEPENDENT RECORD [
SELECT OVERLAID Overlap FROM
loShort => [lo: MsTicks, hi: LONG CARDINAL],
hiShort => [lower: MSTicks, higher: CARDINAL],
ENDCASE
];
milliseconds since 1901
ReadEventTime: PROC RETURNS [EventTime];
AdjustEventTime: PROC [initialize: BOOLFALSE];
BigDifference: PRIVATE PROC [t1, t2: LONG POINTER TO READONLY EventTime]
RETURNS
[MsTicks];
EventTimeDifference: PROC [t1, t2: LONG POINTER TO READONLY EventTime]
RETURNS
[MsTicks]
= INLINE { RETURN[IF t1.hi = t2.hi THEN t1.lo - t2.lo ELSE BigDifference[t1, t2]] };
IsLaterTime: PROC [t1, t2: EventTime] RETURNS [BOOL]
= INLINE { RETURN[IF t1.hi = t2.hi THEN t1.lo > t2.lo ELSE t1.hi > t2.hi] };
AddDeltaTimeToEventTime: PROC [eT: EventTime, dT: DeltaTime]
RETURNS
[rT: EventTime]
= INLINE {
lo: MSTicks ← LONG[eT.lo] + (dT*msPerDeltaTick);
RETURN[[loShort[hi: eT.hi + Basics.HighHalf[lo], lo: Basics.LowHalf[lo]]]];
};
SubtractMsTicksFromEventTime: PROC [eT: LONG POINTER TO EventTime, ticks: MsTicks]
= INLINE {
IF ticks > eT.lower THEN eT.higher ← eT.higher - 1;
eT.lower ← eT.lower - ticks;
};
MsTicksToDeltaTime: PROC [s: MsTicks] RETURNS [dT: DeltaTicks, rem: MsTicks]
= INLINE { [dT, rem] ← Basics.DivMod[s, msPerDeltaTick]; };
END.
DCS, July 2, 1980 2:39 PM, birth, extracted from Increeks
July 2, 1980 2:56 PM, more
July 17, 1980 3:17 PM, remove AddTimeToPosTime, involves Positions
July 21, 1980 8:16 AM, add StoredTimeToEventTime
August 7, 1980 9:35 AM, change EventTimeDifference to StoredEvent...ce, add EventTimeDiff..ce
August 12, 1980 12:37 AM, change time representation again, all milliseconds
August 12, 1980 4:23 PM, add SubtractMsTicksFromEventTime
August 19, 1980 4:45 PM, difference operates on READONLYs
September 9, 1980 2:57 PM, long pointers
September 12, 1980 5:47 AM, modify DeltaTime a little
October 2, 1980 3:36 PM, make EventTime internals PRIVATE
29-Jan-81 13:49:38, narrow DeltaDeltaTime to widen Action kind