benilla-re systems structs docs

TimeManager

struct · core · 2016 bytes

Meaning
Holds the calibration state of the clock: scale, offset, thread, samples and rate estimates
Confidence
verified, proof one
Finding
core/time#calibration-thread

Finding: Calibration thread in core: time

The time manager starts a thread, OsTime, which samples the counter and GetTickCount every 250 ms into a ring of 121 samples and estimates the counter's rate over 1, 4, 20 and 120 samples. It picks the shortest span whose estimate strays from the stored rate beyond its tolerance, capped where neighbouring estimates disagree. In mode 0, a pick of the 20- or 120-sample span, or none, stores the 120-sample estimate and switches to mode 1; a 1- or 4-sample pick stores that estimate and stays. In mode 1 a pick stores its estimate and rescales, and returns to mode 0 when the short-span estimates disagree. The switch is not one-way.

The derivation is in the doc.

Fields 10

offsetsizetypenamemeaningconfidencefinding
0x00008doublem_secondsPerTickHolds the seconds per counter tick, 0.001 at constructionverified, proof onecore/time#counter-switch
0x00088doublem_offsetSecondsHolds the offset in seconds, 0 at constructionverified, proof onecore/time#counter-switch
0x00104void *m_threadHolds the calibration thread's handleverified, proof onecore/time#time-manager-lifetime
0x00144void *m_stopEventHolds the manual-reset event that stops the calibration threadverified, proof onecore/time#time-manager-lifetime
0x00184uint32_tm_intervalHolds the calibration interval in milliseconds, 250verified, proof onecore/time#calibration-thread
0x001c4uint32_tm_processorsHolds the processor countverified, proof onecore/time#multi-core-gate
0x00204uint32_tm_multiCoreHolds the multi-core bit; nonzero stops counter switchingverified, proof onecore/time#multi-core-gate
0x00281936uint8_t[1936]m_samplesHolds 121 samples of 16 bytes: counter low and high dwords, GetTickCount, paddingverified, proof onecore/time#calibration-thread
0x07b84uint32_tm_sampleIndexHolds the index of the newest sampleverified, proof onecore/time#calibration-thread
0x07c032uint64_t[4]m_estimatesHolds the counter rate estimates over 1, 4, 20 and 120 samplesverified, proof onecore/time#calibration-thread