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_cancel.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_cancel.c')
-rw-r--r-- | lib/libthr/thread/thr_cancel.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/lib/libthr/thread/thr_cancel.c b/lib/libthr/thread/thr_cancel.c index 8df0304..3222948 100644 --- a/lib/libthr/thread/thr_cancel.c +++ b/lib/libthr/thread/thr_cancel.c @@ -42,7 +42,7 @@ static inline void testcancel(struct pthread *curthread) { if (__predict_false(SHOULD_CANCEL(curthread) && - !THR_IN_CRITICAL(curthread))) + !THR_IN_CRITICAL(curthread) && curthread->cancel_defer == 0)) _pthread_exit(PTHREAD_CANCELED); } @@ -155,3 +155,24 @@ _thr_cancel_leave(struct pthread *curthread) if (curthread->cancel_enable) curthread->cancel_point--; } + +void +_thr_cancel_enter_defer(struct pthread *curthread) +{ + if (curthread->cancel_enable) { + curthread->cancel_point++; + testcancel(curthread); + curthread->cancel_defer++; + } +} + +void +_thr_cancel_leave_defer(struct pthread *curthread, int check) +{ + if (curthread->cancel_enable) { + curthread->cancel_defer--; + if (check) + testcancel(curthread); + curthread->cancel_point--; + } +} |