1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-15 17:43:51 +01:00

ztimer/overhead: acquire and release clocks

The start/stop overhead that might by introduced by ztimer_acquire() and ztimer_release() called during ztimer_set() resp. ztimer_handler() should not be mesured here. It has its own adjustment field.

Furthermore, the overhead mesaurement uses ztimer_now(). It is allowed to called it only after the clock has been acquired.
This commit is contained in:
Jue 2022-11-03 14:01:59 +01:00
parent 88a9f4b8f9
commit bf5dd34deb

View File

@ -43,18 +43,21 @@ int32_t ztimer_overhead_set(ztimer_clock_t *clock, uint32_t base)
callback_arg_t arg = { .clock = clock, .val = &after };
ztimer_t t = { .callback = _callback, .arg = &arg };
ztimer_acquire(clock);
pre = ztimer_now(clock);
ztimer_set(clock, &t, base);
while (!after) {}
ztimer_release(clock);
return after - pre - base;
}
int32_t ztimer_overhead_sleep(ztimer_clock_t *clock, uint32_t base)
{
ztimer_acquire(clock);
uint32_t pre = ztimer_now(clock);
ztimer_sleep(clock, base);
uint32_t after = ztimer_now(clock);
ztimer_release(clock);
return after - pre - base;
}