Skip to content

Commit 4c85b46

Browse files
laurenmurphyx64galak
authored andcommitted
kernel: k_sleep: fix return value for absolute timeout
Fixes calculation of remaining ticks returned from z_tick_sleep so that it takes absolute timeouts into account. Fixes #32506 Signed-off-by: Lauren Murphy <[email protected]>
1 parent 5b8d418 commit 4c85b46

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

kernel/sched.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,8 +1227,11 @@ static int32_t z_tick_sleep(k_ticks_t ticks)
12271227
}
12281228

12291229
k_timeout_t timeout = Z_TIMEOUT_TICKS(ticks);
1230-
1231-
expected_wakeup_ticks = ticks + sys_clock_tick_get_32();
1230+
if (Z_TICK_ABS(ticks) <= 0) {
1231+
expected_wakeup_ticks = ticks + sys_clock_tick_get_32();
1232+
} else {
1233+
expected_wakeup_ticks = Z_TICK_ABS(ticks);
1234+
}
12321235

12331236
k_spinlock_key_t key = k_spin_lock(&sched_spinlock);
12341237

0 commit comments

Comments
 (0)