X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/2d21ac55c334faf3a56e5634905ed6987fc787d4..ecc0ceb4089d506a0b8d16686a95817b331af9cb:/bsd/kern/kern_clock.c?ds=inline diff --git a/bsd/kern/kern_clock.c b/bsd/kern/kern_clock.c index 432a0f0e8..f0e051345 100644 --- a/bsd/kern/kern_clock.c +++ b/bsd/kern/kern_clock.c @@ -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", ""); @@ -314,7 +339,7 @@ void startprofclock(struct proc *p) { if ((p->p_flag & P_PROFIL) == 0) - OSBitOrAtomic(P_PROFIL, (UInt32 *)&p->p_flag); + OSBitOrAtomic(P_PROFIL, &p->p_flag); } /* @@ -324,7 +349,7 @@ void stopprofclock(struct proc *p) { if (p->p_flag & P_PROFIL) - OSBitAndAtomic(~((uint32_t)P_PROFIL), (UInt32 *)&p->p_flag); + OSBitAndAtomic(~((uint32_t)P_PROFIL), &p->p_flag); } /* TBD locking user profiling is not resolved yet */