kernel: sched: sleep: Use value returned by z_add_timeout
z_tick_sleep function needs to calculate expected wakeup tick. It required reading current system clock tick. It can be costly since it is a register access. When timeout is added this value is calculated and z_add_timeout returns it. It can be used instead to optimize sleep performance. Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
parent
5f55fed4bb
commit
66daaf6ba3
1 changed files with 1 additions and 7 deletions
|
@ -1091,19 +1091,13 @@ static int32_t z_tick_sleep(k_timeout_t timeout)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (Z_IS_TIMEOUT_RELATIVE(timeout)) {
|
||||
expected_wakeup_ticks = timeout.ticks + sys_clock_tick_get_32();
|
||||
} else {
|
||||
expected_wakeup_ticks = Z_TICK_ABS(timeout.ticks);
|
||||
}
|
||||
|
||||
k_spinlock_key_t key = k_spin_lock(&_sched_spinlock);
|
||||
|
||||
#if defined(CONFIG_TIMESLICING) && defined(CONFIG_SWAP_NONATOMIC)
|
||||
pending_current = _current;
|
||||
#endif /* CONFIG_TIMESLICING && CONFIG_SWAP_NONATOMIC */
|
||||
unready_thread(_current);
|
||||
z_add_thread_timeout(_current, timeout);
|
||||
expected_wakeup_ticks = (uint32_t)z_add_thread_timeout(_current, timeout);
|
||||
z_mark_thread_as_sleeping(_current);
|
||||
|
||||
(void)z_swap(&_sched_spinlock, key);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue