Skip to content

Commit e670135

Browse files
pizi-nordicnashif
authored andcommitted
kernel: sched: Fix comparsion in _update_time_slice_before_swap()
The _update_time_slice_before_swap() function directly compared _time_slice_duration (expressed in ms) with value returned by _get_remaining_program_time() which used ticks as a time unit. Moreover, the _time_slice_duration was also used as an argument for _set_time(), which expects time expressed in ticks. This commit ensures that the same unit (ticks) is used in comparsion and timer adjustments. Signed-off-by: Piotr Zięcik <[email protected]>
1 parent 7e3eaaa commit e670135

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

kernel/sched.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,9 +641,10 @@ void _update_time_slice_before_swap(void)
641641
}
642642

643643
u32_t remaining = _get_remaining_program_time();
644+
u32_t time_slice_ticks = _ms_to_ticks(_time_slice_duration);
644645

645-
if (!remaining || (_time_slice_duration < remaining)) {
646-
_set_time(_time_slice_duration);
646+
if (!remaining || (_time_slice_ticks < remaining)) {
647+
_set_time(_time_slice_ticks);
647648
} else {
648649
/* Account previous elapsed time and reprogram
649650
* timer with remaining time

0 commit comments

Comments
 (0)