summaryrefslogtreecommitdiffstats
path: root/lib/libpthread
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2004-10-08 22:57:30 +0000
committerdavidxu <davidxu@FreeBSD.org>2004-10-08 22:57:30 +0000
commit7e9cf9f93431762f97cd654c8a0db849c20b6a5b (patch)
tree46b6ad6f16177e41e96b19c3d0c7b21a013c7793 /lib/libpthread
parent49fc63d1c8595ff2c00fb687bce4f7bf08dd5bd2 (diff)
downloadFreeBSD-src-7e9cf9f93431762f97cd654c8a0db849c20b6a5b.zip
FreeBSD-src-7e9cf9f93431762f97cd654c8a0db849c20b6a5b.tar.gz
if system scope thread didn't set timeout, don't call clock_gettime syscall
before and after sleeping. Reviewed by: deischen
Diffstat (limited to 'lib/libpthread')
-rw-r--r--lib/libpthread/thread/thr_kern.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/libpthread/thread/thr_kern.c b/lib/libpthread/thread/thr_kern.c
index 417e4b8..6e0003a 100644
--- a/lib/libpthread/thread/thr_kern.c
+++ b/lib/libpthread/thread/thr_kern.c
@@ -873,12 +873,14 @@ kse_sched_single(struct kse_mailbox *kmbx)
THR_DEACTIVATE_LAST_LOCK(curthread);
kse_wait(curkse, curthread, sigseqno);
THR_ACTIVATE_LAST_LOCK(curthread);
- KSE_GET_TOD(curkse, &ts);
- if (thr_timedout(curthread, &ts)) {
- /* Indicate the thread timedout: */
- curthread->timeout = 1;
- /* Make the thread runnable. */
- THR_SET_STATE(curthread, PS_RUNNING);
+ if (curthread->wakeup_time.tv_sec >= 0) {
+ KSE_GET_TOD(curkse, &ts);
+ if (thr_timedout(curthread, &ts)) {
+ /* Indicate the thread timedout: */
+ curthread->timeout = 1;
+ /* Make the thread runnable. */
+ THR_SET_STATE(curthread, PS_RUNNING);
+ }
}
}
@@ -1811,13 +1813,12 @@ kse_wait(struct kse *kse, struct pthread *td_wait, int sigseqno)
struct timespec ts, ts_sleep;
int saved_flags;
- KSE_GET_TOD(kse, &ts);
-
if ((td_wait == NULL) || (td_wait->wakeup_time.tv_sec < 0)) {
/* Limit sleep to no more than 1 minute. */
ts_sleep.tv_sec = 60;
ts_sleep.tv_nsec = 0;
} else {
+ KSE_GET_TOD(kse, &ts);
TIMESPEC_SUB(&ts_sleep, &td_wait->wakeup_time, &ts);
if (ts_sleep.tv_sec > 60) {
ts_sleep.tv_sec = 60;
OpenPOWER on IntegriCloud