Commit e670135f authored by Piotr Zięcik's avatar Piotr Zięcik Committed by Anas Nashif
Browse files

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: default avatarPiotr Zięcik <piotr.ziecik@nordicsemi.no>
parent 7e3eaaa0
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -641,9 +641,10 @@ 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_duration < remaining)) {
		_set_time(_time_slice_duration);
	if (!remaining || (_time_slice_ticks < remaining)) {
		_set_time(_time_slice_ticks);
	} else {
		/* Account previous elapsed time and reprogram
		 * timer with remaining time