diff options
author | davidxu <davidxu@FreeBSD.org> | 2003-07-03 13:36:29 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2003-07-03 13:36:29 +0000 |
commit | 2d545c0325ebd6225a22298a5cffc0570a56fb16 (patch) | |
tree | 3a9c8ea250328dbe4e64a79c6913d068fb2ad1e1 /lib/libpthread/thread | |
parent | fa35478dfe8e5268d7fb4da151147ab3de075bef (diff) | |
download | FreeBSD-src-2d545c0325ebd6225a22298a5cffc0570a56fb16.zip FreeBSD-src-2d545c0325ebd6225a22298a5cffc0570a56fb16.tar.gz |
If select() is only used for sleep, convert it to nanosleep,
it only need purely wait in user space.
Diffstat (limited to 'lib/libpthread/thread')
-rw-r--r-- | lib/libpthread/thread/thr_select.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/libpthread/thread/thr_select.c b/lib/libpthread/thread/thr_select.c index 6714af0..25be6a9 100644 --- a/lib/libpthread/thread/thr_select.c +++ b/lib/libpthread/thread/thr_select.c @@ -50,11 +50,16 @@ __select(int numfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) { struct pthread *curthread = _get_curthread(); + struct timespec ts; int ret; - _thr_enter_cancellation_point(curthread); - ret = __sys_select(numfds, readfds, writefds, exceptfds, timeout); - _thr_leave_cancellation_point(curthread); - + if (numfds == 0 && timeout != NULL) { + TIMEVAL_TO_TIMESPEC(timeout, &ts); + return nanosleep(&ts, NULL); + } else { + _thr_enter_cancellation_point(curthread); + ret = __sys_select(numfds, readfds, writefds, exceptfds, timeout); + _thr_leave_cancellation_point(curthread); + } return ret; } |