[PATCH] use CLOCK_MONOTONIC_COARSE to reduce the system call

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



According to the description below:

        http://lkml.org/lkml/2009/7/17/258

There are two benefits:
a) it doesn't need to access the hardware.
b) avoid the syscall by using vdso clock_gettime().

The cons is the CLOCK_MONOTONIC_COARSE returns the time at the last
tick.

Signed-off-by: Deng Zhenrong <dzrongg at gmail.com>
---
 src/pulsecore/core-rtclock.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/src/pulsecore/core-rtclock.c b/src/pulsecore/core-rtclock.c
index 6632cc6..4b6daa1 100644
--- a/src/pulsecore/core-rtclock.c
+++ b/src/pulsecore/core-rtclock.c
@@ -82,12 +82,16 @@ struct timeval *pa_rtclock_get(struct timeval *tv) {
 #elif defined(HAVE_CLOCK_GETTIME)
     struct timespec ts;
 
-#ifdef CLOCK_MONOTONIC
+#if defined(CLOCK_MONOTONIC) || defined(CLOCK_MONOTONIC_COARSE)
     /* No locking or atomic ops for no_monotonic here */
     static pa_bool_t no_monotonic = FALSE;
 
     if (!no_monotonic)
+#ifdef CLOCK_MONOTONIC_COARSE
+        if (clock_gettime(CLOCK_MONOTONIC_COARSE, &ts) < 0)
+#else
         if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0)
+#endif /* CLOCK_MONOTONIC_COARSE */
             no_monotonic = TRUE;
 
     if (no_monotonic)
-- 
1.7.6.5



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux