Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007802OCamlstandard librarypublic2018-06-08 08:362018-06-13 02:26
Reporterberenger 
Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
StatusnewResolutionopen 
Platformunix-likeOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0007802: Shouldn't unix/sleep.c use clock_nanosleep (if available) instead of nanosleep?
DescriptionIf deemed useful, I can send a patch.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0019167)
nojebar (developer)
2018-06-08 10:23

What would be the benefit of switching to clock_nanosleep?
(0019177)
berenger (reporter)
2018-06-11 02:44

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.
---
(0019185)
nojebar (developer)
2018-06-12 15:22

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.
(0019186)
berenger (reporter)
2018-06-13 02:26

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.

- Issue History
Date Modified Username Field Change
2018-06-08 08:36 berenger New Issue
2018-06-08 10:23 nojebar Note Added: 0019167
2018-06-11 02:44 berenger Note Added: 0019177
2018-06-12 15:22 nojebar Note Added: 0019185
2018-06-13 02:26 berenger Note Added: 0019186


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker