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

clock_gettime(2): properly handle monotonic clock #941

Merged
merged 2 commits into from Jul 24, 2019

Conversation

francescolavra
Copy link
Member

clock_gettime(2): properly handle monotonic clock

The now() function returns the wall clock time, so it will be subject to discontinuities if the system time is changed (when support for changing the system time is actually implemented), and for this reason it should not be used as time source in clock_gettime() in case the requested clock is a monotonic clock. This commit uses uptime() as time source in such cases.

Closes #357.

@eyberg eyberg requested a review from a team July 23, 2019 16:16
The uptime field is supposed to contain a number of seconds, so the
timestamp value returned by uptime() should be converted to
seconds.
The now() function returns the wall clock time, so it will be
subject to discontinuities if the system time is changed (when
support for changing the system time is actually implemented), and
for this reason it should not be used as time source in
clock_gettime() in case the requested clock is a monotonic clock.
This commit uses uptime() as time source in such cases.
In addition, the CLOCK_PROCESS_CPUTIME_ID clock type is now
implemented as well.

Closes #357.
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.

clock issues
2 participants