In non-periodic mode absolute times fire exactly at the time given.
When specifying a fast clock, align the firing time so that less
timer interrupt events are needed.
MFC after: 1 week
Sponsored by: NVIDIA Networking
Differential D36858
time(3): Align fast clock times to avoid firing multiple timers. • hselasky on Oct 3 2022, 9:17 AM. Authored by Tags None Referenced Files
Subscribers
Details In non-periodic mode absolute times fire exactly at the time given. MFC after: 1 week
Diff Detail
Event Timeline
Comment Actions I made the same comments in D36857 . . . Something to consider? : It looks to me that the original code tried to minimize the number of divisions (and modulo's). This might have been because of the likes of, say, "ARMv7-A implementation that does not include the Virtualization Extensions" having SDIV and UDIV as optional in the profile and ARMv7-R only requiring such instructions for Thumb, not ARM. (Just examples, I've no general knowledge of the range of platform's status for such.) I also wonder if factor or divisor or the like is intended to ever allowed to be negative in the use of %. (Some routines have signed types involved.) Checking C's language requirements for negatives involved in % operations could be important otherwise: If there is C implementation freedom, that could lead to variability in the results. Looks like C89 was the last with "implementation defined" for / and % involving negative integers. After that: 7/3==2; 7%3==1; -7/3==-2; -7%3==-1; 7/-3==-2; 7/-3==1; -7/-3==2; -7%-3==-1. So / truncates towards zero and a%b==a-(a/b)*b when a/b is representable. Notably -7%3!=7%-3 and 7%3!=-7%-3 .
Comment Actions When you divide and multiply by constants, the compiler will optimize this. Have you looked at the resulting assembly code using -O2 ? Comment Actions I think it is better to wakeup and do a bunch of work, and then go to sleep. Instead of having shorter sleeps with spread load. I'm thinking about the CPU idle stuff which affects the CPU states. Comment Actions
I understand for CLOCK_SECOND and "rem = *sbt % SBT_1S;": SBT_1S is a constant. But for "rem = *sbt % tc_tick_sbt;" no such constant is involved. On armv7, for example, it would generate/use a more expensive __aeabi_uldivmod call (or some such) that the original code would not. |