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:
parent
88a9f4b8f9
commit
bf5dd34deb
@ -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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user