Skip to content
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

[kernel] Reduce precision time routines single routine #1962

Merged
merged 3 commits into from
Aug 13, 2024
Merged

Conversation

ghaerr
Copy link
Owner

@ghaerr ghaerr commented Aug 13, 2024

Pursuant to continued discussion in Mellvik/TLVC#71 (comment).

The following changes are made to the precision timing routines:

  • get_time_10ms and get_time routines removed.
  • get_time_50ms routine renamed get_ptime
  • get_ptime returns continuous 0.838us precision from 0.838us to ~42 seconds.
  • get_ptime returns unsigned long to allow for greater elapsed time. However, if elapsed time is known to be < 50ms, the returned value can be cast to unsigned int for use without the trouble of subsequent 32-bit handling.
  • get_ptime returns 0 on overflow: elapsed time > 42.85 seconds.
  • Sub-10ms handling within get_ptime is very quick and only uses unsigned int and no multiplies/divide.
  • Corrected bug on jiffies overflow on elapsed time over ~32 seconds.
  • Noticed that 5 through 9 seconds is correctly displayed as 5000.000ms through 9999.999ms. Currently not fixed as would add quite a bit of code in printk formatting routine. 1-4 seconds and 10+ seconds displayed properly.

Tested on QEMU and timings are consistent.

Next step will be to start working on user mode C library version of get_ptime which will share almost the same code, except for the method of reading kernel jiffies.

@ghaerr ghaerr merged commit d6dfdfe into master Aug 13, 2024
3 checks passed
@ghaerr ghaerr deleted the prectimer3 branch August 13, 2024 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant