]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/kern/kern_clock.c
xnu-3247.1.106.tar.gz
[apple/xnu.git] / bsd / kern / kern_clock.c
index 0cbd41e1bdeb6fe880cefe8e39d6f2817284b186..f0e0513450156cef708d788a2e047cfd733fad84 100644 (file)
@@ -140,6 +140,31 @@ timeout(
        thread_call_func_delayed((thread_call_func_t)fcn, param, deadline);
 }
 
+/*
+ *     Set a timeout with leeway.
+ *
+ *     fcn:            function to call
+ *     param:          parameter to pass to function
+ *     interval:       timeout interval, in hz.
+ *     leeway_interval:        leeway interval, in hz.
+ */
+void
+timeout_with_leeway(
+       timeout_fcn_t                   fcn,
+       void                                    *param,
+       int                                             interval,
+       int                                             leeway_interval)
+{
+       uint64_t                deadline;
+       uint64_t                leeway;
+
+       clock_interval_to_deadline(interval, NSEC_PER_SEC / hz, &deadline);
+
+       clock_interval_to_absolutetime_interval(leeway_interval, NSEC_PER_SEC / hz, &leeway);
+
+       thread_call_func_delayed_with_leeway((thread_call_func_t)fcn, param, deadline, leeway, THREAD_CALL_DELAY_LEEWAY);
+}
+
 /*
  * Cancel a timeout.
  */
@@ -241,7 +266,7 @@ sysctl_clockrate
 }
 
 SYSCTL_PROC(_kern, KERN_CLOCKRATE, clockrate,
-               CTLTYPE_STRUCT | CTLFLAG_RD,
+               CTLTYPE_STRUCT | CTLFLAG_RD | CTLFLAG_LOCKED,
                0, 0, sysctl_clockrate, "S,clockinfo", "");