Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Apr 2006 23:21:38 GMT
From:      John Birrell <jb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 96117 for review
Message-ID:  <200604252321.k3PNLcin050246@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=96117

Change 96117 by jb@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) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200604252321.k3PNLcin050246>