Skip to content

Commit 2a26576

Browse files
pizi-nordicnashif
authored andcommitted
kernel: sched: Use ticks as time unit in time slicing.
The time slicing settings was kept in milliseconds while all related operations was based on ticks. Continuous back and forth conversion between ticks and milliseconds introduced an accumulating error due to rounding in _ms_to_ticks() and __ticks_to_ms(). As result configured time slice duration was not achieved. This commit removes excessive ticks <-> ms conversion by using ticks as time unit for all operations related to time slicing. Also, it fixes #8896 as well as #8897. Signed-off-by: Piotr Zięcik <[email protected]>
1 parent e670135 commit 2a26576

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

kernel/sched.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -641,10 +641,9 @@ 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);
645644

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

0 commit comments

Comments
 (0)