From a404d58b72412b5320b199f6c13342f6f8f599ef Mon Sep 17 00:00:00 2001 From: deischen Date: Wed, 20 Dec 2000 17:04:12 +0000 Subject: 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 --- lib/libpthread/thread/thr_nanosleep.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'lib/libpthread') 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, ¤t_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, ¤t_time1); /* Calculate the remaining time to sleep: */ -- cgit v1.1