summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authordeischen <deischen@FreeBSD.org>2000-12-20 17:04:12 +0000
committerdeischen <deischen@FreeBSD.org>2000-12-20 17:04:12 +0000
commita404d58b72412b5320b199f6c13342f6f8f599ef (patch)
tree553ef30f3d8cfba00a59207a84d790351b25a6bd /lib
parent686921163f604a169f930948d1f947fa0d7c8354 (diff)
downloadFreeBSD-src-a404d58b72412b5320b199f6c13342f6f8f599ef.zip
FreeBSD-src-a404d58b72412b5320b199f6c13342f6f8f599ef.tar.gz
When retrieving the time of day in nanosleep(), store it in the
global time of day. This costs us nothing, but is a bit of a hack to work around a process blocking and not having the time updated by an ITIMER_PROF signal. PR: 23679
Diffstat (limited to 'lib')
-rw-r--r--lib/libc_r/uthread/uthread_nanosleep.c16
-rw-r--r--lib/libkse/thread/thr_nanosleep.c16
-rw-r--r--lib/libpthread/thread/thr_nanosleep.c16
3 files changed, 36 insertions, 12 deletions
diff --git a/lib/libc_r/uthread/uthread_nanosleep.c b/lib/libc_r/uthread/uthread_nanosleep.c
index 3bbc9a6..67dd08d 100644
--- a/lib/libc_r/uthread/uthread_nanosleep.c
+++ b/lib/libc_r/uthread/uthread_nanosleep.c
@@ -54,8 +54,12 @@ _nanosleep(const struct timespec * time_to_sleep,
errno = EINVAL;
ret = -1;
} else {
- /* Get the current time: */
- gettimeofday(&tv, NULL);
+ /*
+ * As long as we're going to get the time of day, we
+ * might as well store it in the global time of day:
+ */
+ gettimeofday((struct timeval *) &_sched_tod, NULL);
+ GET_CURRENT_TOD(tv);
TIMEVAL_TO_TIMESPEC(&tv, &current_time);
/* Calculate the time for the current thread to wake up: */
@@ -73,8 +77,12 @@ _nanosleep(const struct timespec * time_to_sleep,
/* Reschedule the current thread to sleep: */
_thread_kern_sched_state(PS_SLEEP_WAIT, __FILE__, __LINE__);
- /* Get the current time: */
- gettimeofday(&tv, NULL);
+ /*
+ * As long as we're going to get the time of day, we
+ * might as well store it in the global time of day:
+ */
+ gettimeofday((struct timeval *) &_sched_tod, NULL);
+ GET_CURRENT_TOD(tv);
TIMEVAL_TO_TIMESPEC(&tv, &current_time1);
/* Calculate the remaining time to sleep: */
diff --git a/lib/libkse/thread/thr_nanosleep.c b/lib/libkse/thread/thr_nanosleep.c
index 3bbc9a6..67dd08d 100644
--- a/lib/libkse/thread/thr_nanosleep.c
+++ b/lib/libkse/thread/thr_nanosleep.c
@@ -54,8 +54,12 @@ _nanosleep(const struct timespec * time_to_sleep,
errno = EINVAL;
ret = -1;
} else {
- /* Get the current time: */
- gettimeofday(&tv, NULL);
+ /*
+ * As long as we're going to get the time of day, we
+ * might as well store it in the global time of day:
+ */
+ gettimeofday((struct timeval *) &_sched_tod, NULL);
+ GET_CURRENT_TOD(tv);
TIMEVAL_TO_TIMESPEC(&tv, &current_time);
/* Calculate the time for the current thread to wake up: */
@@ -73,8 +77,12 @@ _nanosleep(const struct timespec * time_to_sleep,
/* Reschedule the current thread to sleep: */
_thread_kern_sched_state(PS_SLEEP_WAIT, __FILE__, __LINE__);
- /* Get the current time: */
- gettimeofday(&tv, NULL);
+ /*
+ * As long as we're going to get the time of day, we
+ * might as well store it in the global time of day:
+ */
+ gettimeofday((struct timeval *) &_sched_tod, NULL);
+ GET_CURRENT_TOD(tv);
TIMEVAL_TO_TIMESPEC(&tv, &current_time1);
/* Calculate the remaining time to sleep: */
diff --git a/lib/libpthread/thread/thr_nanosleep.c b/lib/libpthread/thread/thr_nanosleep.c
index 3bbc9a6..67dd08d 100644
--- a/lib/libpthread/thread/thr_nanosleep.c
+++ b/lib/libpthread/thread/thr_nanosleep.c
@@ -54,8 +54,12 @@ _nanosleep(const struct timespec * time_to_sleep,
errno = EINVAL;
ret = -1;
} else {
- /* Get the current time: */
- gettimeofday(&tv, NULL);
+ /*
+ * As long as we're going to get the time of day, we
+ * might as well store it in the global time of day:
+ */
+ gettimeofday((struct timeval *) &_sched_tod, NULL);
+ GET_CURRENT_TOD(tv);
TIMEVAL_TO_TIMESPEC(&tv, &current_time);
/* Calculate the time for the current thread to wake up: */
@@ -73,8 +77,12 @@ _nanosleep(const struct timespec * time_to_sleep,
/* Reschedule the current thread to sleep: */
_thread_kern_sched_state(PS_SLEEP_WAIT, __FILE__, __LINE__);
- /* Get the current time: */
- gettimeofday(&tv, NULL);
+ /*
+ * As long as we're going to get the time of day, we
+ * might as well store it in the global time of day:
+ */
+ gettimeofday((struct timeval *) &_sched_tod, NULL);
+ GET_CURRENT_TOD(tv);
TIMEVAL_TO_TIMESPEC(&tv, &current_time1);
/* Calculate the remaining time to sleep: */
OpenPOWER on IntegriCloud