Intel/AMD have an inst that returns the num of CPU cycles since boot. This is not a steady, calibrated real time value. TempleOS measures it and you can convert with cnts.time_stamp_freq, a value continuously calibrated from other cnts. Busy Funct Loosely timed. CPURep Funct Report number of cores and clock freq. GetTSC Funct _extern SYS_INITRAMFS_PTR U8* sys_initramfs_ptr; PortNop Funct Innoculous (reads IRQ Mask) which should take fixed time cnts GlbVar CCntsGlbls cnts= {1,0,2676302000,2676302,2676302000,FALSE};
Time/CPU Cycles Dates are 32-bit signed ints representing the number of days since the birth of Christ. Negative values represent B.C.E. dates. DayOfWeek Funct Day of week, given 32-bit day since AD 0. FirstDayOfMon Funct First day of month, given 32-bit day since AD 0. FirstDayOfYear Funct First day of year, given 32-bit day since AD 0. LastDayOfMon Funct Last day of month, given 32-bit day since AD 0. LastDayOfYear Funct Last day of year, given 32-bit day since AD 0. YearStartDate Funct 32-bit day since AD 0, given year number. mon_start_days1 GlbVar U16 mon_start_days1[12]= mon_start_days2 GlbVar U16 mon_start_days2[12]=
Time/Date TempleOS uses a 64-bit value, CDate, for date/time. The upper 32-bits are the days since Christ. The lower 32-bits store time of day divided by 4 billion which works out to 49710ths of a second. You can subtract two CDate's to get a time span. Use CDATE_FREQ to convert. Date2Struct Funct Cvt CDate to CDateStruct. Now Funct Current datetime. Struct2Date Funct Cvt CDateStruct to CDate. local_time_offset GlbVar CDate local_time_offset;
Time/Date/CDate One jiffy is one time slice. cnts.jiffies returns time slices since boot. SysTimerRead reads the timer ticks since boot. It's not as fast as GetTSC. Use JIFFY_FREQ to convert cnts.jiffies. Use SYS_TIMER_FREQ to convert SysTimerRead. Sleep Funct Not for power-saving. It is to make a program pause without hogging the CPU. SleepUntil Funct Not for power-saving. It is to make a program pause without hogging the CPU. SysTimerRead Funct System timer count with overflow already handled. cnts GlbVar CCntsGlbls cnts= {1,0,2676302000,2676302,2676302000,FALSE};
Time/Jiffies Beat Funct Time in music beats. tM Funct Time in seconds synced to music subsystem. tS Funct Time since boot in seconds as a float.
Time/Seconds