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 <piotr.ziecik@nordicsemi.no>
This commit is contained in:
Piotr Zięcik 2018-07-26 14:56:39 +02:00 committed by Anas Nashif
commit 2a26576b03

View file

@ -641,10 +641,9 @@ void _update_time_slice_before_swap(void)
}
u32_t remaining = _get_remaining_program_time();
u32_t time_slice_ticks = _ms_to_ticks(_time_slice_duration);
if (!remaining || (_time_slice_ticks < remaining)) {
_set_time(_time_slice_ticks);
if (!remaining || (_time_slice_duration < remaining)) {
_set_time(_time_slice_duration);
} else {
/* Account previous elapsed time and reprogram
* timer with remaining time