-
Notifications
You must be signed in to change notification settings - Fork 8.3k
kernel: sched: Use ticks as time unit in time slicing. #9137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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 <piotr.ziecik@nordicsemi.no>
bc43901 to
751dea7
Compare
Codecov Report
@@ Coverage Diff @@
## master #9137 +/- ##
==========================================
+ Coverage 52.45% 52.45% +<.01%
==========================================
Files 200 200
Lines 25123 25124 +1
Branches 5245 5245
==========================================
+ Hits 13178 13179 +1
Misses 9824 9824
Partials 2121 2121
Continue to review full report at Codecov.
|
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>
751dea7 to
37e105d
Compare
| s32_t _time_slice_elapsed; | ||
| s32_t _time_slice_duration = CONFIG_TIMESLICE_SIZE; | ||
| int _time_slice_prio_ceiling = CONFIG_TIMESLICE_PRIORITY; | ||
| s32_t _time_slice_duration; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duration and ceiling are now initialized to 0, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or, actually, they are initialized by k_sched_time_slice_set in _sched_init, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
ioannisg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK to me.
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 PR removes excessive ticks <-> ms conversion by using ticks as time unit for all operations related to time slicing.
Also, it fixes #8896, #8897 and #9310