diff --git a/drivers/timer/native_posix_timer.c b/drivers/timer/native_posix_timer.c index e00373c2d6b..874dbd30f34 100644 --- a/drivers/timer/native_posix_timer.c +++ b/drivers/timer/native_posix_timer.c @@ -122,13 +122,27 @@ u32_t z_clock_elapsed(void) * * Note that interrupts may be received in the meanwhile and that therefore this * thread may loose context + * + * This special arch_busy_wait() is necessary due to how the POSIX arch/SOC INF + * models a CPU. Conceptually it could be thought as if the MCU was running + * at an infinitely high clock, and therefore no simulated time passes while + * executing instructions(*1). + * Therefore to be able to busy wait this function does the equivalent of + * programming a dedicated timer which will raise a non-maskable interrupt, + * and halting the CPU. + * + * (*1) In reality simulated time is simply not advanced just due to the "MCU" + * running. Meaning, the SW running on the MCU is assumed to take 0 time. */ void arch_busy_wait(u32_t usec_to_wait) { u64_t time_end = hwm_get_time() + usec_to_wait; while (hwm_get_time() < time_end) { - /*There may be wakes due to other interrupts*/ + /* + * There may be wakes due to other interrupts including + * other threads calling arch_busy_wait + */ hwtimer_wake_in_time(time_end); posix_halt_cpu(); }