File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -122,13 +122,27 @@ u32_t z_clock_elapsed(void)
122
122
*
123
123
* Note that interrupts may be received in the meanwhile and that therefore this
124
124
* thread may loose context
125
+ *
126
+ * This special arch_busy_wait() is necessary due to how the POSIX arch/SOC INF
127
+ * models a CPU. Conceptually it could be thought as if the MCU was running
128
+ * at an infinitely high clock, and therefore no simulated time passes while
129
+ * executing instructions(*1).
130
+ * Therefore to be able to busy wait this function does the equivalent of
131
+ * programming a dedicated timer which will raise a non-maskable interrupt,
132
+ * and halting the CPU.
133
+ *
134
+ * (*1) In reality simulated time is simply not advanced just due to the "MCU"
135
+ * running. Meaning, the SW running on the MCU is assumed to take 0 time.
125
136
*/
126
137
void arch_busy_wait (u32_t usec_to_wait )
127
138
{
128
139
u64_t time_end = hwm_get_time () + usec_to_wait ;
129
140
130
141
while (hwm_get_time () < time_end ) {
131
- /*There may be wakes due to other interrupts*/
142
+ /*
143
+ * There may be wakes due to other interrupts including
144
+ * other threads calling arch_busy_wait
145
+ */
132
146
hwtimer_wake_in_time (time_end );
133
147
posix_halt_cpu ();
134
148
}
You can’t perform that action at this time.
0 commit comments