diff options
author | davidxu <davidxu@FreeBSD.org> | 2012-02-27 13:38:52 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2012-02-27 13:38:52 +0000 |
commit | 96aacc2279b7b65fc0c8ff707abe3d020c1e8378 (patch) | |
tree | 9e46c0856016e3264151a062bf52ebb933fca926 /lib/libthr/thread/thr_rwlock.c | |
parent | 8a35bc6c4fda7b720a969d6cb7122d1667a826d5 (diff) | |
download | FreeBSD-src-96aacc2279b7b65fc0c8ff707abe3d020c1e8378.zip FreeBSD-src-96aacc2279b7b65fc0c8ff707abe3d020c1e8378.tar.gz |
Follow changes made in revision 232144, pass absolute timeout to kernel,
this eliminates a clock_gettime() syscall.
Diffstat (limited to 'lib/libthr/thread/thr_rwlock.c')
-rw-r--r-- | lib/libthr/thread/thr_rwlock.c | 26 |
1 files changed, 2 insertions, 24 deletions
diff --git a/lib/libthr/thread/thr_rwlock.c b/lib/libthr/thread/thr_rwlock.c index ebdeae7..397663e 100644 --- a/lib/libthr/thread/thr_rwlock.c +++ b/lib/libthr/thread/thr_rwlock.c @@ -123,7 +123,6 @@ rwlock_rdlock_common(pthread_rwlock_t *rwlock, const struct timespec *abstime) { struct pthread *curthread = _get_curthread(); pthread_rwlock_t prwlock; - struct timespec ts, ts2, *tsp; int flags; int ret; @@ -162,18 +161,8 @@ rwlock_rdlock_common(pthread_rwlock_t *rwlock, const struct timespec *abstime) return (EINVAL); for (;;) { - if (abstime) { - clock_gettime(CLOCK_REALTIME, &ts); - TIMESPEC_SUB(&ts2, abstime, &ts); - if (ts2.tv_sec < 0 || - (ts2.tv_sec == 0 && ts2.tv_nsec <= 0)) - return (ETIMEDOUT); - tsp = &ts2; - } else - tsp = NULL; - /* goto kernel and lock it */ - ret = __thr_rwlock_rdlock(&prwlock->lock, flags, tsp); + ret = __thr_rwlock_rdlock(&prwlock->lock, flags, abstime); if (ret != EINTR) break; @@ -255,7 +244,6 @@ rwlock_wrlock_common (pthread_rwlock_t *rwlock, const struct timespec *abstime) { struct pthread *curthread = _get_curthread(); pthread_rwlock_t prwlock; - struct timespec ts, ts2, *tsp; int ret; CHECK_AND_INIT_RWLOCK @@ -275,18 +263,8 @@ rwlock_wrlock_common (pthread_rwlock_t *rwlock, const struct timespec *abstime) return (EINVAL); for (;;) { - if (abstime != NULL) { - clock_gettime(CLOCK_REALTIME, &ts); - TIMESPEC_SUB(&ts2, abstime, &ts); - if (ts2.tv_sec < 0 || - (ts2.tv_sec == 0 && ts2.tv_nsec <= 0)) - return (ETIMEDOUT); - tsp = &ts2; - } else - tsp = NULL; - /* goto kernel and lock it */ - ret = __thr_rwlock_wrlock(&prwlock->lock, tsp); + ret = __thr_rwlock_wrlock(&prwlock->lock, abstime); if (ret == 0) { prwlock->owner = curthread; break; |