PERFORCE change 96117 for review
John Birrell
jb at FreeBSD.org
Tue Apr 25 23:21:39 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=96117
Change 96117 by jb at jb_freebsd2 on 2006/04/25 23:20:46
We can just use some standards-complient code here.
Affected files ...
.. //depot/projects/dtrace/src/contrib/opensolaris/lib/libdtrace/common/dt_work.c#7 edit
Differences ...
==== //depot/projects/dtrace/src/contrib/opensolaris/lib/libdtrace/common/dt_work.c#7 (text) ====
@@ -37,11 +37,9 @@
int dtslt_option;
size_t dtslt_offs;
} _dtrace_sleeptab[] = {
-#if defined(sun)
{ DTRACEOPT_STATUSRATE, offsetof(dtrace_hdl_t, dt_laststatus) },
{ DTRACEOPT_AGGRATE, offsetof(dtrace_hdl_t, dt_lastagg) },
{ DTRACEOPT_SWITCHRATE, offsetof(dtrace_hdl_t, dt_lastswitch) },
-#endif
{ DTRACEOPT_MAX, 0 }
};
@@ -75,9 +73,9 @@
earliest = *((hrtime_t *)a) + interval;
}
-printf("%s:%s(%d):\n",__FUNCTION__,__FILE__,__LINE__);
(void) pthread_mutex_lock(&dph->dph_lock);
+#if defined(sun)
now = gethrtime();
if (earliest < now) {
@@ -94,6 +92,22 @@
* awaken, iterate over any pending notifications and process them.
*/
(void) pthread_cond_reltimedwait_np(&dph->dph_cv, &dph->dph_lock, &tv);
+#else
+ clock_gettime(CLOCK_REALTIME,&tv);
+ tv.tv_sec += earliest / NANOSEC;
+ tv.tv_nsec += earliest % NANOSEC;
+ while (tv.tv_nsec > NANOSEC) {
+ tv.tv_sec += 1;
+ tv.tv_nsec -= NANOSEC;
+ }
+
+ /*
+ * Wait for either 'tv' nanoseconds to pass or to receive notification
+ * that a process is in an interesting state. Regardless of why we
+ * awaken, iterate over any pending notifications and process them.
+ */
+ (void) pthread_cond_timedwait(&dph->dph_cv, &dph->dph_lock, &tv);
+#endif
while ((dprn = dph->dph_notify) != NULL) {
if (dtp->dt_prochdlr != NULL) {
More information about the p4-projects
mailing list