diff options
author | davidxu <davidxu@FreeBSD.org> | 2006-12-04 14:20:41 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2006-12-04 14:20:41 +0000 |
commit | cbb0fd817469a7d2bc7e1fb808addd5ca1dbfbfd (patch) | |
tree | a26172ec91f9000244f9da29bce3919b9abbd391 /lib/libthr/thread/thr_umtx.c | |
parent | 22a81fc246efb2668eddcb6ccd27129feaa5910c (diff) | |
download | FreeBSD-src-cbb0fd817469a7d2bc7e1fb808addd5ca1dbfbfd.zip FreeBSD-src-cbb0fd817469a7d2bc7e1fb808addd5ca1dbfbfd.tar.gz |
Use kernel provided userspace condition variable to implement pthread
condition variable.
Diffstat (limited to 'lib/libthr/thread/thr_umtx.c')
-rw-r--r-- | lib/libthr/thread/thr_umtx.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/libthr/thread/thr_umtx.c b/lib/libthr/thread/thr_umtx.c index cc3cb9d..778ac80 100644 --- a/lib/libthr/thread/thr_umtx.c +++ b/lib/libthr/thread/thr_umtx.c @@ -104,3 +104,36 @@ _thr_umtx_wake(volatile umtx_t *mtx, int nr_wakeup) return (0); return (errno); } + +int +_thr_ucond_wait(struct ucond *cv, struct umutex *m, + const struct timespec *timeout, int check_unparking) +{ + if (timeout && (timeout->tv_sec < 0 || (timeout->tv_sec == 0 && + timeout->tv_nsec <= 0))) { + __thr_umutex_unlock(m); + return (ETIMEDOUT); + } + if (_umtx_op(cv, UMTX_OP_CV_WAIT, + check_unparking ? UMTX_CHECK_UNPAKING : 0, + m, __DECONST(void*, timeout)) == 0) { + return (0); + } + return (errno); +} + +int +_thr_ucond_signal(struct ucond *cv) +{ + if (_umtx_op(cv, UMTX_OP_CV_SIGNAL, 0, NULL, NULL) == 0) + return (0); + return (errno); +} + +int +_thr_ucond_broadcast(struct ucond *cv) +{ + if (_umtx_op(cv, UMTX_OP_CV_BROADCAST, 0, NULL, NULL) == 0) + return (0); + return (errno); +} |