diff options
author | davidxu <davidxu@FreeBSD.org> | 2010-12-22 05:01:52 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2010-12-22 05:01:52 +0000 |
commit | 437ad27f9c81f522301de0affe1fc5fef37d8828 (patch) | |
tree | d717e6b5f295c555e1deef8497d4130bec1843cf /lib/libthr/thread/thr_umtx.h | |
parent | 24b08bca030970592bc5241517b0462f603b05b1 (diff) | |
download | FreeBSD-src-437ad27f9c81f522301de0affe1fc5fef37d8828.zip FreeBSD-src-437ad27f9c81f522301de0affe1fc5fef37d8828.tar.gz |
MFp4:
- Add flags CVWAIT_ABSTIME and CVWAIT_CLOCKID for umtx kernel based
condition variable, this should eliminate an extra system call to get
current time.
- Add sub-function UMTX_OP_NWAKE_PRIVATE to wake up N channels in single
system call. Create userland sleep queue for condition variable, in most
cases, thread will wait in the queue, the pthread_cond_signal will defer
thread wakeup until the mutex is unlocked, it tries to avoid an extra
system call and a extra context switch in time window of pthread_cond_signal
and pthread_mutex_unlock.
The changes are part of process-shared mutex project.
Diffstat (limited to 'lib/libthr/thread/thr_umtx.h')
-rw-r--r-- | lib/libthr/thread/thr_umtx.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/libthr/thread/thr_umtx.h b/lib/libthr/thread/thr_umtx.h index 3f53faf..0a8034b 100644 --- a/lib/libthr/thread/thr_umtx.h +++ b/lib/libthr/thread/thr_umtx.h @@ -36,6 +36,7 @@ #define DEFAULT_URWLOCK {0,0,0,0,{0,0,0,0}} int __thr_umutex_lock(struct umutex *mtx, uint32_t id) __hidden; +int __thr_umutex_lock_spin(struct umutex *mtx, uint32_t id) __hidden; int __thr_umutex_timedlock(struct umutex *mtx, uint32_t id, const struct timespec *timeout) __hidden; int __thr_umutex_unlock(struct umutex *mtx, uint32_t id) __hidden; @@ -50,6 +51,8 @@ int _thr_umtx_wait(volatile long *mtx, long exp, const struct timespec *timeout) __hidden; int _thr_umtx_wait_uint(volatile u_int *mtx, u_int exp, const struct timespec *timeout, int shared) __hidden; +int _thr_umtx_timedwait_uint(volatile u_int *mtx, u_int exp, int clockid, + const struct timespec *timeout, int shared) __hidden; int _thr_umtx_wake(volatile void *mtx, int count, int shared) __hidden; int _thr_ucond_wait(struct ucond *cv, struct umutex *m, const struct timespec *timeout, int check_unpaking) __hidden; @@ -97,6 +100,14 @@ _thr_umutex_lock(struct umutex *mtx, uint32_t id) } static inline int +_thr_umutex_lock_spin(struct umutex *mtx, uint32_t id) +{ + if (_thr_umutex_trylock2(mtx, id) == 0) + return (0); + return (__thr_umutex_lock_spin(mtx, id)); +} + +static inline int _thr_umutex_timedlock(struct umutex *mtx, uint32_t id, const struct timespec *timeout) { |