Date: Thu, 4 Nov 2010 06:51:53 +0000 (UTC) From: David Xu <davidxu@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r214772 - in user/davidxu/libthr: lib/libthr/thread sys/kern sys/sys Message-ID: <201011040651.oA46prH7046971@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: davidxu Date: Thu Nov 4 06:51:53 2010 New Revision: 214772 URL: http://svn.freebsd.org/changeset/base/214772 Log: Define UCOND_BIND_MUTEX flag to bind a umutex to a ucond, it indicates a protocol if the condition variable is shared among processes. the system call argument CVWAIT_BIND_MUTEX is removed. Modified: user/davidxu/libthr/lib/libthr/thread/thr_barrier.c user/davidxu/libthr/lib/libthr/thread/thr_cond.c user/davidxu/libthr/sys/kern/kern_umtx.c user/davidxu/libthr/sys/sys/umtx.h Modified: user/davidxu/libthr/lib/libthr/thread/thr_barrier.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_barrier.c Thu Nov 4 06:37:15 2010 (r214771) +++ user/davidxu/libthr/lib/libthr/thread/thr_barrier.c Thu Nov 4 06:51:53 2010 (r214772) @@ -102,7 +102,7 @@ _pthread_barrier_wait(pthread_barrier_t } else { cycle = bar->b_cycle; do { - _thr_ucond_wait(&bar->b_cv, &bar->b_lock, NULL, CVWAIT_BIND_MUTEX); + _thr_ucond_wait(&bar->b_cv, &bar->b_lock, NULL, 0); THR_UMUTEX_LOCK(curthread, &bar->b_lock); /* test cycle to avoid bogus wakeup */ } while (cycle == bar->b_cycle); Modified: user/davidxu/libthr/lib/libthr/thread/thr_cond.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_cond.c Thu Nov 4 06:37:15 2010 (r214771) +++ user/davidxu/libthr/lib/libthr/thread/thr_cond.c Thu Nov 4 06:51:53 2010 (r214772) @@ -80,6 +80,7 @@ cond_init(pthread_cond_t *cond, const pt pcond->c_pshared = (*cond_attr)->c_pshared; pcond->c_clockid = (*cond_attr)->c_clockid; } + pcond->c_kerncv.c_flags |= UCOND_BIND_MUTEX; *cond = pcond; } /* Return the completion status: */ @@ -188,10 +189,10 @@ cond_wait_common(pthread_cond_t *cond, p if (cancel) { _thr_cancel_enter2(curthread, 0); - ret = _thr_ucond_wait(&cv->c_kerncv, &m->m_lock, tsp, CVWAIT_BIND_MUTEX); + ret = _thr_ucond_wait(&cv->c_kerncv, &m->m_lock, tsp, 0); _thr_cancel_leave(curthread, 0); } else { - ret = _thr_ucond_wait(&cv->c_kerncv, &m->m_lock, tsp, CVWAIT_BIND_MUTEX); + ret = _thr_ucond_wait(&cv->c_kerncv, &m->m_lock, tsp, 0); } if (ret == 0) { Modified: user/davidxu/libthr/sys/kern/kern_umtx.c ============================================================================== --- user/davidxu/libthr/sys/kern/kern_umtx.c Thu Nov 4 06:37:15 2010 (r214771) +++ user/davidxu/libthr/sys/kern/kern_umtx.c Thu Nov 4 06:51:53 2010 (r214772) @@ -2495,9 +2495,9 @@ do_cv_wait(struct thread *td, struct uco if (error != 0) return (error); savekey = uq->uq_key; - if ((wflags & CVWAIT_BIND_MUTEX) != 0) { + if ((flags & UCOND_BIND_MUTEX) != 0) { if ((mflags & UMUTEX_PRIO_INHERIT) != 0) - return (EINVAL); + goto ignore; error = umtx_key_get(m, TYPE_NORMAL_UMUTEX, GET_SHARE(mflags), &mkey); if (error != 0) { @@ -2510,6 +2510,7 @@ do_cv_wait(struct thread *td, struct uco bind_mutex = NULL; mkeyp = &mkey; } else { +ignore: bind_mutex = NULL; mkeyp = NULL; } Modified: user/davidxu/libthr/sys/sys/umtx.h ============================================================================== --- user/davidxu/libthr/sys/sys/umtx.h Thu Nov 4 06:37:15 2010 (r214771) +++ user/davidxu/libthr/sys/sys/umtx.h Thu Nov 4 06:51:53 2010 (r214772) @@ -54,6 +54,8 @@ #define URWLOCK_MAX_READERS 0x1fffffffU #define URWLOCK_READER_COUNT(c) ((c) & URWLOCK_MAX_READERS) +#define UCOND_BIND_MUTEX 0x0002 + /* _usem flags */ #define SEM_NAMED 0x0002 @@ -83,7 +85,6 @@ /* flags for UMTX_OP_CV_WAIT */ #define CVWAIT_CHECK_UNPARKING 0x01 -#define CVWAIT_BIND_MUTEX 0x02 #define UMTX_CHECK_UNPARKING _CVWAIT_CHECK_UNPARKING #ifndef _KERNEL
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201011040651.oA46prH7046971>