native_posix: timer: Improve arch_busy_wait() doc

Expand a bit the native_posix arch_busy_wait()
documentation so it is clearer

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
This commit is contained in:
Alberto Escolar Piedras 2020-02-06 17:43:00 +01:00 committed by Carles Cufí
parent 9b024eba54
commit 90d9eb2f50

View file

@ -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();
}