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

Shouldn't unix/sleep.c use clock_nanosleep (if available) instead of nanosleep? #7802

Closed
vicuna opened this issue Jun 8, 2018 · 5 comments
Closed

Comments

@vicuna
Copy link

vicuna commented Jun 8, 2018

Original bug ID: 7802
Reporter: berenger
Status: new
Resolution: open
Priority: normal
Severity: feature
Platform: unix-like
Category: standard library
Monitored by: @nojb

Bug description

If deemed useful, I can send a patch.

@vicuna
Copy link
Author

vicuna commented Jun 8, 2018

Comment author: @nojb

What would be the benefit of switching to clock_nanosleep?

@vicuna
Copy link
Author

vicuna commented Jun 11, 2018

Comment author: berenger

Better precision in some specific cases.
Cf. man nanosleep:

   If a program that catches signals and uses nanosleep() receives signals
   at  a very high rate, then scheduling delays and rounding errors in the
   kernel's calculation of the sleep  interval  and  the  returned  remain
   value  mean  that  the remain value may steadily increase on successive
   restarts  of  the  nanosleep()  call.   To  avoid  such  problems,  use
   clock_nanosleep(2)  with the TIMER_ABSTIME flag to sleep to an absolute
   deadline.

@vicuna
Copy link
Author

vicuna commented Jun 12, 2018

Comment author: @nojb

Thanks. Have you come across an actual situation where the current implementation is problematic or is this request about a potential problem?

Personally I am not familiar with the signal handling code, so I can't say whether this change is worth it or not, but feel free to open a PR if you would like to get wider feedback on this proposal.

@vicuna
Copy link
Author

vicuna commented Jun 13, 2018

Comment author: berenger

I am worried about the potential problem.
As a C programmer, by reading the manpage, I would have used clock_nanosleep
instead of nanosleep (maybe it became available later).
I was reading the C implementation of unix_sleep in otherlibs/unix/sleep.c, which is called by Unix.sleepf.

@github-actions
Copy link

github-actions bot commented May 7, 2020

This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc.

@github-actions github-actions bot added the Stale label May 7, 2020
@github-actions github-actions bot closed this as completed Jun 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant