MCPcopy Create free account
hub / github.com/OpenDUNE/OpenDUNE / Timer_InterruptRun

Function Timer_InterruptRun

src/timer.c:89–132  ·  view source on GitHub ↗

* Run the timer interrupt handler. */

Source from the content-addressed store, hash-verified

87 * Run the timer interrupt handler.
88 */
89static void Timer_InterruptRun(int arg)
90{
91 TimerNode *node;
92 uint32 new_time, usec_delta, delta;
93 int i;
94
95 /* Lock the timer, to avoid double-calls */
96 static bool timerLock = false;
97 if (timerLock) return;
98 timerLock = true;
99
100 /* Calculate the time between calls */
101 new_time = Timer_GetTime();
102 usec_delta = (new_time - s_timerLastTime) * 1000;
103 s_timerLastTime = new_time;
104
105 /* Walk all our timers, see which (and how often) it should be triggered */
106 node = s_timerNodes;
107 for (i = 0; i < s_timerNodeCount; i++, node++) {
108 delta = usec_delta;
109
110 /* No delay means: as often as possible, but don't worry about it */
111 if (node->usec_delay == 0) {
112 node->callback();
113 continue;
114 }
115
116 if (node->callonce) {
117 if (node->usec_left <= delta) {
118 delta -= node->usec_left;
119 node->usec_left = node->usec_delay;
120 if(arg == 0) node->callback();
121 while (node->usec_left <= delta) delta -= node->usec_left;
122 }
123 } else while (node->usec_left <= delta) {
124 delta -= node->usec_left;
125 node->usec_left = node->usec_delay;
126 node->callback();
127 }
128 node->usec_left -= delta;
129 }
130
131 timerLock = false;
132}
133
134#if defined(TOS) || defined(DOS)
135void SleepAndProcessBackgroundTasks(void)

Callers 2

Timer_InterruptWindowsFunction · 0.85

Calls 1

Timer_GetTimeFunction · 0.85

Tested by

no test coverage detected