kernel: Fix timeout issue with SYSTEM_CLOCK_SLOPPY_IDLE
We can't simply use CLAMP to set the next timeout because when CONFIG_SYSTEM_CLOCK_SLOPPY_IDLE is set, MAX_WAIT is a negative number and then CLAMP will be called with the higher boundary lower the lower boundary. Fixes #41422 Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
parent
576e0da9f7
commit
47b7c2e931
1 changed files with 8 additions and 2 deletions
|
@ -68,8 +68,14 @@ static int32_t next_timeout(void)
|
|||
{
|
||||
struct _timeout *to = first();
|
||||
int32_t ticks_elapsed = elapsed();
|
||||
int32_t ret = to == NULL ? MAX_WAIT
|
||||
: CLAMP(to->dticks - ticks_elapsed, 0, MAX_WAIT);
|
||||
int32_t ret;
|
||||
|
||||
if ((to == NULL) ||
|
||||
((int64_t)(to->dticks - ticks_elapsed) > (int64_t)INT_MAX)) {
|
||||
ret = MAX_WAIT;
|
||||
} else {
|
||||
ret = MAX(0, to->dticks - ticks_elapsed);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_TIMESLICING
|
||||
if (_current_cpu->slice_ticks && _current_cpu->slice_ticks < ret) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue